이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<iostream>
using namespace std;
const int MAXN = 3005;
int n, m, a, b, sol;
char l[MAXN] [MAXN];
int bio[MAXN] [MAXN];
bool ok (int x, int y, int d) {
if (d == 0) {
return l[x] [y] == 'R' && l[x+1] [y] == 'G' && l[x+2] [y] == 'W';
} else {
return l[x] [y] == 'R' && l[x] [y+1] == 'G' && l[x] [y+2] == 'W';
}
}
void dfs (int x, int y) {
if (bio[x] [y]) return;
bio[x] [y] = 1;
int cnt = 0;
if (ok(x, y, 0)) a++;
if (ok(x, y, 1)) b++, cnt++;
if (cnt) {
if (x-1 >= 0) dfs(x-1, y+1);
if (x-2 >= 0) dfs(x-2, y+2);
}
}
int main () {
cin >> n >> m;
for (int i=0; i<n; i++) {
for (int j=0; j<m; j++) {
cin >> l[i] [j];
}
}
for (int i=n-1; i>=0; i--) {
for (int j=m-1; j>=0; j--) {
if (!bio[i] [j]) {
a = b = 0;
dfs(i, j);
sol += max(a, b);
}
}
}
cout << sol;
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... |