Submission #785206

#TimeUsernameProblemLanguageResultExecution timeMemory
785206devariaotaSprinkler (JOI22_sprinkler)C++17
3 / 100
4077 ms26280 KiB
#include<bits/stdc++.h> #define int long long using namespace std; int n, l, d, w; vector<int> h; vector<vector<int>> adj; void dfs(int u, int p=-1, int H=0) { if(H>d) return; h[u]=(h[u]*w)%l; for(int pp : adj[u]) { if(pp==p) continue; dfs(pp, u, H+1); } } signed main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> l; adj.resize(n); h.resize(n); for(int i=1; i<n; i++) { int u, v; cin >> u >> v; --u; --v; adj[u].push_back(v); adj[v].push_back(u); } for(int &p : h) cin >> p; int q; cin >> q; while(q--) { int type, x; cin >> type >> x; --x; if(type==1) cin >> d >> w, dfs(x); else cout << h[x] << '\n'; } return 0; }
#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...