# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
785637 | 2023-07-17T10:56:09 Z | devariaota | Sprinkler (JOI22_sprinkler) | C++17 | 4000 ms | 19884 KB |
#include <bits/stdc++.h> using namespace std; #define int long long vector<int> adj[200005]; bool vis[200005]; int arr[200005]; int n, l; int proses(int x, int d, int w) { queue<pair<int, int>> q; vector<int> v; arr[x] *= w; arr[x] %= l; vis[x] = true; v.push_back(x); for(int i = 0; i < adj[x].size(); i++) { vis[adj[x][i]] = true; v.push_back(adj[x][i]); q.push({adj[x][i], 1}); } if(d > 0) { while(q.size() > 0) { int a = q.front().first; int b = q.front().second; arr[a] *= w; arr[a] %= l; if(b < d) { for(int i = 0; i < adj[a].size(); i++) { if(vis[adj[a][i]] == false) { vis[adj[a][i]] = true; v.push_back(adj[a][i]); q.push({adj[a][i], b + 1}); } } } q.pop(); } } for(int i = 0; i < v.size(); i++) { vis[v[i]] = false; } return 0; } signed main() { ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); cin >> n >> l; for(int i = 0; i < n - 1; i++) { int a, b; cin >> a >> b; adj[a].push_back(b); adj[b].push_back(a); } for(int i = 1; i <= n; i++) { cin >> arr[i]; } int q; cin >> q; while(q--) { int a, x; cin >> a >> x; if(a == 2) { cout << arr[x] << "\n"; } else { int d, w; cin >> d >> w; int zzz = proses(x, d, w); } } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 4948 KB | Output is correct |
2 | Correct | 2 ms | 4948 KB | Output is correct |
3 | Correct | 2 ms | 4948 KB | Output is correct |
4 | Correct | 3 ms | 5076 KB | Output is correct |
5 | Correct | 5 ms | 5076 KB | Output is correct |
6 | Correct | 10 ms | 5104 KB | Output is correct |
7 | Correct | 10 ms | 5076 KB | Output is correct |
8 | Correct | 12 ms | 5076 KB | Output is correct |
9 | Correct | 2 ms | 4948 KB | Output is correct |
10 | Correct | 3 ms | 4948 KB | Output is correct |
11 | Correct | 3 ms | 4948 KB | Output is correct |
12 | Correct | 3 ms | 4948 KB | Output is correct |
13 | Correct | 3 ms | 4948 KB | Output is correct |
14 | Correct | 3 ms | 4948 KB | Output is correct |
15 | Correct | 3 ms | 4948 KB | Output is correct |
16 | Correct | 3 ms | 4948 KB | Output is correct |
17 | Correct | 3 ms | 4948 KB | Output is correct |
18 | Correct | 3 ms | 4948 KB | Output is correct |
19 | Correct | 2 ms | 4948 KB | Output is correct |
20 | Correct | 2 ms | 4948 KB | Output is correct |
21 | Correct | 2 ms | 4948 KB | Output is correct |
22 | Correct | 2 ms | 4948 KB | Output is correct |
23 | Correct | 2 ms | 4948 KB | Output is correct |
24 | Correct | 2 ms | 4948 KB | Output is correct |
25 | Correct | 2 ms | 4948 KB | Output is correct |
26 | Correct | 3 ms | 4948 KB | Output is correct |
27 | Correct | 3 ms | 4948 KB | Output is correct |
28 | Correct | 3 ms | 4948 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 4948 KB | Output is correct |
2 | Correct | 167 ms | 17580 KB | Output is correct |
3 | Correct | 261 ms | 14332 KB | Output is correct |
4 | Correct | 192 ms | 14960 KB | Output is correct |
5 | Correct | 204 ms | 15948 KB | Output is correct |
6 | Correct | 252 ms | 15940 KB | Output is correct |
7 | Correct | 242 ms | 16332 KB | Output is correct |
8 | Correct | 184 ms | 19884 KB | Output is correct |
9 | Correct | 151 ms | 16336 KB | Output is correct |
10 | Correct | 236 ms | 13588 KB | Output is correct |
11 | Correct | 172 ms | 17544 KB | Output is correct |
12 | Correct | 257 ms | 14440 KB | Output is correct |
13 | Execution timed out | 4070 ms | 19160 KB | Time limit exceeded |
14 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 4948 KB | Output is correct |
2 | Correct | 167 ms | 17580 KB | Output is correct |
3 | Correct | 261 ms | 14332 KB | Output is correct |
4 | Correct | 192 ms | 14960 KB | Output is correct |
5 | Correct | 204 ms | 15948 KB | Output is correct |
6 | Correct | 252 ms | 15940 KB | Output is correct |
7 | Correct | 242 ms | 16332 KB | Output is correct |
8 | Correct | 184 ms | 19884 KB | Output is correct |
9 | Correct | 151 ms | 16336 KB | Output is correct |
10 | Correct | 236 ms | 13588 KB | Output is correct |
11 | Correct | 172 ms | 17544 KB | Output is correct |
12 | Correct | 257 ms | 14440 KB | Output is correct |
13 | Execution timed out | 4070 ms | 19160 KB | Time limit exceeded |
14 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 4948 KB | Output is correct |
2 | Correct | 335 ms | 13900 KB | Output is correct |
3 | Correct | 1998 ms | 13568 KB | Output is correct |
4 | Correct | 690 ms | 13792 KB | Output is correct |
5 | Correct | 3898 ms | 15052 KB | Output is correct |
6 | Execution timed out | 4072 ms | 18444 KB | Time limit exceeded |
7 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 4948 KB | Output is correct |
2 | Correct | 421 ms | 16520 KB | Output is correct |
3 | Correct | 2211 ms | 14072 KB | Output is correct |
4 | Correct | 767 ms | 15504 KB | Output is correct |
5 | Execution timed out | 4067 ms | 16788 KB | Time limit exceeded |
6 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 4948 KB | Output is correct |
2 | Correct | 2 ms | 4948 KB | Output is correct |
3 | Correct | 2 ms | 4948 KB | Output is correct |
4 | Correct | 3 ms | 5076 KB | Output is correct |
5 | Correct | 5 ms | 5076 KB | Output is correct |
6 | Correct | 10 ms | 5104 KB | Output is correct |
7 | Correct | 10 ms | 5076 KB | Output is correct |
8 | Correct | 12 ms | 5076 KB | Output is correct |
9 | Correct | 2 ms | 4948 KB | Output is correct |
10 | Correct | 3 ms | 4948 KB | Output is correct |
11 | Correct | 3 ms | 4948 KB | Output is correct |
12 | Correct | 3 ms | 4948 KB | Output is correct |
13 | Correct | 3 ms | 4948 KB | Output is correct |
14 | Correct | 3 ms | 4948 KB | Output is correct |
15 | Correct | 3 ms | 4948 KB | Output is correct |
16 | Correct | 3 ms | 4948 KB | Output is correct |
17 | Correct | 3 ms | 4948 KB | Output is correct |
18 | Correct | 3 ms | 4948 KB | Output is correct |
19 | Correct | 2 ms | 4948 KB | Output is correct |
20 | Correct | 2 ms | 4948 KB | Output is correct |
21 | Correct | 2 ms | 4948 KB | Output is correct |
22 | Correct | 2 ms | 4948 KB | Output is correct |
23 | Correct | 2 ms | 4948 KB | Output is correct |
24 | Correct | 2 ms | 4948 KB | Output is correct |
25 | Correct | 2 ms | 4948 KB | Output is correct |
26 | Correct | 3 ms | 4948 KB | Output is correct |
27 | Correct | 3 ms | 4948 KB | Output is correct |
28 | Correct | 3 ms | 4948 KB | Output is correct |
29 | Correct | 2 ms | 4948 KB | Output is correct |
30 | Correct | 167 ms | 17580 KB | Output is correct |
31 | Correct | 261 ms | 14332 KB | Output is correct |
32 | Correct | 192 ms | 14960 KB | Output is correct |
33 | Correct | 204 ms | 15948 KB | Output is correct |
34 | Correct | 252 ms | 15940 KB | Output is correct |
35 | Correct | 242 ms | 16332 KB | Output is correct |
36 | Correct | 184 ms | 19884 KB | Output is correct |
37 | Correct | 151 ms | 16336 KB | Output is correct |
38 | Correct | 236 ms | 13588 KB | Output is correct |
39 | Correct | 172 ms | 17544 KB | Output is correct |
40 | Correct | 257 ms | 14440 KB | Output is correct |
41 | Execution timed out | 4070 ms | 19160 KB | Time limit exceeded |
42 | Halted | 0 ms | 0 KB | - |