Submission #891929

#TimeUsernameProblemLanguageResultExecution timeMemory
891929goodspeed0208Dango Maker (JOI18_dango_maker)C++14
13 / 100
1 ms352 KiB
#include<iostream> #include<vector> #include<algorithm> #include<set> #include<map> #include<queue> #include<utility> #define int long long #define INF 1000000000000000000 #define pii pair<long long, long long> using namespace std; int n, m; char v[3005][3005]; /* r c 0 : - - 1 : + - 2 : - + 3 : + + */ int ans = 0; int cmp(int i, int j) { if (i < 0 || i >= n || j < 0 || j >= m || v[i][j] != 'G') return -1; int row = 0, column = 0; if (i > 0 && i < n-1 && v[i-1][j] == 'R' && v[i+1][j] == 'W') column++; if (j > 0 && j < m-1 && v[i][j-1] == 'R' && v[i][j+1] == 'W') row++; if (column && row) { v[i][j] = v[i-1][j] = v[i+1][j] = v[i][j-1] = v[i][j+1] = '/'; ans++; return 3; } if (row) { v[i][j] = v[i][j-1] = v[i][j+1] = '/'; ans++; return 1; } if (column) { v[i][j] = v[i-1][j] = v[i+1][j] = '/'; ans++; return 2; } return 0; } signed main() { cin >> n >> m; for (int i = 0 ; i < n ; i++) { for (int j = 0 ; j < m ; j++) cin >> v[i][j]; } for (int i = 0 ; i < n ; i++) { for (int j = 0 ; j < m ; j++) { while (cmp(i, j) == 3) { //cout << i << " " << j << "\n"; i++, j--; } } } cout << ans << "\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...