# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
310047 | 2020-10-05T11:32:00 Z | soroush | File Paths (BOI15_fil) | C++14 | 205 ms | 5632 KB |
// Adam Karczmarz #include <bits/stdc++.h> #define SZ(AA) int((AA).size()) using namespace std; const int MAXN = 6000, MAXK = 1000000; vector<int> ve[MAXN + 10]; int N, M, K, S, h[MAXN + 10], cnt[MAXK + 10]; bool res[MAXN + 10], us[MAXK + 10]; void add(int v, int delta, int x) { if (v > N) { return; } int y = h[v] + delta; if (y <= MAXK) { cnt[y] += x; } for (int w : ve[v]) { add(w, delta, x); } } // use cycle void case1(int v) { if (v > N) { int y = K - h[v]; if (y > 0) { for (int d = 1; d * d <= y; ++d) { if (y % d == 0 && (cnt[d] > 0 || cnt[y / d] > 0)) { res[v] = true; } } } return; } add(v, S + 1 - h[v], 1); for (int w : ve[v]) { case1(w); } add(v, S + 1 - h[v], -1); } vector<int> anc; // use single directory symlink void case2(int v) { if (v > N) { for (int a : anc) { int y = K - (h[v] - h[a]) - (S + 1); if (y >= 0 && us[y]) { res[v] = true; } } return; } anc.push_back(v); for (int w : ve[v]) { case2(w); } anc.pop_back(); } // do not use symlinks at all void case3() { for (int i = N + 1; i <= N + M; ++i) { if (h[i] == K) { res[i] = true; } } } // use file symlink void case4() { for (int i = 0; i <= N; ++i) { if (h[i] + S == K) { for (int j = N + 1; j <= N + M; ++j) { res[j] = true; } return; } } } int main(void) { scanf("%d%d%d%d", &N, &M, &K, &S); h[0] = 1; us[1] = true; for (int i = 1; i <= N + M; ++i) { int p; scanf("%d%d", &p, &h[i]); ve[p].push_back(i); h[i] += h[p] + (i <= N ? 1 : 0); if (i <= N) { us[h[i]] = true; } } case1(0); case2(0); case3(); //case4(); for (int i = N + 1; i <= N + M; ++i) { puts(res[i] ? "YES" : "NO"); } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 512 KB | Output is correct |
2 | Correct | 1 ms | 512 KB | Output is correct |
3 | Correct | 2 ms | 1024 KB | Output is correct |
4 | Correct | 4 ms | 1024 KB | Output is correct |
5 | Correct | 6 ms | 4608 KB | Output is correct |
6 | Correct | 5 ms | 3328 KB | Output is correct |
7 | Correct | 11 ms | 4608 KB | Output is correct |
8 | Correct | 4 ms | 4224 KB | Output is correct |
9 | Correct | 4 ms | 4352 KB | Output is correct |
10 | Correct | 1 ms | 512 KB | Output is correct |
11 | Correct | 2 ms | 512 KB | Output is correct |
12 | Correct | 4 ms | 896 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 14 ms | 5248 KB | Output is correct |
2 | Correct | 13 ms | 5248 KB | Output is correct |
3 | Correct | 13 ms | 5376 KB | Output is correct |
4 | Correct | 12 ms | 5248 KB | Output is correct |
5 | Correct | 187 ms | 5336 KB | Output is correct |
6 | Correct | 181 ms | 5632 KB | Output is correct |
7 | Correct | 121 ms | 5240 KB | Output is correct |
8 | Correct | 112 ms | 5504 KB | Output is correct |
9 | Correct | 14 ms | 4864 KB | Output is correct |
10 | Correct | 11 ms | 4224 KB | Output is correct |
11 | Correct | 7 ms | 768 KB | Output is correct |
12 | Correct | 158 ms | 2432 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 512 KB | Output is correct |
2 | Correct | 1 ms | 512 KB | Output is correct |
3 | Correct | 2 ms | 1024 KB | Output is correct |
4 | Correct | 4 ms | 1024 KB | Output is correct |
5 | Correct | 6 ms | 4608 KB | Output is correct |
6 | Correct | 5 ms | 3328 KB | Output is correct |
7 | Correct | 11 ms | 4608 KB | Output is correct |
8 | Correct | 4 ms | 4224 KB | Output is correct |
9 | Correct | 4 ms | 4352 KB | Output is correct |
10 | Correct | 1 ms | 512 KB | Output is correct |
11 | Correct | 2 ms | 512 KB | Output is correct |
12 | Correct | 4 ms | 896 KB | Output is correct |
13 | Correct | 14 ms | 5248 KB | Output is correct |
14 | Correct | 13 ms | 5248 KB | Output is correct |
15 | Correct | 13 ms | 5376 KB | Output is correct |
16 | Correct | 12 ms | 5248 KB | Output is correct |
17 | Correct | 187 ms | 5336 KB | Output is correct |
18 | Correct | 181 ms | 5632 KB | Output is correct |
19 | Correct | 121 ms | 5240 KB | Output is correct |
20 | Correct | 112 ms | 5504 KB | Output is correct |
21 | Correct | 14 ms | 4864 KB | Output is correct |
22 | Correct | 11 ms | 4224 KB | Output is correct |
23 | Correct | 7 ms | 768 KB | Output is correct |
24 | Correct | 158 ms | 2432 KB | Output is correct |
25 | Correct | 13 ms | 4992 KB | Output is correct |
26 | Correct | 11 ms | 5120 KB | Output is correct |
27 | Correct | 12 ms | 5120 KB | Output is correct |
28 | Correct | 12 ms | 5376 KB | Output is correct |
29 | Correct | 190 ms | 5504 KB | Output is correct |
30 | Correct | 194 ms | 5368 KB | Output is correct |
31 | Correct | 113 ms | 5368 KB | Output is correct |
32 | Correct | 109 ms | 5248 KB | Output is correct |
33 | Correct | 11 ms | 4224 KB | Output is correct |
34 | Correct | 10 ms | 4352 KB | Output is correct |
35 | Correct | 7 ms | 768 KB | Output is correct |
36 | Correct | 205 ms | 1536 KB | Output is correct |