#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;
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){
// };
cin >> q;
while(q--){
cin >> t;
if(t == 1){
cin >> x >> d >> w; x--;
(a[x] *= w) %= l;
if(d > 0){
for(auto i : e[x]){
(a[i] *= w) %= l;
}
}
}else{
cin >> x; x--;
cout << a[x] << '\n';
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
192 ms |
17392 KB |
Output is correct |
3 |
Correct |
275 ms |
14212 KB |
Output is correct |
4 |
Correct |
207 ms |
14760 KB |
Output is correct |
5 |
Correct |
215 ms |
15812 KB |
Output is correct |
6 |
Correct |
219 ms |
15728 KB |
Output is correct |
7 |
Correct |
226 ms |
16144 KB |
Output is correct |
8 |
Correct |
194 ms |
20592 KB |
Output is correct |
9 |
Correct |
187 ms |
24380 KB |
Output is correct |
10 |
Correct |
294 ms |
24880 KB |
Output is correct |
11 |
Correct |
202 ms |
25512 KB |
Output is correct |
12 |
Correct |
264 ms |
26060 KB |
Output is correct |
13 |
Execution timed out |
4043 ms |
18868 KB |
Time limit exceeded |
14 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
192 ms |
17392 KB |
Output is correct |
3 |
Correct |
275 ms |
14212 KB |
Output is correct |
4 |
Correct |
207 ms |
14760 KB |
Output is correct |
5 |
Correct |
215 ms |
15812 KB |
Output is correct |
6 |
Correct |
219 ms |
15728 KB |
Output is correct |
7 |
Correct |
226 ms |
16144 KB |
Output is correct |
8 |
Correct |
194 ms |
20592 KB |
Output is correct |
9 |
Correct |
187 ms |
24380 KB |
Output is correct |
10 |
Correct |
294 ms |
24880 KB |
Output is correct |
11 |
Correct |
202 ms |
25512 KB |
Output is correct |
12 |
Correct |
264 ms |
26060 KB |
Output is correct |
13 |
Execution timed out |
4043 ms |
18868 KB |
Time limit exceeded |
14 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
166 ms |
15656 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |