# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
343245 | 2021-01-03T15:04:48 Z | Joshc | Flood (IOI07_flood) | C++11 | 2000 ms | 30688 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) { return left[a] < left[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]]); } multiset<int, decltype(&comp)> s(&comp); for (int i=1; i<=w; i++) s.insert(i); while (!s.empty()) { int start = p[*s.begin()], cur=q[*s.begin()]; if (dir(start, cur)) swap(start, cur); int d = dir(start, cur), orig=cur; set<int> del = {*s.begin()}; num[*s.begin()]++; while (true) { 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(s.find(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 | Incorrect | 3 ms | 4972 KB | Output isn't correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 4972 KB | Output is correct |
2 | Correct | 3 ms | 5100 KB | Output is correct |
3 | Correct | 3 ms | 5100 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2072 ms | 5100 KB | Time limit exceeded |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2098 ms | 5100 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 5100 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2076 ms | 5100 KB | Time limit exceeded |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2065 ms | 5100 KB | Time limit exceeded |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2045 ms | 5100 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2082 ms | 5100 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2070 ms | 9196 KB | Time limit exceeded |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2079 ms | 20076 KB | Time limit exceeded |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2099 ms | 21868 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2059 ms | 27244 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2063 ms | 30688 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |