Submission #235350

#TimeUsernameProblemLanguageResultExecution timeMemory
235350Nodir_BobievDango Maker (JOI18_dango_maker)C++17
13 / 100
5 ms512 KiB
/* +----------------------------------------------------------------+ | 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( s[i][j] == 'G' && 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( s[i][j] == 'G' && 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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...