제출 #206537

#제출 시각아이디문제언어결과실행 시간메모리
206537stefdascaDango Maker (JOI18_dango_maker)C++14
13 / 100
6 ms380 KiB
#include<bits/stdc++.h> using namespace std; int n, m; char a[3005][3005]; bool viz[3005][3005]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> n >> m; for(int i = 1; i <= n; ++i) cin >> (a[i] + 1); int ans = 0; int st = 1; int dr = n; int L = 1; int R = m; while(1) { bool ok = 0; if(st <= dr) { ok = 1; for(int i = 1; i <= m; ++i) { if(!viz[st][i] && !viz[st][i+1] && !viz[st][i+2]) { if(a[st][i] == 'R' && a[st][i+1] == 'G' && a[st][i+2] == 'W') { viz[st][i] = viz[st][i+1] = viz[st][i+2] = 1; // cout << st << " " << i << '\n'; ++ans; } } } for(int i = 1; i <= m; ++i) { if(!viz[dr][i] && !viz[dr][i+1] && !viz[dr][i+2]) { if(a[dr][i] == 'R' && a[dr][i+1] == 'G' && a[dr][i+2] == 'W') { viz[dr][i] = viz[dr][i+1] = viz[dr][i+2] = 1; // cout << dr << " " << i << '\n'; ++ans; } } } ++st; --dr; } if(L <= R) { ok = 1; for(int i = 1; i <= n; ++i) { if(!viz[i][L] && !viz[i+1][L] && !viz[i+2][L]) { if(a[i][L] == 'R' && a[i+1][L] == 'G' && a[i+2][L] == 'W') { // cout << i << " " << L << '\n'; viz[i][L] = viz[i+1][L] = viz[i+2][L] = 1; ++ans; } } } for(int i = 1; i <= n; ++i) { if(!viz[i][R] && !viz[i+1][R] && !viz[i+2][R]) { if(a[i][R] == 'R' && a[i+1][R] == 'G' && a[i+2][R] == 'W') { // cout << i << " " << R << '\n'; viz[i][R] = viz[i+1][R] = viz[i+2][R] = 1; ++ans; } } } ++L; --R; } if(!ok) break; } for(int i = 1; i <= n; ++i) for(int j = 1; j <= m; ++j) { if(!viz[i][j] && !viz[i][j+1] && !viz[i][j+2]) { if(a[i][j] == 'R' && a[i][j+1] == 'G' && a[i][j+2] == 'W') { // cout << i << " " << j << '\n'; viz[i][j] = viz[i][j+1] = viz[i][j+2] = 1; ++ans; } } if(!viz[i][j] && !viz[i+1][j] && !viz[i+2][j]) { if(a[i][j] == 'R' && a[i+1][j] == 'G' && a[i+2][j] == 'W') { // cout << i << " " << j << '\n'; viz[i][j] = viz[i+1][j] = viz[i+2][j] = 1; ++ans; } } } cout << ans; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...