#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);
}
};
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';
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
11 ms |
24020 KB |
Output is correct |
2 |
Correct |
11 ms |
24020 KB |
Output is correct |
3 |
Correct |
12 ms |
24020 KB |
Output is correct |
4 |
Correct |
13 ms |
24020 KB |
Output is correct |
5 |
Correct |
14 ms |
24020 KB |
Output is correct |
6 |
Correct |
17 ms |
24004 KB |
Output is correct |
7 |
Correct |
16 ms |
24020 KB |
Output is correct |
8 |
Correct |
16 ms |
24044 KB |
Output is correct |
9 |
Correct |
12 ms |
24020 KB |
Output is correct |
10 |
Correct |
11 ms |
24016 KB |
Output is correct |
11 |
Correct |
11 ms |
24044 KB |
Output is correct |
12 |
Correct |
12 ms |
24020 KB |
Output is correct |
13 |
Correct |
12 ms |
24020 KB |
Output is correct |
14 |
Correct |
12 ms |
24044 KB |
Output is correct |
15 |
Correct |
12 ms |
23964 KB |
Output is correct |
16 |
Correct |
12 ms |
24020 KB |
Output is correct |
17 |
Correct |
12 ms |
24020 KB |
Output is correct |
18 |
Correct |
12 ms |
24036 KB |
Output is correct |
19 |
Correct |
12 ms |
24020 KB |
Output is correct |
20 |
Correct |
12 ms |
24020 KB |
Output is correct |
21 |
Correct |
12 ms |
24020 KB |
Output is correct |
22 |
Correct |
12 ms |
24024 KB |
Output is correct |
23 |
Correct |
12 ms |
23968 KB |
Output is correct |
24 |
Correct |
12 ms |
23976 KB |
Output is correct |
25 |
Correct |
15 ms |
23948 KB |
Output is correct |
26 |
Correct |
12 ms |
24020 KB |
Output is correct |
27 |
Correct |
13 ms |
24020 KB |
Output is correct |
28 |
Correct |
12 ms |
24036 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
11 ms |
24020 KB |
Output is correct |
2 |
Correct |
185 ms |
41084 KB |
Output is correct |
3 |
Correct |
217 ms |
37920 KB |
Output is correct |
4 |
Correct |
190 ms |
38416 KB |
Output is correct |
5 |
Correct |
190 ms |
39500 KB |
Output is correct |
6 |
Correct |
179 ms |
39528 KB |
Output is correct |
7 |
Correct |
186 ms |
40044 KB |
Output is correct |
8 |
Correct |
170 ms |
40048 KB |
Output is correct |
9 |
Correct |
172 ms |
39936 KB |
Output is correct |
10 |
Correct |
270 ms |
36948 KB |
Output is correct |
11 |
Correct |
181 ms |
41152 KB |
Output is correct |
12 |
Correct |
209 ms |
37888 KB |
Output is correct |
13 |
Execution timed out |
4051 ms |
37988 KB |
Time limit exceeded |
14 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
11 ms |
24020 KB |
Output is correct |
2 |
Correct |
185 ms |
41084 KB |
Output is correct |
3 |
Correct |
217 ms |
37920 KB |
Output is correct |
4 |
Correct |
190 ms |
38416 KB |
Output is correct |
5 |
Correct |
190 ms |
39500 KB |
Output is correct |
6 |
Correct |
179 ms |
39528 KB |
Output is correct |
7 |
Correct |
186 ms |
40044 KB |
Output is correct |
8 |
Correct |
170 ms |
40048 KB |
Output is correct |
9 |
Correct |
172 ms |
39936 KB |
Output is correct |
10 |
Correct |
270 ms |
36948 KB |
Output is correct |
11 |
Correct |
181 ms |
41152 KB |
Output is correct |
12 |
Correct |
209 ms |
37888 KB |
Output is correct |
13 |
Execution timed out |
4051 ms |
37988 KB |
Time limit exceeded |
14 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
11 ms |
24020 KB |
Output is correct |
2 |
Correct |
372 ms |
37400 KB |
Output is correct |
3 |
Correct |
2508 ms |
36636 KB |
Output is correct |
4 |
Correct |
835 ms |
36988 KB |
Output is correct |
5 |
Execution timed out |
4045 ms |
37912 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
14 ms |
24052 KB |
Output is correct |
2 |
Correct |
553 ms |
40212 KB |
Output is correct |
3 |
Correct |
2211 ms |
36948 KB |
Output is correct |
4 |
Correct |
823 ms |
38348 KB |
Output is correct |
5 |
Execution timed out |
4083 ms |
39372 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
11 ms |
24020 KB |
Output is correct |
2 |
Correct |
11 ms |
24020 KB |
Output is correct |
3 |
Correct |
12 ms |
24020 KB |
Output is correct |
4 |
Correct |
13 ms |
24020 KB |
Output is correct |
5 |
Correct |
14 ms |
24020 KB |
Output is correct |
6 |
Correct |
17 ms |
24004 KB |
Output is correct |
7 |
Correct |
16 ms |
24020 KB |
Output is correct |
8 |
Correct |
16 ms |
24044 KB |
Output is correct |
9 |
Correct |
12 ms |
24020 KB |
Output is correct |
10 |
Correct |
11 ms |
24016 KB |
Output is correct |
11 |
Correct |
11 ms |
24044 KB |
Output is correct |
12 |
Correct |
12 ms |
24020 KB |
Output is correct |
13 |
Correct |
12 ms |
24020 KB |
Output is correct |
14 |
Correct |
12 ms |
24044 KB |
Output is correct |
15 |
Correct |
12 ms |
23964 KB |
Output is correct |
16 |
Correct |
12 ms |
24020 KB |
Output is correct |
17 |
Correct |
12 ms |
24020 KB |
Output is correct |
18 |
Correct |
12 ms |
24036 KB |
Output is correct |
19 |
Correct |
12 ms |
24020 KB |
Output is correct |
20 |
Correct |
12 ms |
24020 KB |
Output is correct |
21 |
Correct |
12 ms |
24020 KB |
Output is correct |
22 |
Correct |
12 ms |
24024 KB |
Output is correct |
23 |
Correct |
12 ms |
23968 KB |
Output is correct |
24 |
Correct |
12 ms |
23976 KB |
Output is correct |
25 |
Correct |
15 ms |
23948 KB |
Output is correct |
26 |
Correct |
12 ms |
24020 KB |
Output is correct |
27 |
Correct |
13 ms |
24020 KB |
Output is correct |
28 |
Correct |
12 ms |
24036 KB |
Output is correct |
29 |
Correct |
11 ms |
24020 KB |
Output is correct |
30 |
Correct |
185 ms |
41084 KB |
Output is correct |
31 |
Correct |
217 ms |
37920 KB |
Output is correct |
32 |
Correct |
190 ms |
38416 KB |
Output is correct |
33 |
Correct |
190 ms |
39500 KB |
Output is correct |
34 |
Correct |
179 ms |
39528 KB |
Output is correct |
35 |
Correct |
186 ms |
40044 KB |
Output is correct |
36 |
Correct |
170 ms |
40048 KB |
Output is correct |
37 |
Correct |
172 ms |
39936 KB |
Output is correct |
38 |
Correct |
270 ms |
36948 KB |
Output is correct |
39 |
Correct |
181 ms |
41152 KB |
Output is correct |
40 |
Correct |
209 ms |
37888 KB |
Output is correct |
41 |
Execution timed out |
4051 ms |
37988 KB |
Time limit exceeded |
42 |
Halted |
0 ms |
0 KB |
- |