이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
void solve() {
int n, m;
cin >> n >> m;
vector<string> grid(n);
for(int i=0;i<n;i++) cin >> grid[i];
int ans = 0;
for(int i=0;i<n;i++) {
for(int j=0;j<m;j++) {
if(i+5<n && grid[i][j]=='R' && grid[i+1][j] == 'R' && grid[i+2][j] == 'G' && grid[i+3][j]=='W' && grid[i+4][j] == 'G' && grid[i+5][j] == 'W'){
// cout<<99<<endl;
grid[i][j] = grid[i+1][j] = grid[i+2][j] = grid[i+3][j] = grid[i+4][j] = grid[i+5][j] = 'P';
ans+=2;
}
else if(j+5<m && grid[i][j]=='R' && grid[i][j+1] == 'R' && grid[i][j+2] == 'G'&& grid[i][j+3]=='W' && grid[i][j+4] == 'G' && grid[i][j+5] == 'W'){
// cout<<99<<endl;
grid[i][j] = grid[i][j+1] = grid[i][j+2] = grid[i][j+3] = grid[i][j+4] = grid[i][j+5] = 'P';
ans+=2;
}
else if(i + 2 < n && grid[i][j] == 'R' && grid[i+1][j] == 'G' && grid[i+2][j] == 'W') {
grid[i][j] = 'P';
grid[i+1][j] = 'P';
grid[i+2][j] = 'P';
ans++;
}
else if(j + 2 < m && grid[i][j] == 'R' && grid[i][j+1] == 'G' && grid[i][j+2] == 'W') {
grid[i][j] = 'P';
grid[i][j+1] = 'P';
grid[i][j+2] = 'P';
ans++;
}
}
}
cout << ans;
}
int main() {
solve();
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... |