Submission #981668

#TimeUsernameProblemLanguageResultExecution timeMemory
981668pccLand of the Rainbow Gold (APIO17_rainbow)C++17
0 / 100
3102 ms41024 KiB
#include "rainbow.h" #include <bits/stdc++.h> using namespace std; #define pii pair<int,int> #define fs first #define sc second const int mxn = 2e5+10; pii dir[] = {{0,1},{1,0},{1,1}}; vector<pii> v; set<pii> st; void init(int R, int C, int sr, int sc, int M, char *S) { st.clear(); v.clear(); pii now = pii(sr,sc); v.push_back(now); for(int i = 0;i<M;i++){ if(S[i] == 'N')now.fs--; else if(S[i] == 'S')now.fs++; else if(S[i] == 'E')now.sc++; else if(S[i] == 'W')now.sc--; v.push_back(now); } sort(v.begin(),v.end()); v.resize(unique(v.begin(),v.end())-v.begin()); } int colour(int ar, int ac, int br, int bc) { st.clear(); vector<pii> vv; bool con = false; for(auto &i:v){ if(i.fs<ar||i.fs>br||i.sc<ac||i.sc>bc)continue; if(i.fs == ar||i.fs == br||i.sc == ac||i.sc == bc)con = true; vv.push_back(i); } if(vv.empty())con = true; for(int i = ar-1;i<=br+1;i++){ vv.push_back(pii(i,ac-1)); vv.push_back(pii(i,bc+1)); } for(int i = ac-1;i<=bc+1;i++){ vv.push_back(pii(ar-1,i)); vv.push_back(pii(br+1,i)); } swap(v,vv); sort(v.begin(),v.end()); v.resize(unique(v.begin(),v.end())-v.begin()); //for(auto &i:v)cerr<<i.fs<<','<<i.sc<<' ';cerr<<endl; for(auto &i:v)st.insert(i); int ecnt = 0,vcnt = 0; vcnt = v.size(); for(auto &i:v){ if(st.find(pii(i.fs+1,i.sc)) != st.end())ecnt++; if(st.find(pii(i.fs,i.sc+1)) != st.end())ecnt++; } assert(st.size() == v.size()); int ans = 2+ecnt-vcnt; //cerr<<vcnt<<' '<<ecnt<<endl; for(auto &i:v){ int c = 0; for(auto &d:dir){ if(st.find(pii(i.fs+d.fs,i.sc+d.sc)) != st.end())c++; } if(c == 3)ans--; } swap(v,vv); return ans-con; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...