Advertisement
Guest User

Untitled

a guest
Dec 16th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.43 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define int long long
  4.  
  5. #define REP(i,n) for(int i = 0; i < n; i++)
  6. #define REPP(i, a, n) for(int i = a; i < n; i++)
  7. #define RI(n) for(int i = 0; i < n; i++)
  8. #define IN(n) int n; cin>>n;
  9. #define OUT(x) cout<<x<<'\n';
  10. #define DBG(x) cout<<#x<<" = "<<x<<'\n';
  11. #define VI vector<int>
  12. #define ENDL cout<<'\n';
  13. #define STOP system("pause");
  14. #define pb push_back
  15. #define mp make_pair
  16. int inf = 1e18 * 2;
  17.  
  18. main(){
  19. //ios_base::sync_with_stdio(false);
  20. //cin.tie(0);
  21. //cout.tie(0);
  22.  
  23. IN(n)
  24. IN(m)
  25. n+=2;
  26. m+=2;
  27. vector<vector<bool>>home(n, vector<bool>(m, false));
  28. vector<vector<bool>>water(n, vector<bool>(m, false));
  29. REP(i, n - 2)
  30. REP(j, m - 2){
  31. char c;
  32. cin>>c;
  33. if(c!='.')home[i + 1][j + 1] = true;
  34. }
  35. REP(i, n - 2)
  36. REP(j, m - 2){
  37. char c;
  38. cin>>c;
  39. if(c!='.')water[i + 1][j + 1] = true;
  40. }
  41. //DBG("11")
  42. int ans = 0;
  43. for(int i = -n; i <= n; i++){
  44. //DBG(i)
  45. for(int j = -m; j <= m; j++){
  46.  
  47. bool b = false;
  48. int curr = 0;
  49. REP(x, n){
  50. //DBG(x)
  51. REP(y, m){
  52. int x1 = x + i;
  53. int y1 = y + j;
  54. if(x1 < 0 || y1 < 0)continue;
  55. if(x1 >= n || y1 >= m)continue;
  56. if(water[x][y] && home[x1][y1]){
  57. b = true;
  58. break;
  59. }
  60. if(home[x1][y1]){
  61. for(int x_ = max((int)0, x - 1); x_ <= min(x + 1, n - 1); x_++){
  62. for(int y_ = max((int)0, y - 1); y_ <= min(y + 1, m - 1); y_++){
  63. //DBG(x_)
  64. //DBG(y_)
  65. if(water[x_][y_] && (x_ - x == 0 || y_ - y == 0)){
  66. //DBG("124")
  67. curr++;
  68. }
  69. //DBG("11111")
  70. }
  71. }
  72. }
  73. //DBG("!!!!")
  74. }
  75. // DBG("abcdt")
  76. //DBG(b)
  77. if(b)break;
  78. }
  79. if(!b){
  80. ans = max(ans, curr);
  81. }
  82. }
  83. }
  84. OUT(ans)
  85.  
  86.  
  87. return 0;
  88. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement