Submission #1019727

#TimeUsernameProblemLanguageResultExecution timeMemory
1019727UnforgettableplSprinkler (JOI22_sprinkler)C++17
3 / 100
4090 ms26568 KiB
#include <bits/stdc++.h> using namespace std; #define int long long int32_t main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); int n,l; cin >> n >> l; vector<vector<int>> adj(n+1); for(int i=1;i<n;i++){ int a,b;cin>>a>>b; adj[a].emplace_back(b); adj[b].emplace_back(a); } vector<int> H(n+1); for(int i=1;i<=n;i++)cin>>H[i]; function<void(int,int,int,int)> dfs = [&](int x,int p,int range,int w){ H[x]=(H[x]*w)%l; if(range==0)return; for(int&i:adj[x])if(i!=p)dfs(i,x,range-1,w); }; int q; cin >> q; for(int i=1;i<=q;i++){ int type;cin>>type; if(type==1){ int x,d,w;cin>>x>>d>>w; dfs(x,0,d,w); } else { int x;cin>>x; cout << H[x] << '\n'; } } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...