답안 #890632

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
890632 2023-12-21T17:17:59 Z MinaRagy06 Sprinkler (JOI22_sprinkler) C++17
3 / 100
4000 ms 24572 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long

const int N = 200'005;
vector<int> adj[N];
int mod;
int a[N];
void dfs(int i, int mx, int w, int d = 0, int par = 0) {
	a[i] = 1ll * a[i] * w % mod;
	for (auto nxt : adj[i]) {
		if (nxt == par || d + 1 > mx) continue;
		dfs(nxt, mx, w, d + 1, i);
	}
}
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0);
	int n;
	cin >> n >> mod;
	for (int i = 1, u, v; i < n; i++) {
		cin >> u >> v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	int m;
	cin >> m;
	while (m--) {
		int t;
		cin >> t;
		if (t == 1) {
			int x, d, w;
			cin >> x >> d >> w;
			dfs(x, d, w);
		} else {
			int x;
			cin >> x;
			cout << a[x] << '\n';
		}
	}
	return 0;
}

# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 5724 KB Output is correct
2 Correct 1 ms 5724 KB Output is correct
3 Correct 4 ms 5724 KB Output is correct
4 Correct 2 ms 5724 KB Output is correct
5 Correct 3 ms 5724 KB Output is correct
6 Correct 5 ms 5724 KB Output is correct
7 Correct 6 ms 5724 KB Output is correct
8 Correct 7 ms 5724 KB Output is correct
9 Correct 2 ms 5724 KB Output is correct
10 Correct 2 ms 5724 KB Output is correct
11 Correct 2 ms 5724 KB Output is correct
12 Correct 2 ms 5724 KB Output is correct
13 Correct 2 ms 5724 KB Output is correct
14 Correct 2 ms 5760 KB Output is correct
15 Correct 2 ms 5720 KB Output is correct
16 Correct 2 ms 5724 KB Output is correct
17 Correct 2 ms 5724 KB Output is correct
18 Correct 2 ms 5724 KB Output is correct
19 Correct 2 ms 5724 KB Output is correct
20 Correct 2 ms 5724 KB Output is correct
21 Correct 2 ms 5720 KB Output is correct
22 Correct 2 ms 5724 KB Output is correct
23 Correct 2 ms 5724 KB Output is correct
24 Correct 2 ms 5976 KB Output is correct
25 Correct 2 ms 5724 KB Output is correct
26 Correct 2 ms 5724 KB Output is correct
27 Correct 2 ms 5724 KB Output is correct
28 Correct 2 ms 5724 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 5724 KB Output is correct
2 Correct 161 ms 23892 KB Output is correct
3 Correct 280 ms 24468 KB Output is correct
4 Correct 189 ms 23960 KB Output is correct
5 Correct 179 ms 24244 KB Output is correct
6 Correct 214 ms 23636 KB Output is correct
7 Correct 191 ms 24572 KB Output is correct
8 Execution timed out 4059 ms 19784 KB Time limit exceeded
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 5724 KB Output is correct
2 Correct 161 ms 23892 KB Output is correct
3 Correct 280 ms 24468 KB Output is correct
4 Correct 189 ms 23960 KB Output is correct
5 Correct 179 ms 24244 KB Output is correct
6 Correct 214 ms 23636 KB Output is correct
7 Correct 191 ms 24572 KB Output is correct
8 Execution timed out 4059 ms 19784 KB Time limit exceeded
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 5724 KB Output is correct
2 Correct 321 ms 21072 KB Output is correct
3 Correct 1736 ms 21524 KB Output is correct
4 Correct 707 ms 21384 KB Output is correct
5 Correct 3546 ms 21228 KB Output is correct
6 Execution timed out 4043 ms 16740 KB Time limit exceeded
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 5724 KB Output is correct
2 Correct 334 ms 23468 KB Output is correct
3 Correct 1677 ms 22136 KB Output is correct
4 Correct 625 ms 22860 KB Output is correct
5 Correct 2963 ms 22956 KB Output is correct
6 Execution timed out 4041 ms 17244 KB Time limit exceeded
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 5724 KB Output is correct
2 Correct 1 ms 5724 KB Output is correct
3 Correct 4 ms 5724 KB Output is correct
4 Correct 2 ms 5724 KB Output is correct
5 Correct 3 ms 5724 KB Output is correct
6 Correct 5 ms 5724 KB Output is correct
7 Correct 6 ms 5724 KB Output is correct
8 Correct 7 ms 5724 KB Output is correct
9 Correct 2 ms 5724 KB Output is correct
10 Correct 2 ms 5724 KB Output is correct
11 Correct 2 ms 5724 KB Output is correct
12 Correct 2 ms 5724 KB Output is correct
13 Correct 2 ms 5724 KB Output is correct
14 Correct 2 ms 5760 KB Output is correct
15 Correct 2 ms 5720 KB Output is correct
16 Correct 2 ms 5724 KB Output is correct
17 Correct 2 ms 5724 KB Output is correct
18 Correct 2 ms 5724 KB Output is correct
19 Correct 2 ms 5724 KB Output is correct
20 Correct 2 ms 5724 KB Output is correct
21 Correct 2 ms 5720 KB Output is correct
22 Correct 2 ms 5724 KB Output is correct
23 Correct 2 ms 5724 KB Output is correct
24 Correct 2 ms 5976 KB Output is correct
25 Correct 2 ms 5724 KB Output is correct
26 Correct 2 ms 5724 KB Output is correct
27 Correct 2 ms 5724 KB Output is correct
28 Correct 2 ms 5724 KB Output is correct
29 Correct 1 ms 5724 KB Output is correct
30 Correct 161 ms 23892 KB Output is correct
31 Correct 280 ms 24468 KB Output is correct
32 Correct 189 ms 23960 KB Output is correct
33 Correct 179 ms 24244 KB Output is correct
34 Correct 214 ms 23636 KB Output is correct
35 Correct 191 ms 24572 KB Output is correct
36 Execution timed out 4059 ms 19784 KB Time limit exceeded
37 Halted 0 ms 0 KB -