#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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
488 KB |
Output is correct |
3 |
Correct |
2 ms |
488 KB |
Output is correct |
4 |
Correct |
2 ms |
492 KB |
Output is correct |
5 |
Correct |
2 ms |
624 KB |
Output is correct |
6 |
Correct |
2 ms |
680 KB |
Output is correct |
7 |
Correct |
2 ms |
680 KB |
Output is correct |
8 |
Correct |
2 ms |
680 KB |
Output is correct |
9 |
Correct |
2 ms |
724 KB |
Output is correct |
10 |
Correct |
2 ms |
724 KB |
Output is correct |
11 |
Correct |
2 ms |
784 KB |
Output is correct |
12 |
Correct |
2 ms |
784 KB |
Output is correct |
13 |
Correct |
2 ms |
792 KB |
Output is correct |
14 |
Correct |
2 ms |
792 KB |
Output is correct |
15 |
Correct |
2 ms |
792 KB |
Output is correct |
16 |
Correct |
2 ms |
792 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
488 KB |
Output is correct |
3 |
Correct |
2 ms |
488 KB |
Output is correct |
4 |
Correct |
2 ms |
492 KB |
Output is correct |
5 |
Correct |
2 ms |
624 KB |
Output is correct |
6 |
Correct |
2 ms |
680 KB |
Output is correct |
7 |
Correct |
2 ms |
680 KB |
Output is correct |
8 |
Correct |
2 ms |
680 KB |
Output is correct |
9 |
Correct |
2 ms |
724 KB |
Output is correct |
10 |
Correct |
2 ms |
724 KB |
Output is correct |
11 |
Correct |
2 ms |
784 KB |
Output is correct |
12 |
Correct |
2 ms |
784 KB |
Output is correct |
13 |
Correct |
2 ms |
792 KB |
Output is correct |
14 |
Correct |
2 ms |
792 KB |
Output is correct |
15 |
Correct |
2 ms |
792 KB |
Output is correct |
16 |
Correct |
2 ms |
792 KB |
Output is correct |
17 |
Correct |
2 ms |
812 KB |
Output is correct |
18 |
Correct |
2 ms |
812 KB |
Output is correct |
19 |
Correct |
2 ms |
860 KB |
Output is correct |
20 |
Incorrect |
2 ms |
1048 KB |
Output isn't correct |
21 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
488 KB |
Output is correct |
3 |
Correct |
2 ms |
488 KB |
Output is correct |
4 |
Correct |
2 ms |
492 KB |
Output is correct |
5 |
Correct |
2 ms |
624 KB |
Output is correct |
6 |
Correct |
2 ms |
680 KB |
Output is correct |
7 |
Correct |
2 ms |
680 KB |
Output is correct |
8 |
Correct |
2 ms |
680 KB |
Output is correct |
9 |
Correct |
2 ms |
724 KB |
Output is correct |
10 |
Correct |
2 ms |
724 KB |
Output is correct |
11 |
Correct |
2 ms |
784 KB |
Output is correct |
12 |
Correct |
2 ms |
784 KB |
Output is correct |
13 |
Correct |
2 ms |
792 KB |
Output is correct |
14 |
Correct |
2 ms |
792 KB |
Output is correct |
15 |
Correct |
2 ms |
792 KB |
Output is correct |
16 |
Correct |
2 ms |
792 KB |
Output is correct |
17 |
Correct |
2 ms |
812 KB |
Output is correct |
18 |
Correct |
2 ms |
812 KB |
Output is correct |
19 |
Correct |
2 ms |
860 KB |
Output is correct |
20 |
Incorrect |
2 ms |
1048 KB |
Output isn't correct |
21 |
Halted |
0 ms |
0 KB |
- |