이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
int n,m;
string s[3005];
bool choosed[3004][3005];
bool up(int x,int y){
if (x < 3) return 0;
if (s[x-2][y] == 'R' && s[x-1][y] == 'G' && s[x][y] == 'W' && !choosed[x-2][y] && !choosed[x-1][y] && !choosed[x][y]){
choosed[x-2][y] = choosed[x-1][y] = choosed[x][y] = 1;
return 1;
}
return 0;
}
bool right(int x,int y){
if (y >= m-1) return 0;
if (s[x][y] == 'R' && s[x][y+1] == 'G' && s[x][y+2] == 'W' && !choosed[x][y] && !choosed[x][y+1] && !choosed[x][y+2]){
choosed[x][y] = choosed[x][y+1] = choosed[x][y+2] = 1;
return 1;
}
return 0;
}
int main(){
iostream::sync_with_stdio(0);
cin >> n >> m;
for(int i=1;i<=n;i++) cin >> s[i], s[i] = '0' + s[i];
int ans = 0;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++)
ans += up(i,j);
for(int j=1;j<=m;j++)
ans += right(i,j);
}
cout << ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |