# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
238257 | 2020-06-10T14:02:11 Z | m3r8 | Flood (IOI07_flood) | C++14 | 215 ms | 11912 KB |
#include <stdio.h> #include <set> #include <utility> #include <vector> #include <queue> #define N 100100 #define W N*2 #define ii std::pair<int,int> ii pp[N]; std::vector<ii> adj[N]; int zone[N<<2]; int used[N]; int tbl[4] = {2,1,0,3}; std::queue<int> que; int erg[W]; std::vector<int> akt; std::vector<int> ttmp; void cc(int v){ que.push(v); used[v] = 1; while(que.size()){ int akk = que.front();que.pop(); akt.push_back(akk); for(auto i: adj[akk]){ if(!used[i.first]){ used[i.first] = 1; que.push(i.first); }; }; }; }; void ccp(int sp){ int ip = sp << 2; int cnt = 1; int p; int on; int a,b; int tprev; int tnxt; int prev; int nxt; int idx; que.push(ip); zone[ip] = cnt; while(que.size()){ while(que.size()){ int akk = que.front();que.pop(); p = akk >> 2; on = akk % 4; //printf("on: %d %d %d %d\n",p,on,pp[p].first,pp[p].second); tprev = (on+3)%4; tnxt = (on+1)%4; prev = tprev + (p << 2); nxt = tnxt + (p << 2); for(auto i: adj[p]){ idx = i.first; a = pp[idx].first - pp[p].first == 0; if(a)b = pp[idx].second - pp[p].second < 0; else b = pp[idx].first - pp[p].first < 0; a = b * 2 + a; if(tbl[on] == a){ nxt = tprev + (idx << 2); }; if((tbl[on] + 1)%4 == a){ prev = tnxt + (idx << 2); }; }; if(!zone[prev]){ zone[prev] = cnt; que.push(prev); }; if(!zone[nxt]){ zone[nxt] = cnt; que.push(nxt); }; for(int i = 0;i<4;i++){ ttmp.push_back(i + (p << 2)); }; }; //printf("---------------\n"); cnt++; for(int i: ttmp){ if(!zone[i]){ que.push(i); zone[i] = cnt; }; }; ttmp.clear(); }; }; int main(void){ int n; scanf("%d",&n); for(int i = 0;i<n;i++){ scanf("%d %d",&(pp[i].first),&(pp[i].second)); }; int w; scanf("%d",&w); int a,b; for(int i = 0;i<w;i++){ scanf("%d %d",&a,&b); a--; b--; adj[a].push_back({b,i}); adj[b].push_back({a,i}); }; int mnid; ii mn; for(int i = 0;i<n;i++){ if(!used[i]){ akt.clear(); cc(i); if(akt.size() > 1){ mn = pp[akt[0]]; mnid = akt[0]; for(int j : akt){ if(pp[j] < mn){ mn = pp[j]; mnid = j; }; }; ccp(mnid); }; }; }; ii aa,bb; for(int i = 0;i<n;i++){ for(auto j: adj[i]){ aa = pp[i]; bb = pp[j.first]; if(aa.first == bb.first){ if(aa.second < bb.second){ if(zone[1 + (i << 2)] == zone[2 + (i << 2)]){ erg[j.second] = 1; }; }else{ if(zone[1 + (j.first << 2)] == zone[2 + (j.first << 2)]){ erg[j.second] = 1; }; }; }else{ if(aa.first < bb.first){ if(zone[2 + (i << 2)] == zone[3 + (i << 2)]){ erg[j.second] = 1; }; }else{ if(zone[2 + (j.first << 2)] == zone[3 + (j.first << 2)]){ erg[j.second] = 1; }; }; }; }; }; int cccc = 0; for(int i = 0;i<w;i++){ if(erg[i])cccc++; }; printf("%d\n",cccc); for(int i = 0;i<w;i++){ if(erg[i])printf("%d\n",i+1); }; return 0; };
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 2688 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 2688 KB | Output is correct |
2 | Incorrect | 6 ms | 2688 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 2688 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 2688 KB | Output is correct |
2 | Incorrect | 6 ms | 2688 KB | Output isn't correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 2688 KB | Output is correct |
2 | Correct | 6 ms | 2688 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 2688 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 2688 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 7 ms | 2688 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 6 ms | 2688 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 29 ms | 4224 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 78 ms | 9448 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 82 ms | 8192 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 211 ms | 11408 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 215 ms | 11912 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |