| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1369600 | SpyrosAliv | Sprinkler (JOI22_sprinkler) | C++20 | 2 ms | 344 KiB |
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MN = 1e3+5;
int n, l, q;
vector<vector<int>> tree(MN);
int h[MN];
void dfs(int node, int d, int w, int prev = 0) {
h[node] = (h[node] * w) % l;
if (d == 0) return;
for (auto next: tree[node]) {
if (next == prev) continue;
dfs(next, d-1, w, node);
}
}
void solve() {
cin >> n >> l;
for (int i = 1; i < n; i++) {
int u, v; cin >> u >> v;
tree[u].push_back(v);
tree[v].push_back(u);
}
for (int i = 1; i <= n; i++) cin >> h[i];
cin >> q;
while (q--) {
int t; cin >> t;
if (t == 1) {
int x, d, w; cin >> x >> d >> w;
dfs(x, d, w);
}
else if (t == 2) {
int x; cin >> x;
cout << h[x] << "\n";
}
}
}
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
solve();
return 0;
}| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
