Submission #896782

# Submission time Handle Problem Language Result Execution time Memory
896782 2024-01-02T06:30:08 Z TAhmed33 Sprinkler (JOI22_sprinkler) C++
3 / 100
4000 ms 25052 KB
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 25;
int n, l, h[MAXN];
vector <int> adj[MAXN];
void dfs (int pos, int par, int dep, int d, int w) {
	h[pos] = (h[pos] * 1ll * w) % l;
	if (dep == d) return;
	for (auto j : adj[pos]) if (j != par) dfs(j, pos, dep + 1, d, w);
}
int main () {
	cin >> n >> l;
	for (int i = 1; i < n; 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 >> h[i];
	int q;
	cin >> q;
	while (q--) {
		int t;
		cin >> t;
		if (t == 1) {
			int x, d, w;
			cin >> x >> d >> w;
			dfs(x, -1, 0, d, w);
		} else {
			int x;
			cin >> x;
			cout << h[x] << '\n';
		}
	}
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4956 KB Output is correct
2 Correct 2 ms 4956 KB Output is correct
3 Correct 1 ms 4956 KB Output is correct
4 Correct 4 ms 5212 KB Output is correct
5 Correct 4 ms 5208 KB Output is correct
6 Correct 6 ms 5220 KB Output is correct
7 Correct 7 ms 5208 KB Output is correct
8 Correct 7 ms 5212 KB Output is correct
9 Correct 3 ms 4956 KB Output is correct
10 Correct 3 ms 4968 KB Output is correct
11 Correct 2 ms 4956 KB Output is correct
12 Correct 2 ms 4956 KB Output is correct
13 Correct 2 ms 4956 KB Output is correct
14 Correct 2 ms 4956 KB Output is correct
15 Correct 3 ms 4964 KB Output is correct
16 Correct 2 ms 4956 KB Output is correct
17 Correct 3 ms 4956 KB Output is correct
18 Correct 2 ms 4956 KB Output is correct
19 Correct 2 ms 4956 KB Output is correct
20 Correct 2 ms 4956 KB Output is correct
21 Correct 2 ms 4956 KB Output is correct
22 Correct 2 ms 4956 KB Output is correct
23 Correct 2 ms 4956 KB Output is correct
24 Correct 2 ms 4956 KB Output is correct
25 Correct 2 ms 4956 KB Output is correct
26 Correct 2 ms 4952 KB Output is correct
27 Correct 2 ms 4956 KB Output is correct
28 Correct 3 ms 5024 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4956 KB Output is correct
2 Correct 747 ms 24028 KB Output is correct
3 Correct 513 ms 24356 KB Output is correct
4 Correct 627 ms 24004 KB Output is correct
5 Correct 631 ms 24592 KB Output is correct
6 Correct 640 ms 23636 KB Output is correct
7 Correct 614 ms 24400 KB Output is correct
8 Correct 654 ms 25052 KB Output is correct
9 Correct 750 ms 23680 KB Output is correct
10 Correct 512 ms 24312 KB Output is correct
11 Correct 792 ms 23824 KB Output is correct
12 Correct 523 ms 24400 KB Output is correct
13 Execution timed out 4038 ms 17360 KB Time limit exceeded
14 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4956 KB Output is correct
2 Correct 747 ms 24028 KB Output is correct
3 Correct 513 ms 24356 KB Output is correct
4 Correct 627 ms 24004 KB Output is correct
5 Correct 631 ms 24592 KB Output is correct
6 Correct 640 ms 23636 KB Output is correct
7 Correct 614 ms 24400 KB Output is correct
8 Correct 654 ms 25052 KB Output is correct
9 Correct 750 ms 23680 KB Output is correct
10 Correct 512 ms 24312 KB Output is correct
11 Correct 792 ms 23824 KB Output is correct
12 Correct 523 ms 24400 KB Output is correct
13 Execution timed out 4038 ms 17360 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 1016 ms 21180 KB Output is correct
3 Correct 1942 ms 22104 KB Output is correct
4 Correct 1042 ms 21016 KB Output is correct
5 Correct 3220 ms 21160 KB Output is correct
6 Execution timed out 4033 ms 16884 KB Time limit exceeded
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4956 KB Output is correct
2 Correct 1040 ms 23660 KB Output is correct
3 Correct 2254 ms 22100 KB Output is correct
4 Correct 1137 ms 22536 KB Output is correct
5 Correct 3316 ms 23200 KB Output is correct
6 Execution timed out 4051 ms 17244 KB Time limit exceeded
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4956 KB Output is correct
2 Correct 2 ms 4956 KB Output is correct
3 Correct 1 ms 4956 KB Output is correct
4 Correct 4 ms 5212 KB Output is correct
5 Correct 4 ms 5208 KB Output is correct
6 Correct 6 ms 5220 KB Output is correct
7 Correct 7 ms 5208 KB Output is correct
8 Correct 7 ms 5212 KB Output is correct
9 Correct 3 ms 4956 KB Output is correct
10 Correct 3 ms 4968 KB Output is correct
11 Correct 2 ms 4956 KB Output is correct
12 Correct 2 ms 4956 KB Output is correct
13 Correct 2 ms 4956 KB Output is correct
14 Correct 2 ms 4956 KB Output is correct
15 Correct 3 ms 4964 KB Output is correct
16 Correct 2 ms 4956 KB Output is correct
17 Correct 3 ms 4956 KB Output is correct
18 Correct 2 ms 4956 KB Output is correct
19 Correct 2 ms 4956 KB Output is correct
20 Correct 2 ms 4956 KB Output is correct
21 Correct 2 ms 4956 KB Output is correct
22 Correct 2 ms 4956 KB Output is correct
23 Correct 2 ms 4956 KB Output is correct
24 Correct 2 ms 4956 KB Output is correct
25 Correct 2 ms 4956 KB Output is correct
26 Correct 2 ms 4952 KB Output is correct
27 Correct 2 ms 4956 KB Output is correct
28 Correct 3 ms 5024 KB Output is correct
29 Correct 2 ms 4956 KB Output is correct
30 Correct 747 ms 24028 KB Output is correct
31 Correct 513 ms 24356 KB Output is correct
32 Correct 627 ms 24004 KB Output is correct
33 Correct 631 ms 24592 KB Output is correct
34 Correct 640 ms 23636 KB Output is correct
35 Correct 614 ms 24400 KB Output is correct
36 Correct 654 ms 25052 KB Output is correct
37 Correct 750 ms 23680 KB Output is correct
38 Correct 512 ms 24312 KB Output is correct
39 Correct 792 ms 23824 KB Output is correct
40 Correct 523 ms 24400 KB Output is correct
41 Execution timed out 4038 ms 17360 KB Time limit exceeded
42 Halted 0 ms 0 KB -