Submission #1236416

#TimeUsernameProblemLanguageResultExecution timeMemory
1236416GeforgsDango Maker (JOI18_dango_maker)C++20
0 / 100
0 ms328 KiB
#include <iostream> #include <iomanip> #include <vector> #include <cmath> #include <algorithm> #include <set> #include <queue> #include <map> #include <unordered_map> #include <stack> #include <bitset> #include <string> #include <cstring> #include <iterator> #include <random> #define ll int #define ld long double #define inf (ll)(2*1e18) #define sort(a) sort(a.begin(), a.end()) #define reverse(a) reverse(a.begin(), a.end()) #define pb push_back #define endl "\n" using namespace std; bool DFS(ll id, vector<vector<ll>>& b, vector<ll>& go, vector<bool>& visited){ if(visited[id]) return false; visited[id] = true; for(auto el: b[id]){ if(go[el] == -1){ go[el] = id; return true; } if(DFS(go[el], b, go, visited)){ go[el] = id; return true; } } return false; } void solve(){ ll n, m, i, j, res=0, cnt=0, cnt1=0, dif; cin>>n>>m; vector<vector<char>> a(n, vector<char>(m)); vector<vector<ll>> c(n, vector<ll>(m, -1)); vector<vector<ll>> b; for(i=0;i<n;++i){ for(j=0;j<m;++j){ cin>>a[i][j]; } } for(i=0;i<n-2;++i){ for(j=0;j<m;++j){ if(a[i][j] == 'R' and a[i+1][j] == 'G' and a[i+2][j] == 'W'){ c[i][j] = cnt; c[i+1][j] = cnt; c[i+2][j] = cnt; ++cnt; ++cnt1; // b.pb(vector<ll>()); } } } vector<bool> matched(cnt, false); for(i=0;i<n;++i){ for(j=0;j<m-2;++j){ if(a[i][j] == 'R' and a[i][j+1] == 'G' and a[i][j+2] == 'W'){ ++cnt; // b.pb(vector<ll>()); if(c[i][j] != -1 and !matched[c[i][j]]){ matched[c[i][j]] = true; ++res; continue; } if(c[i][j+1] != -1 and !matched[c[i][j+1]]){ matched[c[i][j+1]] = true; ++res; continue; } if(c[i][j+2] != -1 and !matched[c[i][j+2]]){ matched[c[i][j+2]] = true; ++res; continue; } } } } // vector<ll> go(cnt, -1); // vector<bool> set(cnt1, false); // do{ // dif = 0; // vector<bool> visited(cnt1, false); // for(i=0;i<cnt1;++i){ // if(set[i]) continue; // if(DFS(i, b, go, visited)){ // set[i] = true; // ++dif; // } // } // }while(dif); // for(i=cnt1;i<cnt;++i){ // if(go[i] != -1) ++res; // } cout<<cnt - res<<endl; } int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); srand(time(nullptr)); ll t=1; // cin>>t; for(;t>0;--t){ solve(); } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...