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 fi first
#define se second
#define pii pair<int,int>
#define pll pair<long long, long long>
// jangan kebiasa kalah
// kalo OI, sampah aja dulu, tapi jangan menutup kemungkinan buat AC
long long n,l,tc,h[200069],level[200069],parent_node[200069],mul_par[200069];
vector<long long> adj[200069];
void dfs(long long x, long long p)
{
for(auto j : adj[x])
{
if(j == p) continue;
parent_node[j] = x;
dfs(j,x);
}
}
int main()
{
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
long long i,j;
cin>>n>>l;
for(i=1;i<n;i++)
{
long long u,v;
cin>>u>>v;
adj[u].push_back(v);
adj[v].push_back(u);
}
for(i=1;i<=n;i++)
{
mul_par[i] = 1ll;
cin>>h[i];
}
parent_node[1] = 1ll;
dfs(1,-1);
cin>>tc;
while(tc--)
{
int typ;
long long x,d,w;
cin>>typ;
if(typ == 1)
{
cin>>x>>d>>w;
if(d == 0)
{
h[x] *= w;
h[x] %= l;
}
else
{
h[x] *= w;
h[x] %= l;
for(auto it:adj[x])
{
h[it] *= w;
h[it] %= l;
}
}
}
else
{
cin>>x;
cout<<h[x]<<'\n';
}
}
}
Compilation message (stderr)
sprinkler.cpp: In function 'int main()':
sprinkler.cpp:28:17: warning: unused variable 'j' [-Wunused-variable]
28 | long long i,j;
| ^
# | 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... |