# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
54347 | 2018-07-03T07:56:16 Z | 진화론자(#2049) | Flood (IOI07_flood) | C++11 | 166 ms | 7568 KB |
#include<bits/stdc++.h> #define X first #define Y second using namespace std; 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<pair<int,int>,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 | 2 ms | 376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 488 KB | Output is correct |
2 | Correct | 2 ms | 552 KB | Output is correct |
3 | Correct | 2 ms | 620 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 620 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 620 KB | Output is correct |
2 | Correct | 3 ms | 680 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 680 KB | Output is correct |
2 | Correct | 2 ms | 680 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 680 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 680 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 680 KB | Output is correct |
2 | Correct | 2 ms | 680 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 680 KB | Output is correct |
2 | Correct | 2 ms | 680 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 19 ms | 1796 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 61 ms | 4952 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 63 ms | 4952 KB | Output is correct |
2 | Correct | 136 ms | 7164 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 118 ms | 7164 KB | Output is correct |
2 | Correct | 166 ms | 7264 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 141 ms | 7264 KB | Output is correct |
2 | Correct | 110 ms | 7568 KB | Output is correct |