# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
121278 | 2019-06-26T09:36:10 Z | Plurm | Flood (IOI07_flood) | C++11 | 1142 ms | 65536 KB |
#include <bits/stdc++.h> #define get(a,b) (ev[g[a][b]].first ^ ev[g[a][b]].second ^ a) using namespace std; int x[100005]; int y[100005]; int g[100005][4]; // U, L, D, R class Compare{ public: bool operator()(int x, int y){ return ::x[x] < ::x[y]; } }; int prior[4][4] = { {1, 0, 3, 2}, // U {2, 1, 0, 3}, // L {3, 2, 1, 0}, // D {0, 3, 2, 1} }; int inv[4] = {2, 3, 0, 1}; bool deleted[200005]; vector<pair<int,int> > ev; void deleteEdge(int idx){ int u = ev[idx].first; int v = ev[idx].second; for(int i = 0; i < 4; i++){ int j = inv[i]; if(get(u,i) == v && get(v,j) == u){ g[u][i] = -1; g[v][j] = -1; } } } int main(){ int n; scanf("%d",&n); multiset<int, Compare> ms; for(int i = 1; i <= n; i++){ g[i][0] = g[i][1] = g[i][2] = g[i][3] = -1; scanf("%d%d",x+i,y+i); } for(int i = 1; i <= n; i++){ ms.insert(i); } int w; scanf("%d",&w); for(int i = 0; i < w; i++){ int a,b; scanf("%d%d",&a,&b); if(x[a] > x[b]) swap(a,b); if(y[a] > y[b]) swap(a,b); if(x[a] < x[b]){ g[a][3] = i; g[b][1] = i; }else{ g[a][0] = i; g[b][2] = i; } ev.push_back(make_pair(a,b)); } while(!ms.empty()){ int c = *ms.begin(); int state = g[c][1] != -1; // 0: Going up // 1: Going left // 2: Going down // 3: Going right int u = c; vector<int> tour; vector<int> edge; map<int,int> ecnt; // U L D R do{ // Trace the border tour.push_back(u); for(int i = 0; i < 4; i++){ int chdir = prior[state][i]; if(g[u][chdir] != -1){ state = chdir; ecnt[g[u][chdir]]++; edge.push_back(g[u][chdir]); u = get(u,chdir); break; } } }while(!(u ==c && state >= 2)); for(int i = 0; i < edge.size(); i++){ int en = edge[i]; deleteEdge(en); if(ecnt[en] > 1) continue; deleted[en] = true; } for(int i = 0; i < tour.size(); i++){ int cnt = 0; for(int j = 0; j < 4; j++) if(g[tour[i]][j] != -1) cnt++; if(cnt == 0) ms.erase(tour[i]); } } vector<int> ans; for(int i = 0; i < w; i++){ if(!deleted[i]){ ans.push_back(i+1); } } printf("%d\n",ans.size()); for(int i = 0; i < ans.size(); i++){ printf("%d\n",ans[i]); } return 0; } /* 23 1 1 1 3 1 5 2 3 2 5 2 1 3 2 3 4 7 1 7 5 8 1 8 5 8 3 7 3 4 4 5 4 6 4 4 3 5 3 6 3 4 2 6 2 5 2 25 1 2 2 3 2 4 4 5 4 6 5 10 6 9 9 14 10 14 12 13 13 11 14 13 7 8 18 15 18 21 21 23 22 20 20 17 15 16 16 17 16 19 18 19 19 20 23 22 23 19 */
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 200 ms | 65536 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 202 ms | 65536 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 198 ms | 65536 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 185 ms | 65536 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 130 ms | 65536 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 197 ms | 65536 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 219 ms | 65536 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 214 ms | 65536 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 205 ms | 65536 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 215 ms | 65536 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 240 ms | 65536 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 238 ms | 65536 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 272 ms | 65536 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 1142 ms | 65536 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |