# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
892785 | 2023-12-26T00:16:36 Z | fanwen | Sprinkler (JOI22_sprinkler) | C++17 | 4000 ms | 20296 KB |
#include <bits/stdc++.h> using namespace std; #define fi first #define se second #define ll long long #define file(name) \ if(fopen(name".inp", "r")) \ freopen(name".inp", "r", stdin), freopen(name".out", "w", stdout); const int MAX = 2e5 + 5; const int MAXD = 41; int n, L, q, h[MAX]; vector <int> adj[MAX]; void MUL(int &x, int y) { x = 1LL * x * y % L; } void dfs(int u, int p, int val, int d) { MUL(h[u], val); if(d <= 0) return; for (int v : adj[u]) if(v != p) dfs(v, u, val, d - 1); } void you_make_it(void) { cin >> n >> L; for (int i = 1; i < n; ++i) { int u, v; cin >> u >> v; adj[u].push_back(v); adj[v].push_back(u); } for (int i = 1; i <= n; ++i) cin >> h[i]; cin >> q; while(q--) { int type; cin >> type; if(type == 1) { int u, d, w; cin >> u >> d >> w; dfs(u, 0, w, d); } else { int u; cin >> u; cout << h[u] << '\n'; } } } signed main() { #ifdef LOCAL freopen("TASK.inp", "r", stdin); freopen("TASK.out", "w", stdout); #endif file("sprinkler"); auto start_time = chrono::steady_clock::now(); cin.tie(0), cout.tie(0) -> sync_with_stdio(0); you_make_it(); auto end_time = chrono::steady_clock::now(); cerr << "\nExecution time : " << chrono::duration_cast <chrono::milliseconds> (end_time - start_time).count() << "[ms]" << endl; return (0 ^ 0); } // Dream it. Wish it. Do it.
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 4952 KB | Output is correct |
2 | Correct | 1 ms | 4956 KB | Output is correct |
3 | Correct | 1 ms | 4956 KB | Output is correct |
4 | Correct | 2 ms | 5208 KB | Output is correct |
5 | Correct | 3 ms | 5232 KB | Output is correct |
6 | Correct | 5 ms | 5212 KB | Output is correct |
7 | Correct | 5 ms | 5212 KB | Output is correct |
8 | Correct | 5 ms | 5208 KB | Output is correct |
9 | Correct | 2 ms | 4956 KB | Output is correct |
10 | Correct | 1 ms | 5164 KB | Output is correct |
11 | Correct | 1 ms | 4956 KB | Output is correct |
12 | Correct | 1 ms | 4956 KB | Output is correct |
13 | Correct | 2 ms | 4956 KB | Output is correct |
14 | Correct | 2 ms | 4952 KB | Output is correct |
15 | Correct | 2 ms | 4956 KB | Output is correct |
16 | Correct | 1 ms | 4956 KB | Output is correct |
17 | Correct | 1 ms | 4956 KB | Output is correct |
18 | Correct | 1 ms | 4956 KB | Output is correct |
19 | Correct | 1 ms | 4956 KB | Output is correct |
20 | Correct | 1 ms | 4956 KB | Output is correct |
21 | Correct | 1 ms | 4956 KB | Output is correct |
22 | Correct | 1 ms | 4956 KB | Output is correct |
23 | Correct | 1 ms | 4956 KB | Output is correct |
24 | Correct | 1 ms | 4956 KB | Output is correct |
25 | Correct | 2 ms | 4956 KB | Output is correct |
26 | Correct | 1 ms | 4956 KB | Output is correct |
27 | Correct | 1 ms | 4956 KB | Output is correct |
28 | Correct | 1 ms | 4956 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 4952 KB | Output is correct |
2 | Correct | 152 ms | 20160 KB | Output is correct |
3 | Correct | 196 ms | 18772 KB | Output is correct |
4 | Correct | 153 ms | 19128 KB | Output is correct |
5 | Correct | 151 ms | 19540 KB | Output is correct |
6 | Correct | 164 ms | 19200 KB | Output is correct |
7 | Correct | 161 ms | 19688 KB | Output is correct |
8 | Correct | 144 ms | 20296 KB | Output is correct |
9 | Correct | 137 ms | 19796 KB | Output is correct |
10 | Correct | 172 ms | 18512 KB | Output is correct |
11 | Correct | 135 ms | 20068 KB | Output is correct |
12 | Correct | 179 ms | 19024 KB | Output is correct |
13 | Execution timed out | 4046 ms | 16212 KB | Time limit exceeded |
14 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 4952 KB | Output is correct |
2 | Correct | 152 ms | 20160 KB | Output is correct |
3 | Correct | 196 ms | 18772 KB | Output is correct |
4 | Correct | 153 ms | 19128 KB | Output is correct |
5 | Correct | 151 ms | 19540 KB | Output is correct |
6 | Correct | 164 ms | 19200 KB | Output is correct |
7 | Correct | 161 ms | 19688 KB | Output is correct |
8 | Correct | 144 ms | 20296 KB | Output is correct |
9 | Correct | 137 ms | 19796 KB | Output is correct |
10 | Correct | 172 ms | 18512 KB | Output is correct |
11 | Correct | 135 ms | 20068 KB | Output is correct |
12 | Correct | 179 ms | 19024 KB | Output is correct |
13 | Execution timed out | 4046 ms | 16212 KB | Time limit exceeded |
14 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 4956 KB | Output is correct |
2 | Correct | 330 ms | 17228 KB | Output is correct |
3 | Correct | 1527 ms | 17468 KB | Output is correct |
4 | Correct | 557 ms | 17492 KB | Output is correct |
5 | Correct | 2654 ms | 17748 KB | Output is correct |
6 | Execution timed out | 4091 ms | 16908 KB | Time limit exceeded |
7 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 4952 KB | Output is correct |
2 | Correct | 270 ms | 20104 KB | Output is correct |
3 | Correct | 1345 ms | 18064 KB | Output is correct |
4 | Correct | 450 ms | 18896 KB | Output is correct |
5 | Correct | 2206 ms | 19704 KB | Output is correct |
6 | Execution timed out | 4027 ms | 15216 KB | Time limit exceeded |
7 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 4952 KB | Output is correct |
2 | Correct | 1 ms | 4956 KB | Output is correct |
3 | Correct | 1 ms | 4956 KB | Output is correct |
4 | Correct | 2 ms | 5208 KB | Output is correct |
5 | Correct | 3 ms | 5232 KB | Output is correct |
6 | Correct | 5 ms | 5212 KB | Output is correct |
7 | Correct | 5 ms | 5212 KB | Output is correct |
8 | Correct | 5 ms | 5208 KB | Output is correct |
9 | Correct | 2 ms | 4956 KB | Output is correct |
10 | Correct | 1 ms | 5164 KB | Output is correct |
11 | Correct | 1 ms | 4956 KB | Output is correct |
12 | Correct | 1 ms | 4956 KB | Output is correct |
13 | Correct | 2 ms | 4956 KB | Output is correct |
14 | Correct | 2 ms | 4952 KB | Output is correct |
15 | Correct | 2 ms | 4956 KB | Output is correct |
16 | Correct | 1 ms | 4956 KB | Output is correct |
17 | Correct | 1 ms | 4956 KB | Output is correct |
18 | Correct | 1 ms | 4956 KB | Output is correct |
19 | Correct | 1 ms | 4956 KB | Output is correct |
20 | Correct | 1 ms | 4956 KB | Output is correct |
21 | Correct | 1 ms | 4956 KB | Output is correct |
22 | Correct | 1 ms | 4956 KB | Output is correct |
23 | Correct | 1 ms | 4956 KB | Output is correct |
24 | Correct | 1 ms | 4956 KB | Output is correct |
25 | Correct | 2 ms | 4956 KB | Output is correct |
26 | Correct | 1 ms | 4956 KB | Output is correct |
27 | Correct | 1 ms | 4956 KB | Output is correct |
28 | Correct | 1 ms | 4956 KB | Output is correct |
29 | Correct | 1 ms | 4952 KB | Output is correct |
30 | Correct | 152 ms | 20160 KB | Output is correct |
31 | Correct | 196 ms | 18772 KB | Output is correct |
32 | Correct | 153 ms | 19128 KB | Output is correct |
33 | Correct | 151 ms | 19540 KB | Output is correct |
34 | Correct | 164 ms | 19200 KB | Output is correct |
35 | Correct | 161 ms | 19688 KB | Output is correct |
36 | Correct | 144 ms | 20296 KB | Output is correct |
37 | Correct | 137 ms | 19796 KB | Output is correct |
38 | Correct | 172 ms | 18512 KB | Output is correct |
39 | Correct | 135 ms | 20068 KB | Output is correct |
40 | Correct | 179 ms | 19024 KB | Output is correct |
41 | Execution timed out | 4046 ms | 16212 KB | Time limit exceeded |
42 | Halted | 0 ms | 0 KB | - |