#include <bits/stdc++.h>
#define int long long
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define pb push_back
using namespace std;
const int N=1e5+5;
vector <int> g[N];
int h[N];
signed main(){
int n,l;
cin>>n>>l;
for(int i=0;i<n-1;i++){
int u,v;
cin>>u>>v;
g[u].pb(v);
g[v].pb(u);
}
for(int i=1;i<=n;i++){
cin>>h[i];
}
int q;
cin>>q;
while(q--){
int type,x,d,w;
cin>>type;
if(type==1){
cin>>x>>d>>w;
queue <int> q;
vector <int> dis(n+1,-1);
q.push(x);
dis[x]=0;
while(!q.empty()){
int v=q.front();
q.pop();
for(auto to : g[v]){
if(dis[to]==-1){
dis[to]=dis[v]+1;
q.push(to);
}
}
}
for(int i=1;i<=n;i++){
if(dis[i]<=d){
h[i]=(h[i]*w)%l;
}
}
}
else{
cin>>x;
cout<<h[x]<<"\n";
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
3164 KB |
Output is correct |
2 |
Correct |
1 ms |
3164 KB |
Output is correct |
3 |
Correct |
1 ms |
3168 KB |
Output is correct |
4 |
Correct |
9 ms |
3420 KB |
Output is correct |
5 |
Correct |
10 ms |
3452 KB |
Output is correct |
6 |
Correct |
11 ms |
3416 KB |
Output is correct |
7 |
Correct |
10 ms |
3420 KB |
Output is correct |
8 |
Correct |
9 ms |
3416 KB |
Output is correct |
9 |
Correct |
2 ms |
3164 KB |
Output is correct |
10 |
Correct |
2 ms |
3164 KB |
Output is correct |
11 |
Correct |
2 ms |
3164 KB |
Output is correct |
12 |
Correct |
2 ms |
3164 KB |
Output is correct |
13 |
Correct |
2 ms |
3164 KB |
Output is correct |
14 |
Correct |
2 ms |
3164 KB |
Output is correct |
15 |
Correct |
3 ms |
3164 KB |
Output is correct |
16 |
Correct |
2 ms |
3164 KB |
Output is correct |
17 |
Correct |
2 ms |
3164 KB |
Output is correct |
18 |
Correct |
2 ms |
3164 KB |
Output is correct |
19 |
Correct |
2 ms |
3164 KB |
Output is correct |
20 |
Correct |
2 ms |
3164 KB |
Output is correct |
21 |
Correct |
2 ms |
3164 KB |
Output is correct |
22 |
Correct |
2 ms |
3164 KB |
Output is correct |
23 |
Correct |
2 ms |
3164 KB |
Output is correct |
24 |
Correct |
2 ms |
3164 KB |
Output is correct |
25 |
Correct |
2 ms |
3164 KB |
Output is correct |
26 |
Correct |
2 ms |
3164 KB |
Output is correct |
27 |
Correct |
2 ms |
3164 KB |
Output is correct |
28 |
Correct |
2 ms |
3164 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
3160 KB |
Output is correct |
2 |
Runtime error |
4 ms |
6492 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
3160 KB |
Output is correct |
2 |
Runtime error |
4 ms |
6492 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
3164 KB |
Output is correct |
2 |
Runtime error |
3 ms |
6492 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
3164 KB |
Output is correct |
2 |
Runtime error |
3 ms |
6492 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
3164 KB |
Output is correct |
2 |
Correct |
1 ms |
3164 KB |
Output is correct |
3 |
Correct |
1 ms |
3168 KB |
Output is correct |
4 |
Correct |
9 ms |
3420 KB |
Output is correct |
5 |
Correct |
10 ms |
3452 KB |
Output is correct |
6 |
Correct |
11 ms |
3416 KB |
Output is correct |
7 |
Correct |
10 ms |
3420 KB |
Output is correct |
8 |
Correct |
9 ms |
3416 KB |
Output is correct |
9 |
Correct |
2 ms |
3164 KB |
Output is correct |
10 |
Correct |
2 ms |
3164 KB |
Output is correct |
11 |
Correct |
2 ms |
3164 KB |
Output is correct |
12 |
Correct |
2 ms |
3164 KB |
Output is correct |
13 |
Correct |
2 ms |
3164 KB |
Output is correct |
14 |
Correct |
2 ms |
3164 KB |
Output is correct |
15 |
Correct |
3 ms |
3164 KB |
Output is correct |
16 |
Correct |
2 ms |
3164 KB |
Output is correct |
17 |
Correct |
2 ms |
3164 KB |
Output is correct |
18 |
Correct |
2 ms |
3164 KB |
Output is correct |
19 |
Correct |
2 ms |
3164 KB |
Output is correct |
20 |
Correct |
2 ms |
3164 KB |
Output is correct |
21 |
Correct |
2 ms |
3164 KB |
Output is correct |
22 |
Correct |
2 ms |
3164 KB |
Output is correct |
23 |
Correct |
2 ms |
3164 KB |
Output is correct |
24 |
Correct |
2 ms |
3164 KB |
Output is correct |
25 |
Correct |
2 ms |
3164 KB |
Output is correct |
26 |
Correct |
2 ms |
3164 KB |
Output is correct |
27 |
Correct |
2 ms |
3164 KB |
Output is correct |
28 |
Correct |
2 ms |
3164 KB |
Output is correct |
29 |
Correct |
1 ms |
3160 KB |
Output is correct |
30 |
Runtime error |
4 ms |
6492 KB |
Execution killed with signal 11 |
31 |
Halted |
0 ms |
0 KB |
- |