fork download
  1. /// b.cpp
  2.  
  3. # include <stdio.h>
  4. # include <bits/stdc++.h>
  5. using namespace std;
  6. const pair < int , int > DD[] = {{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};
  7. # define fi cin
  8. # define fo cout
  9. # define mp make_pair
  10. template < class T > T smin(T &a,T b) {if (a > b) a = b;return a;}
  11. template < class T > T smax(T &a,T b) {if (a < b) a = b;return a;}
  12. int main(void)
  13. {
  14. #ifdef CF
  15. freopen("input","r",stdin);
  16. #endif // CF
  17. srand(time(0));
  18. fo << fixed << setprecision(7);
  19. cerr << fixed << setprecision(7);
  20. static int was[1 << 10][1 << 10];
  21. static char s[1 << 10][1 << 10];
  22. int n,m;
  23. fi>>n>>m;
  24. for (int i = 1;i <= n;++i)
  25. fi>>(s[i] + 1);
  26. for (int i = 1;i <= n;++i)
  27. for (int j = 1;j <= m;++j)
  28. was[i][j] += was[i - 1][j] + was[i][j - 1] - was[i - 1][j - 1] + (s[i][j] == '*');
  29. auto get = [&](int x1,int y1,int x2,int y2)
  30. {
  31. int ans = was[x2][y2] + was[x1 - 1][y1 - 1] - was[x1 - 1][y2] - was[x2][y1 - 1];
  32. return ans;
  33. };
  34. pii S,T;
  35. for (int i = 1;i <= n;++i)
  36. for (int j = 1;j <= m;++j)
  37. {
  38. if (s[i][j] == 'S')
  39. S = mp(i,j);
  40. if (s[i][j] == 'T')
  41. T = mp(i,j);
  42. }
  43. const int dx[] = {0,1,-1,0};
  44. const int dy[] = {1,0,0,-1};
  45. for (int a = 0;a < 4;++a)
  46. for (int b = 0;b < 4;++b)
  47. for (int i = 0;i <= 1000;++i)
  48. for (int j = 0;j <= 1000;++j)
  49. {
  50. int xx = S.x + i * dx[a];
  51. int yy = S.y + i * dy[a];
  52. if (!(1 <= xx && xx <= n) || !(1 <= yy && yy <= m) || get(min(S.x,xx),min(S.y,yy),max(S.x,xx),max(S.y,yy)))
  53. continue;
  54. int cx = xx;
  55. int cy = yy;
  56. xx += j * dx[b];
  57. yy += j * dy[b];
  58. if (!(1 <= xx && xx <= n) || !(1 <= yy && yy <= m) || get(min(cx,xx),min(cy,yy),max(cx,xx),max(cy,yy)))
  59. continue;
  60. if (!(xx == T.x || T.y == yy) || get(min(xx,T.x),min(yy,T.y),max(xx,T.x),max(yy,T.y)))
  61. continue;
  62. return yes * 0;
  63. }
  64. no;
  65. cerr << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
  66. return 0;
  67. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:34:5: error: ‘pii’ was not declared in this scope
     pii S,T;
     ^~~
prog.cpp:39:17: error: ‘S’ was not declared in this scope
                 S = mp(i,j);
                 ^
prog.cpp:41:17: error: ‘T’ was not declared in this scope
                 T = mp(i,j);
                 ^
prog.cpp:50:30: error: ‘S’ was not declared in this scope
                     int xx = S.x + i * dx[a];
                              ^
prog.cpp:60:33: error: ‘T’ was not declared in this scope
                     if (!(xx == T.x || T.y == yy) || get(min(xx,T.x),min(yy,T.y),max(xx,T.x),max(yy,T.y)))
                                 ^
prog.cpp:62:28: error: ‘yes’ was not declared in this scope
                     return yes * 0;
                            ^~~
prog.cpp:64:5: error: ‘no’ was not declared in this scope
     no;
     ^~
stdout
Standard output is empty