# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
842676 | 2023-09-03T08:27:31 Z | SUNWOOOOOOOO | Jail (JOI22_jail) | C++17 | 1 ms | 4956 KB |
#include <bits/stdc++.h> using namespace std; using pint = array <int, 2>; const int mxN = 120005; vector <int> adj[mxN], v1, v2; pint st[mxN]; int n, m, s1[mxN], s2[mxN]; int solve() { sort(st + 1, st + m + 1); for (int i = 1; i <= m; i++){ if (st[i][0] < st[i][1]) { v1.push_back(st[i][1]); s1[st[i][0]]++, s1[st[i][1] + 1]--; } else { v2.push_back(st[i][1]); s2[st[i][1]]++, s2[st[i][0] + 1]--; } } for (int i = 0; i < (int) v1.size() - 1; i++) if (v1[i] > v1[i + 1]) return 0; for (int i = 0; i < (int) v2.size() - 1; i++) if (v2[i] > v2[i + 1]) return 0; for (int i = 1; i <= n; i++) { s1[i] += s1[i - 1]; // printf("%d ", s1[i]); } // printf("\n"); for (int i = 1; i <= n; i++) { s2[i] += s2[i - 1]; // printf("%d ", s2[i]); } // printf("\n"); for (int i = 1; i <= n; i++) if (s1[i] && s2[i]) return 0; return 1; } int main() { int q; scanf("%d", &q); while (q--) { scanf("%d", &n); for (int i = 1; i <= n; i++) { // init adj[i].clear(); s1[i] = 0, s2[i] = 0; } v1.clear(); v2.clear(); for (int i = 0, a, b; i < n - 1; i++){ scanf("%d %d", &a, &b); adj[a].push_back(b); adj[b].push_back(a); } scanf("%d", &m); for (int i = 1; i <= m; i++) { scanf("%d %d", &st[i][0], &st[i][1]); } if (solve()) printf("YES\n"); else printf("NO\n"); } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 4956 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 4696 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 4696 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 4696 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 4696 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 4952 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 4956 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |