This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define ll long long
#define f first
#define s second
#define pii pair <int,int>
#define en '\n'
void boos() {
ios_base :: sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
}
const int N = 2e5 + 100;
vector <int> g[N];
ll a[N],L;
int n;
void dfs(int v,int p,int d,ll val) {
a[v] = (a[v] * val) % L;
if(d == 0)return;
for(auto to : g[v]) {
if(to == p)continue;
dfs(to,v,d - 1,val);
}
}
void solve() {
cin >> n >> L;
for(int i = 1;i < n;i++) {
int x,y;
cin >> x >> y;
g[x].pb(y);
g[y].pb(x);
}
for(int i = 1;i <= n;i++)cin >> a[i];
int q;
cin >> q;
for(int i = 1;i <= q;i++) {
int typ;
cin >> typ;
if(typ == 1) {
int x,d;
ll w;
cin >> x >> d >> w;
dfs(x,-1,d,w);
}else {
int x;
cin >> x;
cout << a[x] << en;
}
}
}
int main() {
boos();
int ttt;
ttt = 1;
while(ttt--) {
solve();
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |