Submission #706750

#TimeUsernameProblemLanguageResultExecution timeMemory
706750esomerDango Maker (JOI18_dango_maker)C++17
0 / 100
1 ms324 KiB
#include<bits/stdc++.h> using namespace std; typedef long long int ll; const int MOD = 1e9 + 7; //~ void calc(int i, int j, vector<vector<char>>& table, vector<vector<vector<int>>>& v, vector<vector<bool>>& done){ //~ if(i < n - 2 && table[i + 1][j] == 'G' && table[i+2][j] == 'W' && done[i][j] == 0 && done[i+1][j] == 0 && done[i+2][j] == 0){ //~ }else if(j < m - 2 && table[i][j + 1] == 'G' && table[i][j + 2] == 'W' && done[i][j] == 0 && done[i][j+1] == 0 && done[i][j+2] == 0){ //~ int cnt = 0; //~ else{ //~ ans++; //~ done[i][j] = 1; //~ done[i][j+1] = 1; //~ done[i][j+2] = 1; //~ } //~ } //~ } void solve(){ int n, m; cin >> n >> m; vector<vector<char>> table(n, vector<char>(m)); for(int i = 0; i < n; i++){ for(int j = 0; j < m; j++) cin >> table[i][j]; } vector<vector<int>> v(n, vector<int>(m, 0)); for(int i = 0; i < n; i++){ for(int j = 0; j < n; j++){ if(table[i][j] != 'R') continue; if(i < n - 2){ if(table[i + 1][j] == 'G' && table[i+2][j] == 'W'){ v[i+1][j]++; v[i+2][j]++; } } if(j < m - 2){ if(table[i][j + 1] == 'G' && table[i][j + 2] == 'W'){ v[i][j + 1]++; v[i][j + 2]++; } } } } vector<vector<bool>> done(n, vector<bool>(m, 0)); int ans = 0; for(int i = 0; i < n; i++){ for(int j = 0; j < m; j++){ if(table[i][j] == 'R' && done[i][j] == 0){ if(j < m - 2 && table[i][j + 1] == 'G' && table[i][j + 2] == 'W' && done[i][j] == 0 && done[i][j+1] == 0 && done[i][j+2] == 0){ ans++; done[i][j] = 1; done[i][j+1] = 1; done[i][j+2] = 1; }else if(i < n - 2 && table[i + 1][j] == 'G' && table[i+2][j] == 'W' && done[i][j] == 0 && done[i+1][j] == 0 && done[i+2][j] == 0){ if(v[i+1][j] == 2 && v[i+2][j] == 2){ ans += 2; done[i+1][j-1] = 1; done[i+1][j] = 1; done[i+1][j+1] = 1; done[i+2][j-2] = 1; done[i+2][j-1] = 1; done[i+2][j] = 1; }else{ ans++; done[i][j] = 1; done[i+1][j] = 1; done[i+2][j] = 1; } } } } } cout << ans << endl; } signed main(){ ios_base::sync_with_stdio(0); cin.tie(0); //~ int tt; cin >> tt; int tt = 1; for(int t = 1; t <= tt; t++){ solve(); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...