# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
343778 | 2021-01-04T13:20:06 Z | Joshc | Flood (IOI07_flood) | C++11 | 560 ms | 31328 KB |
#include <cstdio> #include <algorithm> #include <set> #include <vector> using namespace std; const int MAX_N = 100001; int x[MAX_N], y[MAX_N], p[2*MAX_N], q[2*MAX_N], left[2*MAX_N], num[2*MAX_N]; set<pair<int, int> > edges[MAX_N]; int dir(int a, int b) { if (x[a] == x[b]) return y[a]<y[b] ? 0 : 2; return x[a]<x[b] ? 3 : 1; } bool comp(int a, int b) { if ((dir(p[a], q[a])&1) != (dir(p[b], q[b])&1)) return dir(p[b], q[b])&1; if (dir(p[a], q[a])&1) return y[p[a]] > y[p[b]]; return x[p[a]] < x[p[b]]; } int main() { int n, w, ans=0; scanf("%d", &n); for (int i=1; i<=n; i++) scanf("%d%d", &x[i], &y[i]); scanf("%d", &w); for (int i=1; i<=w; i++) { scanf("%d%d", &p[i], &q[i]); edges[p[i]].insert({q[i], i}); edges[q[i]].insert({p[i], i}); left[i] = min(x[p[i]], x[q[i]]); } vector<int> v; for (int i=1; i<=w; i++) v.push_back(i); sort(v.begin(), v.end(), comp); set<int> s; for (int i : v) s.insert(i); while (!s.empty()) { int start = p[*s.begin()], cur=q[*s.begin()]; if (dir(start, cur)<2) swap(start, cur); int d = dir(start, cur), orig=cur; set<int> del = {*s.begin()}; num[*s.begin()]++; while (true) { if (!cur) break; int angle=4; pair<int, int> best; for (auto v : edges[cur]) { int x = (dir(cur, v.first)-d+5)%4; if (x < angle) { angle = x; best = v; } } if (cur==start && orig==best.first) break; num[best.second]++; del.insert(best.second); d = dir(cur, best.first); cur = best.first; } for (int i : del) { edges[p[i]].erase({q[i], i}); edges[q[i]].erase({p[i], i}); s.erase(i); } } for (int i=1; i<=w; i++) ans += num[i]==2; printf("%d\n", ans); for (int i=1; i<=w; i++) { if (num[i] == 2) printf("%d\n", i); } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 4972 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 4972 KB | Output is correct |
2 | Correct | 4 ms | 5100 KB | Output is correct |
3 | Correct | 4 ms | 4972 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 5100 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 5100 KB | Output is correct |
2 | Correct | 5 ms | 5100 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 5100 KB | Output is correct |
2 | Incorrect | 4 ms | 5100 KB | Output isn't correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 5248 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 5100 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 4 ms | 5100 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 4 ms | 5100 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 34 ms | 9324 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 111 ms | 21904 KB | Output isn't correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 113 ms | 22372 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 467 ms | 28132 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 560 ms | 31328 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |