# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
615293 | 2022-07-31T08:19:46 Z | zz(#8674) | Sprinkler (JOI22_sprinkler) | C++17 | 1000 ms | 96312 KB |
#include <bits/stdc++.h> using namespace std; vector<int> G[210009]; long long D[210009][44]; int P[210009]; void dfs(int x, int p) { P[x] = p; for(auto& it: G[x]) if(it != p) dfs(it, x); } int main() { int N, L; scanf("%d%d", &N, &L); for(int i=1; i<N; i++) { int u, v; scanf("%d%d", &u, &v); G[u].push_back(v); G[v].push_back(u); } for(int i=N+1; i<=N+40; i++) { G[i].push_back(i-1); G[i-1].push_back(i); } for(int i=1; i<=N+40; i++) for(int j=1; j<=40; j++) D[i][j] = 1; for(int i=1; i<=N; i++) scanf("%d", &D[i][0]); dfs(N+40, N+40); int Q; scanf("%d", &Q); while(Q--) { int t, x; scanf("%d%d", &t, &x); if(t == 1) { int d, w; scanf("%d%d", &d, &w); for(int i=0; i<=d; i++) { D[x][d-i] = D[x][d-i] * w % L; if(i < d) D[x][d-i-1] = D[x][d-i-1] * w % L; x = P[x]; } } if(t == 2) { long long r = 1; for(int i=0; i<=40; i++) { r = r * D[x][i] % L; x = P[x]; } printf("%lld\n", r); } } return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 5204 KB | Output is correct |
2 | Correct | 3 ms | 5204 KB | Output is correct |
3 | Correct | 3 ms | 5236 KB | Output is correct |
4 | Correct | 5 ms | 5588 KB | Output is correct |
5 | Correct | 6 ms | 5588 KB | Output is correct |
6 | Correct | 4 ms | 5588 KB | Output is correct |
7 | Correct | 4 ms | 5632 KB | Output is correct |
8 | Correct | 5 ms | 5588 KB | Output is correct |
9 | Correct | 4 ms | 5332 KB | Output is correct |
10 | Correct | 3 ms | 5204 KB | Output is correct |
11 | Correct | 4 ms | 5244 KB | Output is correct |
12 | Correct | 5 ms | 5204 KB | Output is correct |
13 | Correct | 4 ms | 5204 KB | Output is correct |
14 | Correct | 3 ms | 5248 KB | Output is correct |
15 | Correct | 4 ms | 5240 KB | Output is correct |
16 | Correct | 4 ms | 5248 KB | Output is correct |
17 | Correct | 4 ms | 5204 KB | Output is correct |
18 | Correct | 4 ms | 5260 KB | Output is correct |
19 | Correct | 4 ms | 5204 KB | Output is correct |
20 | Correct | 3 ms | 5204 KB | Output is correct |
21 | Correct | 3 ms | 5244 KB | Output is correct |
22 | Correct | 3 ms | 5240 KB | Output is correct |
23 | Correct | 4 ms | 5200 KB | Output is correct |
24 | Correct | 3 ms | 5240 KB | Output is correct |
25 | Correct | 4 ms | 5204 KB | Output is correct |
26 | Correct | 4 ms | 5204 KB | Output is correct |
27 | Correct | 3 ms | 5204 KB | Output is correct |
28 | Correct | 3 ms | 5204 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 5332 KB | Output is correct |
2 | Correct | 591 ms | 87124 KB | Output is correct |
3 | Correct | 414 ms | 88140 KB | Output is correct |
4 | Correct | 568 ms | 95644 KB | Output is correct |
5 | Correct | 586 ms | 93268 KB | Output is correct |
6 | Correct | 429 ms | 92932 KB | Output is correct |
7 | Correct | 463 ms | 93520 KB | Output is correct |
8 | Correct | 364 ms | 94012 KB | Output is correct |
9 | Correct | 773 ms | 95324 KB | Output is correct |
10 | Correct | 501 ms | 95420 KB | Output is correct |
11 | Correct | 722 ms | 92884 KB | Output is correct |
12 | Correct | 534 ms | 92668 KB | Output is correct |
13 | Correct | 421 ms | 89992 KB | Output is correct |
14 | Correct | 407 ms | 89128 KB | Output is correct |
15 | Correct | 367 ms | 89204 KB | Output is correct |
16 | Correct | 354 ms | 88996 KB | Output is correct |
17 | Correct | 462 ms | 89688 KB | Output is correct |
18 | Correct | 4 ms | 5204 KB | Output is correct |
19 | Correct | 5 ms | 5204 KB | Output is correct |
20 | Correct | 4 ms | 5204 KB | Output is correct |
21 | Correct | 5 ms | 5244 KB | Output is correct |
22 | Correct | 4 ms | 5204 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 5332 KB | Output is correct |
2 | Correct | 591 ms | 87124 KB | Output is correct |
3 | Correct | 414 ms | 88140 KB | Output is correct |
4 | Correct | 568 ms | 95644 KB | Output is correct |
5 | Correct | 586 ms | 93268 KB | Output is correct |
6 | Correct | 429 ms | 92932 KB | Output is correct |
7 | Correct | 463 ms | 93520 KB | Output is correct |
8 | Correct | 364 ms | 94012 KB | Output is correct |
9 | Correct | 773 ms | 95324 KB | Output is correct |
10 | Correct | 501 ms | 95420 KB | Output is correct |
11 | Correct | 722 ms | 92884 KB | Output is correct |
12 | Correct | 534 ms | 92668 KB | Output is correct |
13 | Correct | 421 ms | 89992 KB | Output is correct |
14 | Correct | 407 ms | 89128 KB | Output is correct |
15 | Correct | 367 ms | 89204 KB | Output is correct |
16 | Correct | 354 ms | 88996 KB | Output is correct |
17 | Correct | 462 ms | 89688 KB | Output is correct |
18 | Correct | 4 ms | 5204 KB | Output is correct |
19 | Correct | 5 ms | 5204 KB | Output is correct |
20 | Correct | 4 ms | 5204 KB | Output is correct |
21 | Correct | 5 ms | 5244 KB | Output is correct |
22 | Correct | 4 ms | 5204 KB | Output is correct |
23 | Correct | 4 ms | 5236 KB | Output is correct |
24 | Correct | 723 ms | 92340 KB | Output is correct |
25 | Correct | 476 ms | 92628 KB | Output is correct |
26 | Correct | 555 ms | 96312 KB | Output is correct |
27 | Correct | 500 ms | 92336 KB | Output is correct |
28 | Correct | 438 ms | 92436 KB | Output is correct |
29 | Correct | 458 ms | 92108 KB | Output is correct |
30 | Correct | 365 ms | 93132 KB | Output is correct |
31 | Correct | 603 ms | 95832 KB | Output is correct |
32 | Correct | 425 ms | 94936 KB | Output is correct |
33 | Correct | 602 ms | 92064 KB | Output is correct |
34 | Correct | 448 ms | 92560 KB | Output is correct |
35 | Correct | 4 ms | 5204 KB | Output is correct |
36 | Correct | 4 ms | 5204 KB | Output is correct |
37 | Correct | 4 ms | 5248 KB | Output is correct |
38 | Correct | 5 ms | 5204 KB | Output is correct |
39 | Correct | 4 ms | 5212 KB | Output is correct |
40 | Correct | 4 ms | 5240 KB | Output is correct |
41 | Correct | 5 ms | 5204 KB | Output is correct |
42 | Correct | 4 ms | 5236 KB | Output is correct |
43 | Correct | 4 ms | 5244 KB | Output is correct |
44 | Correct | 4 ms | 5204 KB | Output is correct |
45 | Correct | 4 ms | 5204 KB | Output is correct |
46 | Correct | 4 ms | 5204 KB | Output is correct |
47 | Correct | 4 ms | 5204 KB | Output is correct |
48 | Correct | 4 ms | 5204 KB | Output is correct |
49 | Correct | 3 ms | 5236 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 5332 KB | Output is correct |
2 | Correct | 703 ms | 86356 KB | Output is correct |
3 | Correct | 882 ms | 90420 KB | Output is correct |
4 | Correct | 647 ms | 94004 KB | Output is correct |
5 | Correct | 697 ms | 89516 KB | Output is correct |
6 | Correct | 454 ms | 90056 KB | Output is correct |
7 | Correct | 425 ms | 89976 KB | Output is correct |
8 | Correct | 397 ms | 90736 KB | Output is correct |
9 | Correct | 645 ms | 92060 KB | Output is correct |
10 | Correct | 844 ms | 94220 KB | Output is correct |
11 | Correct | 685 ms | 89428 KB | Output is correct |
12 | Correct | 737 ms | 90432 KB | Output is correct |
13 | Correct | 465 ms | 91352 KB | Output is correct |
14 | Correct | 514 ms | 91608 KB | Output is correct |
15 | Correct | 3 ms | 5204 KB | Output is correct |
16 | Correct | 3 ms | 5204 KB | Output is correct |
17 | Correct | 4 ms | 5244 KB | Output is correct |
18 | Correct | 4 ms | 5204 KB | Output is correct |
19 | Correct | 3 ms | 5204 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 5204 KB | Output is correct |
2 | Correct | 650 ms | 88168 KB | Output is correct |
3 | Correct | 888 ms | 89300 KB | Output is correct |
4 | Correct | 679 ms | 94740 KB | Output is correct |
5 | Correct | 537 ms | 91024 KB | Output is correct |
6 | Correct | 484 ms | 92032 KB | Output is correct |
7 | Correct | 431 ms | 91776 KB | Output is correct |
8 | Correct | 482 ms | 92048 KB | Output is correct |
9 | Correct | 672 ms | 96208 KB | Output is correct |
10 | Correct | 819 ms | 93904 KB | Output is correct |
11 | Correct | 625 ms | 92664 KB | Output is correct |
12 | Correct | 700 ms | 91120 KB | Output is correct |
13 | Correct | 526 ms | 92056 KB | Output is correct |
14 | Correct | 541 ms | 92336 KB | Output is correct |
15 | Correct | 4 ms | 5204 KB | Output is correct |
16 | Correct | 3 ms | 5204 KB | Output is correct |
17 | Correct | 3 ms | 5204 KB | Output is correct |
18 | Correct | 3 ms | 5204 KB | Output is correct |
19 | Correct | 3 ms | 5204 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 5204 KB | Output is correct |
2 | Correct | 3 ms | 5204 KB | Output is correct |
3 | Correct | 3 ms | 5236 KB | Output is correct |
4 | Correct | 5 ms | 5588 KB | Output is correct |
5 | Correct | 6 ms | 5588 KB | Output is correct |
6 | Correct | 4 ms | 5588 KB | Output is correct |
7 | Correct | 4 ms | 5632 KB | Output is correct |
8 | Correct | 5 ms | 5588 KB | Output is correct |
9 | Correct | 4 ms | 5332 KB | Output is correct |
10 | Correct | 3 ms | 5204 KB | Output is correct |
11 | Correct | 4 ms | 5244 KB | Output is correct |
12 | Correct | 5 ms | 5204 KB | Output is correct |
13 | Correct | 4 ms | 5204 KB | Output is correct |
14 | Correct | 3 ms | 5248 KB | Output is correct |
15 | Correct | 4 ms | 5240 KB | Output is correct |
16 | Correct | 4 ms | 5248 KB | Output is correct |
17 | Correct | 4 ms | 5204 KB | Output is correct |
18 | Correct | 4 ms | 5260 KB | Output is correct |
19 | Correct | 4 ms | 5204 KB | Output is correct |
20 | Correct | 3 ms | 5204 KB | Output is correct |
21 | Correct | 3 ms | 5244 KB | Output is correct |
22 | Correct | 3 ms | 5240 KB | Output is correct |
23 | Correct | 4 ms | 5200 KB | Output is correct |
24 | Correct | 3 ms | 5240 KB | Output is correct |
25 | Correct | 4 ms | 5204 KB | Output is correct |
26 | Correct | 4 ms | 5204 KB | Output is correct |
27 | Correct | 3 ms | 5204 KB | Output is correct |
28 | Correct | 3 ms | 5204 KB | Output is correct |
29 | Correct | 3 ms | 5332 KB | Output is correct |
30 | Correct | 591 ms | 87124 KB | Output is correct |
31 | Correct | 414 ms | 88140 KB | Output is correct |
32 | Correct | 568 ms | 95644 KB | Output is correct |
33 | Correct | 586 ms | 93268 KB | Output is correct |
34 | Correct | 429 ms | 92932 KB | Output is correct |
35 | Correct | 463 ms | 93520 KB | Output is correct |
36 | Correct | 364 ms | 94012 KB | Output is correct |
37 | Correct | 773 ms | 95324 KB | Output is correct |
38 | Correct | 501 ms | 95420 KB | Output is correct |
39 | Correct | 722 ms | 92884 KB | Output is correct |
40 | Correct | 534 ms | 92668 KB | Output is correct |
41 | Correct | 421 ms | 89992 KB | Output is correct |
42 | Correct | 407 ms | 89128 KB | Output is correct |
43 | Correct | 367 ms | 89204 KB | Output is correct |
44 | Correct | 354 ms | 88996 KB | Output is correct |
45 | Correct | 462 ms | 89688 KB | Output is correct |
46 | Correct | 4 ms | 5204 KB | Output is correct |
47 | Correct | 5 ms | 5204 KB | Output is correct |
48 | Correct | 4 ms | 5204 KB | Output is correct |
49 | Correct | 5 ms | 5244 KB | Output is correct |
50 | Correct | 4 ms | 5204 KB | Output is correct |
51 | Correct | 4 ms | 5236 KB | Output is correct |
52 | Correct | 723 ms | 92340 KB | Output is correct |
53 | Correct | 476 ms | 92628 KB | Output is correct |
54 | Correct | 555 ms | 96312 KB | Output is correct |
55 | Correct | 500 ms | 92336 KB | Output is correct |
56 | Correct | 438 ms | 92436 KB | Output is correct |
57 | Correct | 458 ms | 92108 KB | Output is correct |
58 | Correct | 365 ms | 93132 KB | Output is correct |
59 | Correct | 603 ms | 95832 KB | Output is correct |
60 | Correct | 425 ms | 94936 KB | Output is correct |
61 | Correct | 602 ms | 92064 KB | Output is correct |
62 | Correct | 448 ms | 92560 KB | Output is correct |
63 | Correct | 4 ms | 5204 KB | Output is correct |
64 | Correct | 4 ms | 5204 KB | Output is correct |
65 | Correct | 4 ms | 5248 KB | Output is correct |
66 | Correct | 5 ms | 5204 KB | Output is correct |
67 | Correct | 4 ms | 5212 KB | Output is correct |
68 | Correct | 4 ms | 5240 KB | Output is correct |
69 | Correct | 5 ms | 5204 KB | Output is correct |
70 | Correct | 4 ms | 5236 KB | Output is correct |
71 | Correct | 4 ms | 5244 KB | Output is correct |
72 | Correct | 4 ms | 5204 KB | Output is correct |
73 | Correct | 4 ms | 5204 KB | Output is correct |
74 | Correct | 4 ms | 5204 KB | Output is correct |
75 | Correct | 4 ms | 5204 KB | Output is correct |
76 | Correct | 4 ms | 5204 KB | Output is correct |
77 | Correct | 3 ms | 5236 KB | Output is correct |
78 | Correct | 5 ms | 5332 KB | Output is correct |
79 | Correct | 703 ms | 86356 KB | Output is correct |
80 | Correct | 882 ms | 90420 KB | Output is correct |
81 | Correct | 647 ms | 94004 KB | Output is correct |
82 | Correct | 697 ms | 89516 KB | Output is correct |
83 | Correct | 454 ms | 90056 KB | Output is correct |
84 | Correct | 425 ms | 89976 KB | Output is correct |
85 | Correct | 397 ms | 90736 KB | Output is correct |
86 | Correct | 645 ms | 92060 KB | Output is correct |
87 | Correct | 844 ms | 94220 KB | Output is correct |
88 | Correct | 685 ms | 89428 KB | Output is correct |
89 | Correct | 737 ms | 90432 KB | Output is correct |
90 | Correct | 465 ms | 91352 KB | Output is correct |
91 | Correct | 514 ms | 91608 KB | Output is correct |
92 | Correct | 3 ms | 5204 KB | Output is correct |
93 | Correct | 3 ms | 5204 KB | Output is correct |
94 | Correct | 4 ms | 5244 KB | Output is correct |
95 | Correct | 4 ms | 5204 KB | Output is correct |
96 | Correct | 3 ms | 5204 KB | Output is correct |
97 | Correct | 4 ms | 5204 KB | Output is correct |
98 | Correct | 650 ms | 88168 KB | Output is correct |
99 | Correct | 888 ms | 89300 KB | Output is correct |
100 | Correct | 679 ms | 94740 KB | Output is correct |
101 | Correct | 537 ms | 91024 KB | Output is correct |
102 | Correct | 484 ms | 92032 KB | Output is correct |
103 | Correct | 431 ms | 91776 KB | Output is correct |
104 | Correct | 482 ms | 92048 KB | Output is correct |
105 | Correct | 672 ms | 96208 KB | Output is correct |
106 | Correct | 819 ms | 93904 KB | Output is correct |
107 | Correct | 625 ms | 92664 KB | Output is correct |
108 | Correct | 700 ms | 91120 KB | Output is correct |
109 | Correct | 526 ms | 92056 KB | Output is correct |
110 | Correct | 541 ms | 92336 KB | Output is correct |
111 | Correct | 4 ms | 5204 KB | Output is correct |
112 | Correct | 3 ms | 5204 KB | Output is correct |
113 | Correct | 3 ms | 5204 KB | Output is correct |
114 | Correct | 3 ms | 5204 KB | Output is correct |
115 | Correct | 3 ms | 5204 KB | Output is correct |
116 | Correct | 581 ms | 88000 KB | Output is correct |
117 | Correct | 800 ms | 91468 KB | Output is correct |
118 | Correct | 702 ms | 96088 KB | Output is correct |
119 | Correct | 613 ms | 92204 KB | Output is correct |
120 | Correct | 484 ms | 92004 KB | Output is correct |
121 | Correct | 530 ms | 92720 KB | Output is correct |
122 | Correct | 478 ms | 93280 KB | Output is correct |
123 | Correct | 739 ms | 94816 KB | Output is correct |
124 | Correct | 1000 ms | 95004 KB | Output is correct |
125 | Correct | 715 ms | 91464 KB | Output is correct |
126 | Correct | 901 ms | 92700 KB | Output is correct |
127 | Correct | 849 ms | 93572 KB | Output is correct |
128 | Correct | 669 ms | 94112 KB | Output is correct |
129 | Correct | 638 ms | 94884 KB | Output is correct |