Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #include <vector>
- #include <set>
- #include <algorithm>
- #include <cmath>
- #define pb push_back
- #define mp make_pair
- typedef unsigned long long ull;
- typedef long long ll;
- using namespace std;
- int main()
- {
- ios::sync_with_stdio(false);
- cin.tie(0);
- int q,cnt = 0;
- cin >> q;
- //q = 500;
- while(cnt < q)
- {
- char mpp[105][105];
- bool mp[105][105];
- for(int i = 0; i < 105; i++)
- for(int j = 0; j < 105; j++)
- mp[i][j] = 0;
- int n,m,main_ans = 0;
- cin >> n >> m;
- for(int i = 1; i <= n; i++)
- for(int j = 1; j <= m; j++)
- cin >> mpp[i][j];
- for(int i = 1; i < m; i++)
- {
- for(int j = 1; j < n; j++)
- {
- if(mpp[j][i] != 'R' && mpp[j][i] != 'B') mp[j][i] = true;
- else break;
- }
- }
- while(1)
- {
- int ans = 0;
- for(int i = 1; i < n; i++)
- {
- for(int j = 1; j < m; j++)
- {
- if(mp[i][j]) ans++;
- else
- {
- int flag = 0;
- if(mpp[i][j] != 'R' && mpp[i][j] != 'B' && mp[i-1][j] == true)
- flag = 1;
- else if(mpp[i][j] != 'D' && mpp[i][j] != 'B' && mp[i][j-1] == true)
- flag = 1;
- else if(mpp[i][j+1] != 'D' && mpp[i][j+1] != 'B' && mp[i][j+1] == true)
- flag = 1;
- else if(mpp[i+1][j] != 'R' && mpp[i+1][j] != 'B' && mp[i+1][j] == true)
- flag = 1;
- if(flag)
- {
- mp[i][j] = true;
- ans++;
- }
- }
- }
- }
- if(ans > main_ans) {main_ans = ans;}
- else break;
- }
- cout << "Case " << cnt+1 << ": " << main_ans << endl;
- cnt++;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement