# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
614874 | 2022-07-31T05:18:45 Z | 반딧불(#8492) | Sprinkler (JOI22_sprinkler) | C++17 | 4000 ms | 25640 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; int n, q; ll MOD; vector<int> link[200002]; ll arr[200002]; void dfs(int x, int p, int d, ll w){ arr[x] = (arr[x] * w) % MOD; if(!d) return; for(auto y: link[x]){ if(y==p) continue; dfs(y, x, d-1, w); } } int main(){ scanf("%d %lld", &n, &MOD); for(int i=1; i<n; i++){ int x, y; scanf("%d %d", &x, &y); link[x].push_back(y); link[y].push_back(x); } for(int i=1; i<=n; i++) scanf("%lld", &arr[i]); scanf("%d", &q); while(q--){ int qt; scanf("%d", &qt); if(qt==1){ int x, d; ll w; scanf("%d %d %lld", &x, &d, &w); dfs(x, -1, d, w); } else{ int x; scanf("%d", &x); printf("%lld\n", arr[x]); } } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 4948 KB | Output is correct |
2 | Correct | 2 ms | 4948 KB | Output is correct |
3 | Correct | 3 ms | 5008 KB | Output is correct |
4 | Correct | 4 ms | 5076 KB | Output is correct |
5 | Correct | 6 ms | 5020 KB | Output is correct |
6 | Correct | 7 ms | 4980 KB | Output is correct |
7 | Correct | 8 ms | 5076 KB | Output is correct |
8 | Correct | 8 ms | 5020 KB | Output is correct |
9 | Correct | 3 ms | 4948 KB | Output is correct |
10 | Correct | 4 ms | 4948 KB | Output is correct |
11 | Correct | 4 ms | 4948 KB | Output is correct |
12 | Correct | 5 ms | 4952 KB | Output is correct |
13 | Correct | 4 ms | 4948 KB | Output is correct |
14 | Correct | 3 ms | 4948 KB | Output is correct |
15 | Correct | 3 ms | 5016 KB | Output is correct |
16 | Correct | 4 ms | 4948 KB | Output is correct |
17 | Correct | 3 ms | 5012 KB | Output is correct |
18 | Correct | 3 ms | 4948 KB | Output is correct |
19 | Correct | 4 ms | 5076 KB | Output is correct |
20 | Correct | 3 ms | 4948 KB | Output is correct |
21 | Correct | 3 ms | 4948 KB | Output is correct |
22 | Correct | 3 ms | 5012 KB | Output is correct |
23 | Correct | 3 ms | 5008 KB | Output is correct |
24 | Correct | 3 ms | 4948 KB | Output is correct |
25 | Correct | 3 ms | 4948 KB | Output is correct |
26 | Correct | 4 ms | 4948 KB | Output is correct |
27 | Correct | 3 ms | 4948 KB | Output is correct |
28 | Correct | 4 ms | 4948 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 5008 KB | Output is correct |
2 | Correct | 297 ms | 24564 KB | Output is correct |
3 | Correct | 395 ms | 25172 KB | Output is correct |
4 | Correct | 315 ms | 24680 KB | Output is correct |
5 | Correct | 371 ms | 24960 KB | Output is correct |
6 | Correct | 283 ms | 24472 KB | Output is correct |
7 | Correct | 364 ms | 25104 KB | Output is correct |
8 | Correct | 290 ms | 25640 KB | Output is correct |
9 | Correct | 314 ms | 24248 KB | Output is correct |
10 | Correct | 354 ms | 24872 KB | Output is correct |
11 | Correct | 273 ms | 24568 KB | Output is correct |
12 | Correct | 361 ms | 25000 KB | Output is correct |
13 | Execution timed out | 4035 ms | 17992 KB | Time limit exceeded |
14 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 5008 KB | Output is correct |
2 | Correct | 297 ms | 24564 KB | Output is correct |
3 | Correct | 395 ms | 25172 KB | Output is correct |
4 | Correct | 315 ms | 24680 KB | Output is correct |
5 | Correct | 371 ms | 24960 KB | Output is correct |
6 | Correct | 283 ms | 24472 KB | Output is correct |
7 | Correct | 364 ms | 25104 KB | Output is correct |
8 | Correct | 290 ms | 25640 KB | Output is correct |
9 | Correct | 314 ms | 24248 KB | Output is correct |
10 | Correct | 354 ms | 24872 KB | Output is correct |
11 | Correct | 273 ms | 24568 KB | Output is correct |
12 | Correct | 361 ms | 25000 KB | Output is correct |
13 | Execution timed out | 4035 ms | 17992 KB | Time limit exceeded |
14 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 4948 KB | Output is correct |
2 | Correct | 887 ms | 21636 KB | Output is correct |
3 | Execution timed out | 4022 ms | 22332 KB | Time limit exceeded |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 4948 KB | Output is correct |
2 | Correct | 729 ms | 24316 KB | Output is correct |
3 | Execution timed out | 4042 ms | 22616 KB | Time limit exceeded |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 4948 KB | Output is correct |
2 | Correct | 2 ms | 4948 KB | Output is correct |
3 | Correct | 3 ms | 5008 KB | Output is correct |
4 | Correct | 4 ms | 5076 KB | Output is correct |
5 | Correct | 6 ms | 5020 KB | Output is correct |
6 | Correct | 7 ms | 4980 KB | Output is correct |
7 | Correct | 8 ms | 5076 KB | Output is correct |
8 | Correct | 8 ms | 5020 KB | Output is correct |
9 | Correct | 3 ms | 4948 KB | Output is correct |
10 | Correct | 4 ms | 4948 KB | Output is correct |
11 | Correct | 4 ms | 4948 KB | Output is correct |
12 | Correct | 5 ms | 4952 KB | Output is correct |
13 | Correct | 4 ms | 4948 KB | Output is correct |
14 | Correct | 3 ms | 4948 KB | Output is correct |
15 | Correct | 3 ms | 5016 KB | Output is correct |
16 | Correct | 4 ms | 4948 KB | Output is correct |
17 | Correct | 3 ms | 5012 KB | Output is correct |
18 | Correct | 3 ms | 4948 KB | Output is correct |
19 | Correct | 4 ms | 5076 KB | Output is correct |
20 | Correct | 3 ms | 4948 KB | Output is correct |
21 | Correct | 3 ms | 4948 KB | Output is correct |
22 | Correct | 3 ms | 5012 KB | Output is correct |
23 | Correct | 3 ms | 5008 KB | Output is correct |
24 | Correct | 3 ms | 4948 KB | Output is correct |
25 | Correct | 3 ms | 4948 KB | Output is correct |
26 | Correct | 4 ms | 4948 KB | Output is correct |
27 | Correct | 3 ms | 4948 KB | Output is correct |
28 | Correct | 4 ms | 4948 KB | Output is correct |
29 | Correct | 3 ms | 5008 KB | Output is correct |
30 | Correct | 297 ms | 24564 KB | Output is correct |
31 | Correct | 395 ms | 25172 KB | Output is correct |
32 | Correct | 315 ms | 24680 KB | Output is correct |
33 | Correct | 371 ms | 24960 KB | Output is correct |
34 | Correct | 283 ms | 24472 KB | Output is correct |
35 | Correct | 364 ms | 25104 KB | Output is correct |
36 | Correct | 290 ms | 25640 KB | Output is correct |
37 | Correct | 314 ms | 24248 KB | Output is correct |
38 | Correct | 354 ms | 24872 KB | Output is correct |
39 | Correct | 273 ms | 24568 KB | Output is correct |
40 | Correct | 361 ms | 25000 KB | Output is correct |
41 | Execution timed out | 4035 ms | 17992 KB | Time limit exceeded |
42 | Halted | 0 ms | 0 KB | - |