# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
54360 | 2018-07-03T08:17:47 Z | khsoo01 | Flood (IOI07_flood) | C++11 | 141 ms | 7564 KB |
#include<bits/stdc++.h> #define X first #define Y second using namespace std; typedef pair<int,int> pii; const int N = 200005; const int dx[4] = {1, 0, -1, 0}; const int dy[4] = {0, -1, 0, 1}; int n, m, x[N], y[N], a[N], b[N], nxt[N][4]; bool col[N], vis[N][2]; vector<int> wait, ans; priority_queue<pair<pii,int> > pq; int main() { scanf("%d",&n); for(int i=1;i<=n;i++) { scanf("%d%d",&x[i],&y[i]); } scanf("%d",&m); for(int i=1;i<=m;i++) { int A, B; scanf("%d%d",&A,&B); if(x[A] > x[B] || y[A] > y[B]) swap(A, B); a[i] = A; b[i] = B; if(y[A] == y[B]) { nxt[A][0] = i; nxt[B][2] = i; } else { nxt[A][3] = i; nxt[B][1] = i; } pq.push({{x[B], -y[B]}, i}); } while(!pq.empty()) { int T = pq.top().Y; pq.pop(); if(col[T]) continue; int V = a[T], P = (x[a[T]] == x[b[T]] ? 1 : 2); for(;;) { int D, Z; for(int i=0;i<4;i++) { D = (P + 3 + i) % 4; Z = nxt[V][D]; if(Z && !col[Z]) break; } if(vis[Z][D<2]) break; vis[Z][D<2] = true; wait.push_back(Z); V = a[Z] + b[Z] - V; P = D; } for(auto &T : wait) { col[T] = true; } wait.clear(); } for(int i=1;i<=m;i++) { if(vis[i][0] && vis[i][1]) ans.push_back(i); } printf("%d\n",(int)ans.size()); sort(ans.begin(), ans.end()); for(auto &T : ans) { printf("%d\n",T); } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 416 KB | Output is correct |
3 | Correct | 2 ms | 428 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 480 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 484 KB | Output is correct |
2 | Correct | 4 ms | 512 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 560 KB | Output is correct |
2 | Correct | 2 ms | 568 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 592 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 592 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 592 KB | Output is correct |
2 | Correct | 3 ms | 592 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 592 KB | Output is correct |
2 | Correct | 3 ms | 720 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 19 ms | 1888 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 64 ms | 4988 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 63 ms | 4988 KB | Output is correct |
2 | Correct | 136 ms | 7212 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 125 ms | 7212 KB | Output is correct |
2 | Correct | 139 ms | 7212 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 141 ms | 7212 KB | Output is correct |
2 | Correct | 102 ms | 7564 KB | Output is correct |