Submission #785346

#TimeUsernameProblemLanguageResultExecution timeMemory
785346makanhuliaSprinkler (JOI22_sprinkler)C++17
3 / 100
4083 ms41152 KiB
#include <bits/stdc++.h> #define int long long #define fi first #define se second #define keish ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0) using namespace std; int n, l, q, u, v, t, x, d, w, lim; vector<int> con[1005][1005]; signed main(){ keish; cin >> n >> l; vector<vector<int>> e(n); for(int i = 1; i < n; i++){ cin >> u >> v; u--, v--; e[u].push_back(v); e[v].push_back(u); } vector<int> a(n); for(auto &x : a) cin >> x; function<void(int, int, int)> dfs = [&](int u, int p, int d){ if(d > lim) return; for(auto v : e[u]){ if(v == p) continue; (a[v] *= w) %= l; dfs(v, u, d + 1); } }; cin >> q; while(q--){ cin >> t; if(t == 1){ cin >> x >> lim >> w; x--; (a[x] *= w) %= l; dfs(x, -1, 1); }else{ cin >> x; x--; cout << a[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...