#include <bits/stdc++.h>
using namespace std;
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
int N, L;
cin >> N >> L;
vector<vector<int>> adj(N);
for(int i = 1; i < N; ++i){
int u, v;
cin >> u >> v;
--u, --v;
adj[u].emplace_back(v);
adj[v].emplace_back(u);
}
vector<int> H(N);
for(int i = 0; i < N; ++i) cin >> H[i];
function<void(int, int, int, int)> dfs = [&](int u, int p, int limit, int coef){
H[u] = 1LL * H[u] * coef % L;
if(limit){
for(auto v : adj[u]) if(v != p){
dfs(v, u, limit - 1, coef);
}
}
};
int Q;
cin >> Q;
while(Q--){
int type;
cin >> type;
if(type == 1){
int x, d, w;
cin >> x >> d >> w;
--x;
dfs(x, -1, d, w);
} else{
int x; cin >> x;
--x;
cout << H[x] << '\n';
}
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
2 ms |
508 KB |
Output is correct |
5 |
Correct |
2 ms |
336 KB |
Output is correct |
6 |
Correct |
5 ms |
336 KB |
Output is correct |
7 |
Correct |
5 ms |
336 KB |
Output is correct |
8 |
Correct |
7 ms |
336 KB |
Output is correct |
9 |
Correct |
1 ms |
336 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
1 ms |
336 KB |
Output is correct |
12 |
Correct |
1 ms |
336 KB |
Output is correct |
13 |
Correct |
1 ms |
336 KB |
Output is correct |
14 |
Correct |
1 ms |
592 KB |
Output is correct |
15 |
Correct |
1 ms |
592 KB |
Output is correct |
16 |
Correct |
1 ms |
388 KB |
Output is correct |
17 |
Correct |
2 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
504 KB |
Output is correct |
19 |
Correct |
1 ms |
336 KB |
Output is correct |
20 |
Correct |
1 ms |
504 KB |
Output is correct |
21 |
Correct |
1 ms |
336 KB |
Output is correct |
22 |
Correct |
1 ms |
464 KB |
Output is correct |
23 |
Correct |
1 ms |
336 KB |
Output is correct |
24 |
Correct |
1 ms |
336 KB |
Output is correct |
25 |
Correct |
1 ms |
348 KB |
Output is correct |
26 |
Correct |
1 ms |
336 KB |
Output is correct |
27 |
Correct |
1 ms |
336 KB |
Output is correct |
28 |
Correct |
1 ms |
336 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
148 ms |
23880 KB |
Output is correct |
3 |
Correct |
218 ms |
24424 KB |
Output is correct |
4 |
Correct |
164 ms |
23880 KB |
Output is correct |
5 |
Correct |
191 ms |
24224 KB |
Output is correct |
6 |
Correct |
164 ms |
23880 KB |
Output is correct |
7 |
Correct |
181 ms |
24536 KB |
Output is correct |
8 |
Correct |
167 ms |
25020 KB |
Output is correct |
9 |
Correct |
146 ms |
23676 KB |
Output is correct |
10 |
Correct |
209 ms |
24136 KB |
Output is correct |
11 |
Correct |
143 ms |
23880 KB |
Output is correct |
12 |
Correct |
201 ms |
24380 KB |
Output is correct |
13 |
Execution timed out |
4049 ms |
17496 KB |
Time limit exceeded |
14 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
148 ms |
23880 KB |
Output is correct |
3 |
Correct |
218 ms |
24424 KB |
Output is correct |
4 |
Correct |
164 ms |
23880 KB |
Output is correct |
5 |
Correct |
191 ms |
24224 KB |
Output is correct |
6 |
Correct |
164 ms |
23880 KB |
Output is correct |
7 |
Correct |
181 ms |
24536 KB |
Output is correct |
8 |
Correct |
167 ms |
25020 KB |
Output is correct |
9 |
Correct |
146 ms |
23676 KB |
Output is correct |
10 |
Correct |
209 ms |
24136 KB |
Output is correct |
11 |
Correct |
143 ms |
23880 KB |
Output is correct |
12 |
Correct |
201 ms |
24380 KB |
Output is correct |
13 |
Execution timed out |
4049 ms |
17496 KB |
Time limit exceeded |
14 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
382 ms |
20920 KB |
Output is correct |
3 |
Correct |
1653 ms |
21696 KB |
Output is correct |
4 |
Correct |
535 ms |
21192 KB |
Output is correct |
5 |
Correct |
2698 ms |
21236 KB |
Output is correct |
6 |
Execution timed out |
4064 ms |
16968 KB |
Time limit exceeded |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
341 ms |
23472 KB |
Output is correct |
3 |
Correct |
1612 ms |
22092 KB |
Output is correct |
4 |
Correct |
475 ms |
22600 KB |
Output is correct |
5 |
Correct |
2866 ms |
22876 KB |
Output is correct |
6 |
Execution timed out |
4059 ms |
17012 KB |
Time limit exceeded |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
2 ms |
508 KB |
Output is correct |
5 |
Correct |
2 ms |
336 KB |
Output is correct |
6 |
Correct |
5 ms |
336 KB |
Output is correct |
7 |
Correct |
5 ms |
336 KB |
Output is correct |
8 |
Correct |
7 ms |
336 KB |
Output is correct |
9 |
Correct |
1 ms |
336 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
1 ms |
336 KB |
Output is correct |
12 |
Correct |
1 ms |
336 KB |
Output is correct |
13 |
Correct |
1 ms |
336 KB |
Output is correct |
14 |
Correct |
1 ms |
592 KB |
Output is correct |
15 |
Correct |
1 ms |
592 KB |
Output is correct |
16 |
Correct |
1 ms |
388 KB |
Output is correct |
17 |
Correct |
2 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
504 KB |
Output is correct |
19 |
Correct |
1 ms |
336 KB |
Output is correct |
20 |
Correct |
1 ms |
504 KB |
Output is correct |
21 |
Correct |
1 ms |
336 KB |
Output is correct |
22 |
Correct |
1 ms |
464 KB |
Output is correct |
23 |
Correct |
1 ms |
336 KB |
Output is correct |
24 |
Correct |
1 ms |
336 KB |
Output is correct |
25 |
Correct |
1 ms |
348 KB |
Output is correct |
26 |
Correct |
1 ms |
336 KB |
Output is correct |
27 |
Correct |
1 ms |
336 KB |
Output is correct |
28 |
Correct |
1 ms |
336 KB |
Output is correct |
29 |
Correct |
1 ms |
336 KB |
Output is correct |
30 |
Correct |
148 ms |
23880 KB |
Output is correct |
31 |
Correct |
218 ms |
24424 KB |
Output is correct |
32 |
Correct |
164 ms |
23880 KB |
Output is correct |
33 |
Correct |
191 ms |
24224 KB |
Output is correct |
34 |
Correct |
164 ms |
23880 KB |
Output is correct |
35 |
Correct |
181 ms |
24536 KB |
Output is correct |
36 |
Correct |
167 ms |
25020 KB |
Output is correct |
37 |
Correct |
146 ms |
23676 KB |
Output is correct |
38 |
Correct |
209 ms |
24136 KB |
Output is correct |
39 |
Correct |
143 ms |
23880 KB |
Output is correct |
40 |
Correct |
201 ms |
24380 KB |
Output is correct |
41 |
Execution timed out |
4049 ms |
17496 KB |
Time limit exceeded |
42 |
Halted |
0 ms |
0 KB |
- |