#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define pb push_back
const int sez = 2e5+5;
ll n,l;
vector<int> adj1[sez], adj2[sez];
vector<ll> h(sez);
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);
// }
// }
// }
// for(int i=1;i<=n;i++){ // cek aja
// cout<<"::"<<i<<" = ";
// for(int j: adj2[i]){
// cout<<j<<' ';
// }
// cout<<'\n';
// }
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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
11220 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
11220 KB |
Output is correct |
2 |
Correct |
229 ms |
27392 KB |
Output is correct |
3 |
Correct |
268 ms |
24300 KB |
Output is correct |
4 |
Correct |
243 ms |
25628 KB |
Output is correct |
5 |
Correct |
241 ms |
25904 KB |
Output is correct |
6 |
Correct |
233 ms |
25928 KB |
Output is correct |
7 |
Correct |
246 ms |
26420 KB |
Output is correct |
8 |
Correct |
202 ms |
27424 KB |
Output is correct |
9 |
Correct |
241 ms |
27272 KB |
Output is correct |
10 |
Correct |
278 ms |
24236 KB |
Output is correct |
11 |
Correct |
223 ms |
27500 KB |
Output is correct |
12 |
Correct |
309 ms |
24348 KB |
Output is correct |
13 |
Execution timed out |
4061 ms |
25344 KB |
Time limit exceeded |
14 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
11220 KB |
Output is correct |
2 |
Correct |
229 ms |
27392 KB |
Output is correct |
3 |
Correct |
268 ms |
24300 KB |
Output is correct |
4 |
Correct |
243 ms |
25628 KB |
Output is correct |
5 |
Correct |
241 ms |
25904 KB |
Output is correct |
6 |
Correct |
233 ms |
25928 KB |
Output is correct |
7 |
Correct |
246 ms |
26420 KB |
Output is correct |
8 |
Correct |
202 ms |
27424 KB |
Output is correct |
9 |
Correct |
241 ms |
27272 KB |
Output is correct |
10 |
Correct |
278 ms |
24236 KB |
Output is correct |
11 |
Correct |
223 ms |
27500 KB |
Output is correct |
12 |
Correct |
309 ms |
24348 KB |
Output is correct |
13 |
Execution timed out |
4061 ms |
25344 KB |
Time limit exceeded |
14 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
11220 KB |
Output is correct |
2 |
Incorrect |
209 ms |
27276 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
11220 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
11220 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |