Submission #1097002

#TimeUsernameProblemLanguageResultExecution timeMemory
1097002efishelSprinkler (JOI22_sprinkler)C++17
3 / 100
4065 ms26484 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; void dfs (ll u, ll par, ll w, ll dis, ll maxD) { (ve[u] *= w) %= L; if (dis == maxD) return; for (ll v : adj[u]) { if (v == par) continue; dfs(v, u, w, dis+1, maxD); } } int main () { cin.tie(nullptr) -> sync_with_stdio(false); ll n; cin >> n >> L; 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; 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--; dfs(u, u, w, 0, maxD);} break; case '2': {ll u; cin >> u; u--; cout << ve[u] << '\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...