This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <iostream>
#include <unordered_map>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <locale>
#include <bitset>
#include <climits>
typedef long long ll;
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
ll n, m;
cin >> n >> m;
vector<vector<bool>> vis(n, vector<bool>(m, false));
vector<vector<char>> board(n, vector<char>(m, 'A'));
for(int x = 0; x < n; x++){
for(int y = 0; y < m; y++) {
cin >> board[x][y];
}
}
ll il = 0;
for(int x = 0; x < n; x++){
for(int y = 0; y < m; y++) {
if(!vis[x][y]) {
if(board[x][y] == 'G') {
if(x > 0 && x < n - 1 && !vis[x - 1][y] && !vis[x + 1][y]) {
if(board[x - 1][y] == 'R' && board[x + 1][y] == 'W') {
vis[x][y] = true;
vis[x - 1][y] = true;
vis[x + 1][y] = true;
il++;
}
} else
if(y > 0 && y < m - 1 && !vis[x][y - 1] && !vis[x][y + 1]) {
if(board[x][y - 1] == 'R' && board[x][y + 1] == 'W') {
vis[x][y] = true;
vis[x][y - 1] = true;
vis[x][y + 1] = true;
il++;
}
}
}
}
}
}
cout << il << '\n';
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |