답안 #910152

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
910152 2024-01-18T00:27:21 Z vjudge1 Sprinkler (JOI22_sprinkler) C++17
3 / 100
4000 ms 24900 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';
    	}
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4956 KB Output is correct
2 Correct 2 ms 5144 KB Output is correct
3 Correct 2 ms 4956 KB Output is correct
4 Correct 4 ms 5212 KB Output is correct
5 Correct 5 ms 5096 KB Output is correct
6 Correct 6 ms 5208 KB Output is correct
7 Correct 7 ms 5212 KB Output is correct
8 Correct 10 ms 5208 KB Output is correct
9 Correct 2 ms 4976 KB Output is correct
10 Correct 3 ms 4956 KB Output is correct
11 Correct 2 ms 4956 KB Output is correct
12 Correct 4 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 2 ms 5148 KB Output is correct
16 Correct 3 ms 4956 KB Output is correct
17 Correct 3 ms 4956 KB Output is correct
18 Correct 3 ms 4952 KB Output is correct
19 Correct 3 ms 4956 KB Output is correct
20 Correct 2 ms 4952 KB Output is correct
21 Correct 3 ms 4956 KB Output is correct
22 Correct 3 ms 4980 KB Output is correct
23 Correct 2 ms 4956 KB Output is correct
24 Correct 3 ms 4956 KB Output is correct
25 Correct 2 ms 5144 KB Output is correct
26 Correct 2 ms 5144 KB Output is correct
27 Correct 3 ms 4952 KB Output is correct
28 Correct 3 ms 4956 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4956 KB Output is correct
2 Correct 764 ms 23852 KB Output is correct
3 Correct 515 ms 24404 KB Output is correct
4 Correct 630 ms 23892 KB Output is correct
5 Correct 644 ms 24052 KB Output is correct
6 Correct 625 ms 23788 KB Output is correct
7 Correct 642 ms 24660 KB Output is correct
8 Correct 613 ms 24900 KB Output is correct
9 Correct 741 ms 23636 KB Output is correct
10 Correct 500 ms 24164 KB Output is correct
11 Correct 753 ms 23756 KB Output is correct
12 Correct 523 ms 24532 KB Output is correct
13 Execution timed out 4062 ms 17448 KB Time limit exceeded
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4956 KB Output is correct
2 Correct 764 ms 23852 KB Output is correct
3 Correct 515 ms 24404 KB Output is correct
4 Correct 630 ms 23892 KB Output is correct
5 Correct 644 ms 24052 KB Output is correct
6 Correct 625 ms 23788 KB Output is correct
7 Correct 642 ms 24660 KB Output is correct
8 Correct 613 ms 24900 KB Output is correct
9 Correct 741 ms 23636 KB Output is correct
10 Correct 500 ms 24164 KB Output is correct
11 Correct 753 ms 23756 KB Output is correct
12 Correct 523 ms 24532 KB Output is correct
13 Execution timed out 4062 ms 17448 KB Time limit exceeded
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4956 KB Output is correct
2 Correct 902 ms 13028 KB Output is correct
3 Correct 1816 ms 21928 KB Output is correct
4 Correct 965 ms 21164 KB Output is correct
5 Correct 2830 ms 21328 KB Output is correct
6 Execution timed out 4022 ms 17032 KB Time limit exceeded
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4956 KB Output is correct
2 Correct 935 ms 23572 KB Output is correct
3 Correct 1964 ms 21996 KB Output is correct
4 Correct 968 ms 22824 KB Output is correct
5 Correct 3045 ms 22944 KB Output is correct
6 Execution timed out 4010 ms 17252 KB Time limit exceeded
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4956 KB Output is correct
2 Correct 2 ms 5144 KB Output is correct
3 Correct 2 ms 4956 KB Output is correct
4 Correct 4 ms 5212 KB Output is correct
5 Correct 5 ms 5096 KB Output is correct
6 Correct 6 ms 5208 KB Output is correct
7 Correct 7 ms 5212 KB Output is correct
8 Correct 10 ms 5208 KB Output is correct
9 Correct 2 ms 4976 KB Output is correct
10 Correct 3 ms 4956 KB Output is correct
11 Correct 2 ms 4956 KB Output is correct
12 Correct 4 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 2 ms 5148 KB Output is correct
16 Correct 3 ms 4956 KB Output is correct
17 Correct 3 ms 4956 KB Output is correct
18 Correct 3 ms 4952 KB Output is correct
19 Correct 3 ms 4956 KB Output is correct
20 Correct 2 ms 4952 KB Output is correct
21 Correct 3 ms 4956 KB Output is correct
22 Correct 3 ms 4980 KB Output is correct
23 Correct 2 ms 4956 KB Output is correct
24 Correct 3 ms 4956 KB Output is correct
25 Correct 2 ms 5144 KB Output is correct
26 Correct 2 ms 5144 KB Output is correct
27 Correct 3 ms 4952 KB Output is correct
28 Correct 3 ms 4956 KB Output is correct
29 Correct 1 ms 4956 KB Output is correct
30 Correct 764 ms 23852 KB Output is correct
31 Correct 515 ms 24404 KB Output is correct
32 Correct 630 ms 23892 KB Output is correct
33 Correct 644 ms 24052 KB Output is correct
34 Correct 625 ms 23788 KB Output is correct
35 Correct 642 ms 24660 KB Output is correct
36 Correct 613 ms 24900 KB Output is correct
37 Correct 741 ms 23636 KB Output is correct
38 Correct 500 ms 24164 KB Output is correct
39 Correct 753 ms 23756 KB Output is correct
40 Correct 523 ms 24532 KB Output is correct
41 Execution timed out 4062 ms 17448 KB Time limit exceeded
42 Halted 0 ms 0 KB -