#include <iostream>
using namespace std;
const int MAXN = 3001;
int n, m;
int tablica[MAXN][MAXN];
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n >> m;
char p1;
for (int i = 0; n > i; i++) {
for (int j = 0; m > j; j++) {
cin >> p1;
if (p1 == 'R') {
tablica[i][j] = 1;
} else if (p1 == 'G') {
tablica[i][j] = 2;
} else {
tablica[i][j] = 3;
}
}
}
int wynik = 0;
for (int i = 0; n > i; i++) {
for (int j = 0; m > j; j++) {
//czy poziomo
if (((j + 2) < m) && tablica[i][j] == 1 && tablica[i][j + 1] == 2 && tablica[i][j + 2] == 3) {
if ((i > 0) && ((i + 1) < n) && tablica[i - 1][j + 1] == 1 && tablica[i][j + 1] == 2 && tablica[i + 1][j + 1] == 3) {
//cout << "problemy poziom " << i << " " << j << "\n";
wynik++;
tablica[i - 1][j + 1] = 0;
tablica[i][j + 1] = 0;
tablica[i][j + 2] = 0;
} else {
//cout << "ess poziomo " << i << " " << j << "\n";
wynik++;
tablica[i][j] = 0;
tablica[i][j + 1] = 0;
tablica[i][j + 2] = 0;
}
}
if ((i > 0) && (i + 1) < n && tablica[i - 1][j] == 1 && tablica[i][j] == 2 && tablica[i + 1][j]) {
//cout << "ess pionowo " << i << " " << j << "\n";
wynik++;
tablica[i - 1][j] = 0;
tablica[i][j] = 0;
tablica[i + 1][j] = 0;
}
//czy pionowo
}
}
cout << wynik;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
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 |
- |