Submission #558474

# Submission time Handle Problem Language Result Execution time Memory
558474 2022-05-07T12:32:02 Z DanShaders Sprinkler (JOI22_sprinkler) C++17
3 / 100
4000 ms 16432 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;

namespace x = __gnu_pbds;
template <typename T>
using ordered_set = x::tree<T, x::null_type, less<T>, x::rb_tree_tag, x::tree_order_statistics_node_update>;

template <typename T>
using normal_queue = priority_queue<T, vector<T>, greater<>>;

#define all(x) begin(x), end(x)
#define sz(x) ((int) (x).size())
#define x first
#define y second
using ll = long long;
using ld = long double;

const int N = 2e5 + 10;

vector<int> g[N];
ll h[N];

signed main() {
	cin.tie(0)->sync_with_stdio(0);
	int n, l;
	cin >> n >> l;
	for (int i = 1; i < n; ++i) {
		int u, v;
		cin >> u >> v;
		g[--u].push_back(--v);
		g[v].push_back(u);
	}
	for (int i = 0; i < n; ++i) {
		cin >> h[i];
	}
	int queries;
	cin >> queries;
	while (queries--) {
		int type;
		cin >> type;
		if (type == 1) {
			int x, d, w;
			cin >> x >> d >> w;
			--x;
			queue<tuple<int, int, int>> bfs;
			bfs.push({0, x, -1});
			while (sz(bfs)) {
				auto [cd, u, p] = bfs.front();
				bfs.pop();
				(h[u] *= w) %= l;
				if (cd == d) {
					continue;
				}
				for (int v : g[u]) {
					if (v != p) {
						bfs.push({cd + 1, v, u});
					}
				}
			}
		} else {
			int x;
			cin >> x;
			cout << h[x - 1] << "\n";
		}
	}
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4948 KB Output is correct
2 Correct 3 ms 4980 KB Output is correct
3 Correct 3 ms 4948 KB Output is correct
4 Correct 4 ms 4948 KB Output is correct
5 Correct 6 ms 4948 KB Output is correct
6 Correct 12 ms 5076 KB Output is correct
7 Correct 11 ms 5076 KB Output is correct
8 Correct 11 ms 5076 KB Output is correct
9 Correct 3 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 5020 KB Output is correct
17 Correct 3 ms 4948 KB Output is correct
18 Correct 3 ms 4948 KB Output is correct
19 Correct 3 ms 4948 KB Output is correct
20 Correct 3 ms 4948 KB Output is correct
21 Correct 3 ms 4948 KB Output is correct
22 Correct 3 ms 4948 KB Output is correct
23 Correct 3 ms 4948 KB Output is correct
24 Correct 4 ms 4948 KB Output is correct
25 Correct 3 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 3 ms 4948 KB Output is correct
2 Correct 200 ms 16380 KB Output is correct
3 Correct 359 ms 13248 KB Output is correct
4 Correct 233 ms 14652 KB Output is correct
5 Correct 250 ms 14828 KB Output is correct
6 Correct 304 ms 14808 KB Output is correct
7 Correct 239 ms 15080 KB Output is correct
8 Correct 241 ms 15480 KB Output is correct
9 Correct 228 ms 16196 KB Output is correct
10 Correct 301 ms 13120 KB Output is correct
11 Correct 199 ms 16340 KB Output is correct
12 Correct 368 ms 13304 KB Output is correct
13 Execution timed out 4075 ms 15924 KB Time limit exceeded
14 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4948 KB Output is correct
2 Correct 200 ms 16380 KB Output is correct
3 Correct 359 ms 13248 KB Output is correct
4 Correct 233 ms 14652 KB Output is correct
5 Correct 250 ms 14828 KB Output is correct
6 Correct 304 ms 14808 KB Output is correct
7 Correct 239 ms 15080 KB Output is correct
8 Correct 241 ms 15480 KB Output is correct
9 Correct 228 ms 16196 KB Output is correct
10 Correct 301 ms 13120 KB Output is correct
11 Correct 199 ms 16340 KB Output is correct
12 Correct 368 ms 13304 KB Output is correct
13 Execution timed out 4075 ms 15924 KB Time limit exceeded
14 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4948 KB Output is correct
2 Correct 512 ms 13648 KB Output is correct
3 Correct 2857 ms 13028 KB Output is correct
4 Correct 948 ms 13304 KB Output is correct
5 Execution timed out 4080 ms 13464 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 4948 KB Output is correct
2 Correct 542 ms 16432 KB Output is correct
3 Correct 2756 ms 13420 KB Output is correct
4 Correct 967 ms 14600 KB Output is correct
5 Execution timed out 4065 ms 14564 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4948 KB Output is correct
2 Correct 3 ms 4980 KB Output is correct
3 Correct 3 ms 4948 KB Output is correct
4 Correct 4 ms 4948 KB Output is correct
5 Correct 6 ms 4948 KB Output is correct
6 Correct 12 ms 5076 KB Output is correct
7 Correct 11 ms 5076 KB Output is correct
8 Correct 11 ms 5076 KB Output is correct
9 Correct 3 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 5020 KB Output is correct
17 Correct 3 ms 4948 KB Output is correct
18 Correct 3 ms 4948 KB Output is correct
19 Correct 3 ms 4948 KB Output is correct
20 Correct 3 ms 4948 KB Output is correct
21 Correct 3 ms 4948 KB Output is correct
22 Correct 3 ms 4948 KB Output is correct
23 Correct 3 ms 4948 KB Output is correct
24 Correct 4 ms 4948 KB Output is correct
25 Correct 3 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 3 ms 4948 KB Output is correct
30 Correct 200 ms 16380 KB Output is correct
31 Correct 359 ms 13248 KB Output is correct
32 Correct 233 ms 14652 KB Output is correct
33 Correct 250 ms 14828 KB Output is correct
34 Correct 304 ms 14808 KB Output is correct
35 Correct 239 ms 15080 KB Output is correct
36 Correct 241 ms 15480 KB Output is correct
37 Correct 228 ms 16196 KB Output is correct
38 Correct 301 ms 13120 KB Output is correct
39 Correct 199 ms 16340 KB Output is correct
40 Correct 368 ms 13304 KB Output is correct
41 Execution timed out 4075 ms 15924 KB Time limit exceeded
42 Halted 0 ms 0 KB -