#include <bits/stdc++.h>
#define int long long
#define fi first
#define se second
#define keish ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using namespace std;
int n, l, q, u, v, t, x, d, w, lim;
vector<int> con[1005][1005];
signed main(){
keish;
cin >> n >> l;
vector<vector<int>> e(n);
for(int i = 1; i < n; i++){
cin >> u >> v; u--, v--;
e[u].push_back(v);
e[v].push_back(u);
}
vector<int> a(n);
for(auto &x : a) cin >> x;
function<void(int, int, int)> dfs = [&](int u, int p, int d){
if(d > lim) return;
for(auto v : e[u]){
if(v == p) continue;
(a[v] *= w) %= l;
dfs(v, u, d + 1);
}
};
for(int i = 0; i < n; i++){
dfs(i, -1, 1);
}
cin >> q;
while(q--){
cin >> t;
if(t == 1){
cin >> x >> lim >> w; x--;
(a[x] *= w) %= l;
dfs(x, -1, 1);
}else{
cin >> x; x--;
cout << a[x] << '\n';
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
24020 KB |
Output is correct |
2 |
Correct |
11 ms |
24028 KB |
Output is correct |
3 |
Correct |
11 ms |
24020 KB |
Output is correct |
4 |
Correct |
11 ms |
24020 KB |
Output is correct |
5 |
Correct |
14 ms |
24060 KB |
Output is correct |
6 |
Correct |
16 ms |
24112 KB |
Output is correct |
7 |
Correct |
14 ms |
24020 KB |
Output is correct |
8 |
Correct |
17 ms |
24212 KB |
Output is correct |
9 |
Correct |
10 ms |
24020 KB |
Output is correct |
10 |
Correct |
12 ms |
24020 KB |
Output is correct |
11 |
Correct |
11 ms |
24020 KB |
Output is correct |
12 |
Correct |
13 ms |
23976 KB |
Output is correct |
13 |
Correct |
10 ms |
23992 KB |
Output is correct |
14 |
Correct |
10 ms |
24028 KB |
Output is correct |
15 |
Correct |
13 ms |
24044 KB |
Output is correct |
16 |
Correct |
12 ms |
24048 KB |
Output is correct |
17 |
Correct |
14 ms |
24020 KB |
Output is correct |
18 |
Correct |
12 ms |
23944 KB |
Output is correct |
19 |
Correct |
11 ms |
24040 KB |
Output is correct |
20 |
Correct |
12 ms |
24020 KB |
Output is correct |
21 |
Correct |
13 ms |
23936 KB |
Output is correct |
22 |
Correct |
10 ms |
24020 KB |
Output is correct |
23 |
Correct |
10 ms |
23980 KB |
Output is correct |
24 |
Correct |
10 ms |
24020 KB |
Output is correct |
25 |
Correct |
10 ms |
24020 KB |
Output is correct |
26 |
Correct |
12 ms |
24020 KB |
Output is correct |
27 |
Correct |
14 ms |
24004 KB |
Output is correct |
28 |
Correct |
9 ms |
24032 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
15 ms |
23948 KB |
Output is correct |
2 |
Correct |
288 ms |
41040 KB |
Output is correct |
3 |
Correct |
271 ms |
37948 KB |
Output is correct |
4 |
Correct |
254 ms |
38388 KB |
Output is correct |
5 |
Correct |
211 ms |
39476 KB |
Output is correct |
6 |
Correct |
269 ms |
39564 KB |
Output is correct |
7 |
Correct |
259 ms |
39936 KB |
Output is correct |
8 |
Correct |
172 ms |
40100 KB |
Output is correct |
9 |
Correct |
195 ms |
39952 KB |
Output is correct |
10 |
Correct |
293 ms |
36868 KB |
Output is correct |
11 |
Correct |
234 ms |
41036 KB |
Output is correct |
12 |
Correct |
248 ms |
37896 KB |
Output is correct |
13 |
Execution timed out |
4046 ms |
37988 KB |
Time limit exceeded |
14 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
15 ms |
23948 KB |
Output is correct |
2 |
Correct |
288 ms |
41040 KB |
Output is correct |
3 |
Correct |
271 ms |
37948 KB |
Output is correct |
4 |
Correct |
254 ms |
38388 KB |
Output is correct |
5 |
Correct |
211 ms |
39476 KB |
Output is correct |
6 |
Correct |
269 ms |
39564 KB |
Output is correct |
7 |
Correct |
259 ms |
39936 KB |
Output is correct |
8 |
Correct |
172 ms |
40100 KB |
Output is correct |
9 |
Correct |
195 ms |
39952 KB |
Output is correct |
10 |
Correct |
293 ms |
36868 KB |
Output is correct |
11 |
Correct |
234 ms |
41036 KB |
Output is correct |
12 |
Correct |
248 ms |
37896 KB |
Output is correct |
13 |
Execution timed out |
4046 ms |
37988 KB |
Time limit exceeded |
14 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
13 ms |
24020 KB |
Output is correct |
2 |
Correct |
477 ms |
37368 KB |
Output is correct |
3 |
Correct |
2709 ms |
36632 KB |
Output is correct |
4 |
Correct |
1313 ms |
36976 KB |
Output is correct |
5 |
Execution timed out |
4067 ms |
37804 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
24020 KB |
Output is correct |
2 |
Correct |
614 ms |
40056 KB |
Output is correct |
3 |
Correct |
3211 ms |
36932 KB |
Output is correct |
4 |
Correct |
1285 ms |
38460 KB |
Output is correct |
5 |
Execution timed out |
4078 ms |
38904 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
24020 KB |
Output is correct |
2 |
Correct |
11 ms |
24028 KB |
Output is correct |
3 |
Correct |
11 ms |
24020 KB |
Output is correct |
4 |
Correct |
11 ms |
24020 KB |
Output is correct |
5 |
Correct |
14 ms |
24060 KB |
Output is correct |
6 |
Correct |
16 ms |
24112 KB |
Output is correct |
7 |
Correct |
14 ms |
24020 KB |
Output is correct |
8 |
Correct |
17 ms |
24212 KB |
Output is correct |
9 |
Correct |
10 ms |
24020 KB |
Output is correct |
10 |
Correct |
12 ms |
24020 KB |
Output is correct |
11 |
Correct |
11 ms |
24020 KB |
Output is correct |
12 |
Correct |
13 ms |
23976 KB |
Output is correct |
13 |
Correct |
10 ms |
23992 KB |
Output is correct |
14 |
Correct |
10 ms |
24028 KB |
Output is correct |
15 |
Correct |
13 ms |
24044 KB |
Output is correct |
16 |
Correct |
12 ms |
24048 KB |
Output is correct |
17 |
Correct |
14 ms |
24020 KB |
Output is correct |
18 |
Correct |
12 ms |
23944 KB |
Output is correct |
19 |
Correct |
11 ms |
24040 KB |
Output is correct |
20 |
Correct |
12 ms |
24020 KB |
Output is correct |
21 |
Correct |
13 ms |
23936 KB |
Output is correct |
22 |
Correct |
10 ms |
24020 KB |
Output is correct |
23 |
Correct |
10 ms |
23980 KB |
Output is correct |
24 |
Correct |
10 ms |
24020 KB |
Output is correct |
25 |
Correct |
10 ms |
24020 KB |
Output is correct |
26 |
Correct |
12 ms |
24020 KB |
Output is correct |
27 |
Correct |
14 ms |
24004 KB |
Output is correct |
28 |
Correct |
9 ms |
24032 KB |
Output is correct |
29 |
Correct |
15 ms |
23948 KB |
Output is correct |
30 |
Correct |
288 ms |
41040 KB |
Output is correct |
31 |
Correct |
271 ms |
37948 KB |
Output is correct |
32 |
Correct |
254 ms |
38388 KB |
Output is correct |
33 |
Correct |
211 ms |
39476 KB |
Output is correct |
34 |
Correct |
269 ms |
39564 KB |
Output is correct |
35 |
Correct |
259 ms |
39936 KB |
Output is correct |
36 |
Correct |
172 ms |
40100 KB |
Output is correct |
37 |
Correct |
195 ms |
39952 KB |
Output is correct |
38 |
Correct |
293 ms |
36868 KB |
Output is correct |
39 |
Correct |
234 ms |
41036 KB |
Output is correct |
40 |
Correct |
248 ms |
37896 KB |
Output is correct |
41 |
Execution timed out |
4046 ms |
37988 KB |
Time limit exceeded |
42 |
Halted |
0 ms |
0 KB |
- |