#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define pb push_back
ll n,l;
vector<int> adj1[200005], adj2[200005];
vector<ll> h(200005);
int main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin>>n>>l;
for(int i=1;i<n;i++){
int u,v;
cin>>u>>v;
adj1[u].pb(v);
adj2[u].pb(v);
adj1[v].pb(u);
adj2[v].pb(u);
}
for(int i=1;i<=n;i++) {
cin>>h[i];
}
// precomp adjs
for(int i=1;i<=n;i++){
for(int j : adj1[i]){
for(int k : adj1[j]){
if(k != i) adj2[i].pb(k);
}
}
}
int q; cin>>q;
while(q--){
int op;
cin>>op;
if(op==1){
ll x, d, w;
cin >> x >> d >> w;
if(d==0) h[x]=h[x]*w%l;
if(d==1){
h[x] = h[x]*w%l;
for(int i : adj1[x]){
h[i] = h[i]*w%l;
}
}
else if(d==2){
h[x] = h[x]*w%l;
for(int i : adj2[x]){
h[i] = h[i]*w%l;
}
}
}
else{
int x; cin>>x;
cout<<h[x]<<'\n';
}
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
11220 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
11220 KB |
Output is correct |
2 |
Correct |
331 ms |
31700 KB |
Output is correct |
3 |
Correct |
393 ms |
28472 KB |
Output is correct |
4 |
Correct |
303 ms |
25608 KB |
Output is correct |
5 |
Correct |
409 ms |
30096 KB |
Output is correct |
6 |
Correct |
363 ms |
31096 KB |
Output is correct |
7 |
Correct |
352 ms |
33212 KB |
Output is correct |
8 |
Runtime error |
1478 ms |
1048576 KB |
Execution killed with signal 9 |
9 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
11220 KB |
Output is correct |
2 |
Correct |
331 ms |
31700 KB |
Output is correct |
3 |
Correct |
393 ms |
28472 KB |
Output is correct |
4 |
Correct |
303 ms |
25608 KB |
Output is correct |
5 |
Correct |
409 ms |
30096 KB |
Output is correct |
6 |
Correct |
363 ms |
31096 KB |
Output is correct |
7 |
Correct |
352 ms |
33212 KB |
Output is correct |
8 |
Runtime error |
1478 ms |
1048576 KB |
Execution killed with signal 9 |
9 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
11220 KB |
Output is correct |
2 |
Incorrect |
298 ms |
27260 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
11188 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
11220 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |