Advertisement
Guest User

Untitled

a guest
Nov 18th, 2019
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.14 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. #include <vector>
  3. #include <set>
  4. #include <algorithm>
  5. #include <cmath>
  6. #define pb push_back
  7. #define mp make_pair
  8. typedef unsigned long long ull;
  9. typedef long long ll;
  10.  
  11. using namespace std;
  12.  
  13. int main()
  14. {
  15.     ios::sync_with_stdio(false);
  16.     cin.tie(0);
  17.     int q,cnt = 0;
  18.     cin >> q;
  19.     //q = 500;
  20.     while(cnt < q)
  21.     {
  22.         char mpp[105][105];
  23.         bool mp[105][105];
  24.         for(int i = 0; i < 105; i++)
  25.             for(int j = 0; j < 105; j++)
  26.                 mp[i][j] = 0;
  27.         int n,m,main_ans = 0;
  28.         cin >> n >> m;
  29.         for(int i = 1; i <= n; i++)
  30.             for(int j = 1; j <= m; j++)
  31.                 cin >> mpp[i][j];
  32.         for(int i = 1; i < m; i++)
  33.         {
  34.             for(int j = 1; j < n; j++)
  35.             {
  36.                 if(mpp[j][i] != 'R' && mpp[j][i] != 'B') mp[j][i] = true;
  37.                 else break;
  38.             }
  39.         }
  40.         while(1)
  41.         {
  42.             int ans = 0;
  43.             for(int i = 1; i < n; i++)
  44.             {
  45.                 for(int j = 1; j < m; j++)
  46.                 {
  47.                     if(mp[i][j]) ans++;
  48.                     else
  49.                     {
  50.                         int flag = 0;
  51.                         if(mpp[i][j] != 'R' && mpp[i][j] != 'B' && mp[i-1][j] == true)
  52.                             flag = 1;
  53.                         else if(mpp[i][j] != 'D' && mpp[i][j] != 'B' && mp[i][j-1] == true)
  54.                             flag = 1;
  55.                         else if(mpp[i][j+1] != 'D' && mpp[i][j+1] != 'B' && mp[i][j+1] == true)
  56.                             flag = 1;
  57.                         else if(mpp[i+1][j] != 'R' && mpp[i+1][j] != 'B' && mp[i+1][j] == true)
  58.                             flag = 1;
  59.                         if(flag)
  60.                         {
  61.                             mp[i][j] = true;
  62.                             ans++;
  63.                         }
  64.                     }
  65.                 }
  66.             }
  67.             if(ans > main_ans) {main_ans = ans;}
  68.             else break;
  69.         }
  70.         cout << "Case " << cnt+1 << ": " << main_ans << endl;
  71.         cnt++;
  72.     }
  73.     return 0;
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement