#include <bits/stdc++.h>
using namespace std;
vector<string> plansza;
int tab[3001][3001];
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n, m;
cin >> n >> m;
for(int i = 0; i < n; i++){
string s;
cin >> s;
plansza.push_back(s);
}
int wyn = 0;
for(int i = 0; i < n; i++){
for(int j = 0; j < m; j++){
if(plansza[i][j] == 'R'){
if(i >= 2){
if(plansza[i - 1][j] == 'G' && plansza[i - 2][j] == 'W'){
tab[i][j]++;
tab[i - 1][j] = j + i * 3001;
tab[i - 2][j] = j + i * 3001;
}
}
if(i < n - 2){
if(plansza[i + 1][j] == 'G' && plansza[i + 2][j] == 'W'){
tab[i][j]++;
tab[i + 1][j] = j + i * 3001;
tab[i + 2][j] = j + i * 3001;
}
}
if(j >= 2){
if(plansza[i][j - 1] == 'G' && plansza[i][j - 2] == 'W'){
tab[i][j]++;
tab[i][j - 1] = j + i * 3001;
tab[i][j - 2] = j + i * 3001;
}
}
if(j < m - 2){
if(plansza[i][j + 1] == 'G' && plansza[i][j + 2] == 'W'){
tab[i][j]++;
tab[i][j + 1] = j + i * 3001;
tab[i][j + 2] = j + i * 3001;
}
}
wyn += min(1, tab[i][j]);
}
}
}
cout << wyn;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |