Submission #762531

#TimeUsernameProblemLanguageResultExecution timeMemory
762531stefanneaguDango Maker (JOI18_dango_maker)C++17
13 / 100
1 ms340 KiB
#include <iostream> #include <vector> #include <set> #include <algorithm> using namespace std; const int nmax = 3007; char mat[nmax][nmax]; int jos[nmax][nmax], dr[nmax][nmax], f[nmax][nmax]; int32_t main() { int n, m, ans = 0; cin >> n >> m; for(int i = 1; i <= n; i ++) { for(int j = 1; j <= m; j ++) { cin >> mat[i][j]; } } for(int i = 1; i <= n - 2; i ++) { for(int j = 1; j <= m; j ++) { if(mat[i][j] == 'R' && mat[i + 1][j] == 'G' && mat[i + 2][j] == 'W') { jos[i][j] = 1; jos[i + 1][j] = 2; jos[i + 2][j] = 3; } } } for(int i = 1; i <= n; i ++) { for(int j = 1; j <= m - 2; j ++) { if(mat[i][j] == 'R' && mat[i][j + 1] == 'G' && mat[i][j + 2] == 'W') { dr[i][j] = 1; dr[i][j + 1] = 2; dr[i][j + 2] = 3; } } } for(int i = 1; i <= n; i ++) { for(int j = 1; j <= m; j ++) { if(!f[i][j]) { int cnt = 0, ult = 0; if(jos[i][j] == 1 && f[i + 1][j] == 0 && f[i + 2][j] == 0) { // numaram cate blocam if(dr[i][j] == 1) cnt ++; if(dr[i + 1][j] == 1) cnt ++; if(dr[i + 2][j] == 1) cnt ++; if(dr[i][j - 1] == 1) cnt ++; if(dr[i + 1][j - 1] == 1) cnt ++; if(dr[i + 2][j - 1] == 1) cnt ++; if(j > 1) { if(dr[i][j - 2] == 1) cnt ++; if(dr[i + 1][j - 2] == 1) cnt ++; if(dr[i + 2][j - 2] == 1) cnt ++; } } else { cnt = 1e9; } ult = cnt; cnt = 0; if(dr[i][j] == 1 && f[i][j + 1] == 0 && f[i][j + 2] == 0) { if(jos[i][j] == 1) cnt ++; if(jos[i][j + 1] == 1) cnt ++; if(jos[i][j + 2] == 1) cnt ++; if(jos[i - 1][j] == 1) cnt ++; if(jos[i - 1][j + 1] == 1) cnt ++; if(jos[i - 1][j + 2] == 1) cnt ++; if(i > 1) { if(jos[i - 2][j] == 1) cnt ++; if(jos[i - 2][j + 1] == 1) cnt ++; if(jos[i - 2][j + 2] == 1) cnt ++; } } else { cnt = 1e9; } if(cnt < ult && cnt != 1e9) { ans ++; f[i][j] = 1; f[i][j + 1] = 1; f[i][j + 2] = 1; } else if(ult != 1e9) { ans ++; f[i][j] = 1; f[i + 1][j] = 1; f[i + 2][j] = 1; } } } } cout << ans; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...