#include<bits/stdc++.h>
#define int long long
using namespace std;
int n, l, d, w;
vector<int> h;
vector<vector<int>> adj;
void dfs(int u, int p=-1, int H=0) {
if(H>d) return;
h[u]=(h[u]*w)%l;
for(int pp : adj[u]) {
if(pp==p) continue;
dfs(pp, u, H+1);
}
}
signed main() {
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin >> n >> l;
adj.resize(n); h.resize(n);
for(int i=1; i<n; i++) {
int u, v; cin >> u >> v;
--u; --v;
adj[u].push_back(v);
adj[v].push_back(u);
}
for(int &p : h) cin >> p;
int q; cin >> q;
while(q--) {
int type, x; cin >> type >> x; --x;
if(type==1) cin >> d >> w, dfs(x);
else cout << h[x] << '\n';
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
324 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
2 ms |
332 KB |
Output is correct |
5 |
Correct |
2 ms |
416 KB |
Output is correct |
6 |
Correct |
4 ms |
420 KB |
Output is correct |
7 |
Correct |
5 ms |
340 KB |
Output is correct |
8 |
Correct |
5 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
324 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
328 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
324 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
1 ms |
328 KB |
Output is correct |
19 |
Correct |
1 ms |
212 KB |
Output is correct |
20 |
Correct |
1 ms |
212 KB |
Output is correct |
21 |
Correct |
1 ms |
320 KB |
Output is correct |
22 |
Correct |
1 ms |
212 KB |
Output is correct |
23 |
Correct |
0 ms |
212 KB |
Output is correct |
24 |
Correct |
1 ms |
340 KB |
Output is correct |
25 |
Correct |
1 ms |
340 KB |
Output is correct |
26 |
Correct |
1 ms |
340 KB |
Output is correct |
27 |
Correct |
1 ms |
340 KB |
Output is correct |
28 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
320 KB |
Output is correct |
2 |
Correct |
172 ms |
25640 KB |
Output is correct |
3 |
Correct |
329 ms |
26136 KB |
Output is correct |
4 |
Correct |
240 ms |
24720 KB |
Output is correct |
5 |
Correct |
230 ms |
25804 KB |
Output is correct |
6 |
Correct |
202 ms |
25484 KB |
Output is correct |
7 |
Correct |
255 ms |
26280 KB |
Output is correct |
8 |
Execution timed out |
4045 ms |
20624 KB |
Time limit exceeded |
9 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
320 KB |
Output is correct |
2 |
Correct |
172 ms |
25640 KB |
Output is correct |
3 |
Correct |
329 ms |
26136 KB |
Output is correct |
4 |
Correct |
240 ms |
24720 KB |
Output is correct |
5 |
Correct |
230 ms |
25804 KB |
Output is correct |
6 |
Correct |
202 ms |
25484 KB |
Output is correct |
7 |
Correct |
255 ms |
26280 KB |
Output is correct |
8 |
Execution timed out |
4045 ms |
20624 KB |
Time limit exceeded |
9 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
483 ms |
21616 KB |
Output is correct |
3 |
Correct |
2882 ms |
22440 KB |
Output is correct |
4 |
Correct |
985 ms |
21876 KB |
Output is correct |
5 |
Execution timed out |
4038 ms |
22192 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
541 ms |
24244 KB |
Output is correct |
3 |
Correct |
3076 ms |
22740 KB |
Output is correct |
4 |
Correct |
1024 ms |
23252 KB |
Output is correct |
5 |
Execution timed out |
4077 ms |
23656 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
324 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
2 ms |
332 KB |
Output is correct |
5 |
Correct |
2 ms |
416 KB |
Output is correct |
6 |
Correct |
4 ms |
420 KB |
Output is correct |
7 |
Correct |
5 ms |
340 KB |
Output is correct |
8 |
Correct |
5 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
324 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
328 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
324 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
1 ms |
328 KB |
Output is correct |
19 |
Correct |
1 ms |
212 KB |
Output is correct |
20 |
Correct |
1 ms |
212 KB |
Output is correct |
21 |
Correct |
1 ms |
320 KB |
Output is correct |
22 |
Correct |
1 ms |
212 KB |
Output is correct |
23 |
Correct |
0 ms |
212 KB |
Output is correct |
24 |
Correct |
1 ms |
340 KB |
Output is correct |
25 |
Correct |
1 ms |
340 KB |
Output is correct |
26 |
Correct |
1 ms |
340 KB |
Output is correct |
27 |
Correct |
1 ms |
340 KB |
Output is correct |
28 |
Correct |
1 ms |
340 KB |
Output is correct |
29 |
Correct |
1 ms |
320 KB |
Output is correct |
30 |
Correct |
172 ms |
25640 KB |
Output is correct |
31 |
Correct |
329 ms |
26136 KB |
Output is correct |
32 |
Correct |
240 ms |
24720 KB |
Output is correct |
33 |
Correct |
230 ms |
25804 KB |
Output is correct |
34 |
Correct |
202 ms |
25484 KB |
Output is correct |
35 |
Correct |
255 ms |
26280 KB |
Output is correct |
36 |
Execution timed out |
4045 ms |
20624 KB |
Time limit exceeded |
37 |
Halted |
0 ms |
0 KB |
- |