# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
450445 | 2021-08-02T22:25:35 Z | mjhmjh1104 | Joker (BOI20_joker) | C++17 | 101 ms | 8844 KB |
#include <cstdio> #include <vector> #include <utility> using namespace std; int uf[200006], sz[200006], ds[200006]; int _find(int x) { if (uf[x] == -1) return x; return _find(uf[x]); } int _dist(int x) { if (uf[x] == -1) return 0; return ds[x] + _dist(uf[x]); } bool _merge(int x, int y) { x = _find(x), y = _find(y); if (x != y) { if (sz[x] > sz[y]) uf[y] = x, sz[x] += sz[y], ds[y]++; else uf[x] = y, sz[y] += sz[x], ds[x]++; return true; } return false; } int n, m, q; vector<pair<int, int>> edges; int main() { scanf("%d%d%d", &n, &m, &q); for (int i = 0; i < m; i++) { int u, v; scanf("%d%d", &u, &v); u--, v--; edges.push_back({ u, v }); } for (int i = 0; i < n; i++) uf[i] = -1, sz[i] = 1, ds[i] = 0; int x = -1; for (int i = m - 1; i >= 0; i--) if (!_merge(edges[i].first, edges[i].second) && (_dist(edges[i].first) + _dist(edges[i].second) + 1) % 2) { x = i; break; } for (int i = 0; i < q; i++) { int l, r; scanf("%d%d", &l, &r); l--, r--; if (r < x) puts("YES"); else puts("NO"); } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 0 ms | 204 KB | Output is correct |
3 | Incorrect | 0 ms | 204 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 0 ms | 204 KB | Output is correct |
3 | Incorrect | 0 ms | 204 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 0 ms | 204 KB | Output is correct |
3 | Correct | 97 ms | 3716 KB | Output is correct |
4 | Correct | 101 ms | 8396 KB | Output is correct |
5 | Incorrect | 99 ms | 8844 KB | Output isn't correct |
6 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 0 ms | 204 KB | Output is correct |
3 | Incorrect | 0 ms | 204 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 0 ms | 204 KB | Output is correct |
3 | Incorrect | 0 ms | 204 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 0 ms | 204 KB | Output is correct |
3 | Incorrect | 0 ms | 204 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |