fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. using i64 = int64_t;
  5.  
  6. void setIO(string s) {
  7. freopen((s+".in").c_str(), "r", stdin);
  8. freopen((s+".out").c_str(), "w", stdout);
  9. }
  10.  
  11. const int MAXN = 310;
  12. int N;
  13. char G[MAXN][MAXN];
  14.  
  15. i64 ans = 0;
  16. bitset<MAXN> bs[MAXN];
  17.  
  18. void go() {
  19. for (int i = 0; i < N; i++) {
  20. for (int j = 0; j < N; j++) {
  21. bs[i][j] = (G[i][j] == '*');
  22. }
  23. }
  24. for (int a0 = 0; a0 < N; a0++) {
  25. for (int x = 1; x < N; x++) {
  26. for (int y = x; y < N; y += 2) {
  27. int b0 = a0+x;
  28. int c0 = b0+(x+y)/2;
  29. if (c0 >= N) break;
  30. int bshift = y;
  31. int cshift = (y-x)/2;
  32. ans += int((bs[a0] & (bs[b0] >> bshift) & (bs[c0] >> cshift)).count());
  33. }
  34. }
  35. }
  36. }
  37.  
  38. char tmp[MAXN][MAXN];
  39.  
  40. void rot90() {
  41. for (int i = 0; i < N; i++) {
  42. for (int j = 0; j < N; j++) {
  43. tmp[N-1-j][i] = G[i][j];
  44. }
  45. }
  46. for (int i = 0; i < N; i++) {
  47. for (int j = 0; j < N; j++) {
  48. G[i][j] = tmp[i][j];
  49. }
  50. }
  51. }
  52.  
  53. int main() {
  54. ios::sync_with_stdio(0), cin.tie(0);
  55.  
  56. cin >> N;
  57. for (int i = 0; i < N; i++) {
  58. //cin >> G[i];
  59. for (int j = 0; j < N; j++) G[i][j] = '*';
  60. }
  61.  
  62. for (int z = 0; z < 4; z++) {
  63. go();
  64. rot90();
  65. }
  66. cout << ans << '\n';
  67.  
  68. return 0;
  69. }
  70.  
Success #stdin #stdout 0s 4248KB
stdin
3
***
***
***
stdout
8