# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
342405 | 2021-01-02T05:48:21 Z | mjhmjh1104 | Spring cleaning (CEOI20_cleaning) | C++14 | 53 ms | 7908 KB |
#include <cstdio> #include <vector> #include <algorithm> using namespace std; const int MAX = 100006; int n, q, d, childs[MAX]; vector<int> adj[MAX]; int main() { scanf("%d%d", &n, &q); for (int i = 0; i < n - 1; i++) { int a, b; scanf("%d%d", &a, &b); a--, b--; adj[a].push_back(b); adj[b].push_back(a); } scanf("%d", &d); for (int i = 0; i < d; i++) { int x; scanf("%d", &x); x--; childs[x]++; } int cnt = 0; for (int i = 1; i < n; i++) cnt += max(childs[i], 1); if (cnt % 2) return puts("-1"), 0; long long res = 0; for (int i = 1; i < n; i++) if (childs[i] > 2) res += (childs[i] - 1) / 2 * 2, childs[i] -= (childs[i] - 1) / 2 * 2; for (int i = 1; i < n; i++) if (childs[i]) res += childs[i] * 2; else res++; printf("%lld", res); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 2816 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 15 ms | 3180 KB | Output is correct |
2 | Correct | 12 ms | 3180 KB | Output is correct |
3 | Correct | 36 ms | 7396 KB | Output is correct |
4 | Correct | 35 ms | 6520 KB | Output is correct |
5 | Correct | 45 ms | 7908 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 14 ms | 3308 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 14 ms | 3692 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 29 ms | 5612 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 53 ms | 7276 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 2816 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |