Submission #1097004

#TimeUsernameProblemLanguageResultExecution timeMemory
1097004efishelSprinkler (JOI22_sprinkler)C++17
9 / 100
204 ms33184 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; using vll = vector <ll>; using ii = pair <ll, ll>; using vii = vector <ii>; const ll MAXN = 2E5+16; vll adj[MAXN]; ll L; vll ve; ll par[MAXN]; ll src[MAXN]; void dfs (ll u, ll par) { ::par[u] = par; for (ll v : adj[u]) { if (v == par) continue; dfs(v, u); } } int main () { cin.tie(nullptr) -> sync_with_stdio(false); ll n; cin >> n >> L; fill(src, src+n, 1); for (ll i = 1; i < n; i++) { ll u, v; cin >> u >> v; u--; v--; adj[u].push_back(v); adj[v].push_back(u); } ve = vll(n); for (ll &i : ve) cin >> i; dfs(0, 0); ll Q; cin >> Q; for (ll q = 0; q < Q; q++) { char type; cin >> type; switch (type) { case '1': {ll u, maxD, w; cin >> u >> maxD >> w; u--; if (maxD == 0) { (ve[u] *= w) %= L; } else { if (u) (ve[par[u]] *= w) %= L; (ve[u] *= w) %= L; (src[u] *= w) %= L; } break;} case '2': {ll u; cin >> u; u--; ll ans = ve[u]; if (u) (ans *= src[par[u]]) %= L; cout << ans << '\n'; break;} } } 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...