/*
+----------------------------------------------------------------+
| In the name of Allah, the most Gracious and the most Merciful. |
+----------------------------------------------------------------+
When you are down in your misery
And there is nowhere to run
Remember just remember
You can always run to The One.
When things are down
And you are out of your mind
Remember just remember
Allah is The Kind.
*/
# include <bits/stdc++.h>
# define FILE
using namespace std;
int n, m, ans;
string s[3333];
int main(){
# ifdef FILEs
freopen( "input.txt", "r", stdin );
freopen( "output.txt", "w", stdout );
# endif
ios_base::sync_with_stdio(false);
cin >> n >> m;
for( int i = 0; i < n; i ++ ){
cin >> s[i];
}
for( int i = 0; i < n; i ++ ){
for( int j = 0; j < m; j ++ ){
if( s[i][j] != 'G' )continue;
int cnt = 0;
if( i && i < n-1 && s[i-1][j] == 'R' && s[i+1][j] == 'W' ){
cnt ++;
}
if( j && j < m-1 && s[i][j-1] == 'R' && s[i][j+1] == 'W' ){
cnt ++;
}
if( cnt == 1 ){
ans ++;
if( i && i < n-1 && s[i-1][j] == 'R' && s[i+1][j] == 'W' ){
s[i][j] = '#';
s[i-1][j] = '&';
s[i+1][j] = '@';
}
if( j && j < m-1 && s[i][j-1] == 'R' && s[i][j+1] == 'W' ){
s[i][j] = '#';
s[i][j-1] = '&';
s[i][j+1] = '@';
}
}
}
}
for( int i = 0; i < n; i ++ ){
for( int j = 0; j < m; j ++ ){
if( i && i < n-1 && s[i-1][j] == 'R' && s[i+1][j] == 'W' ){
s[i][j] = '#';
s[i-1][j] = '&';
s[i+1][j] = '@';
ans++;
}
else if( j && j < m-1 && s[i][j-1] == 'R' && s[i][j+1] == 'W' ){
s[i][j] = '#';
s[i][j-1] = '&';
s[i][j+1] = '@';
ans++;
}
}
}
cout << ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
512 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
512 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
512 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |