Submission #1019727

# Submission time Handle Problem Language Result Execution time Memory
1019727 2024-07-11T08:19:22 Z Unforgettablepl Sprinkler (JOI22_sprinkler) C++17
3 / 100
4000 ms 26568 KB
#include <bits/stdc++.h>
using namespace std;

#define int long long


int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	int n,l;
	cin >> n >> l;
	vector<vector<int>> adj(n+1);
	for(int i=1;i<n;i++){
		int a,b;cin>>a>>b;
		adj[a].emplace_back(b);
		adj[b].emplace_back(a);
	}
	vector<int> H(n+1);
	for(int i=1;i<=n;i++)cin>>H[i];
	function<void(int,int,int,int)> dfs = [&](int x,int p,int range,int w){
		H[x]=(H[x]*w)%l;
		if(range==0)return;
		for(int&i:adj[x])if(i!=p)dfs(i,x,range-1,w);
	};
	int q;
	cin >> q;
	for(int i=1;i<=q;i++){
		int type;cin>>type;
		if(type==1){
			int x,d,w;cin>>x>>d>>w;
			dfs(x,0,d,w);
		} else {
			int x;cin>>x;
			cout << H[x] << '\n';
		}
	}
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 2 ms 460 KB Output is correct
6 Correct 4 ms 348 KB Output is correct
7 Correct 4 ms 560 KB Output is correct
8 Correct 4 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 464 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 476 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 ms 344 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 161 ms 25804 KB Output is correct
3 Correct 179 ms 26204 KB Output is correct
4 Correct 165 ms 24788 KB Output is correct
5 Correct 152 ms 25956 KB Output is correct
6 Correct 145 ms 25680 KB Output is correct
7 Correct 152 ms 26448 KB Output is correct
8 Correct 138 ms 26568 KB Output is correct
9 Correct 131 ms 24400 KB Output is correct
10 Correct 230 ms 24916 KB Output is correct
11 Correct 133 ms 25684 KB Output is correct
12 Correct 178 ms 26196 KB Output is correct
13 Execution timed out 4090 ms 18968 KB Time limit exceeded
14 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 161 ms 25804 KB Output is correct
3 Correct 179 ms 26204 KB Output is correct
4 Correct 165 ms 24788 KB Output is correct
5 Correct 152 ms 25956 KB Output is correct
6 Correct 145 ms 25680 KB Output is correct
7 Correct 152 ms 26448 KB Output is correct
8 Correct 138 ms 26568 KB Output is correct
9 Correct 131 ms 24400 KB Output is correct
10 Correct 230 ms 24916 KB Output is correct
11 Correct 133 ms 25684 KB Output is correct
12 Correct 178 ms 26196 KB Output is correct
13 Execution timed out 4090 ms 18968 KB Time limit exceeded
14 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 313 ms 13908 KB Output is correct
3 Correct 1860 ms 22572 KB Output is correct
4 Correct 577 ms 21840 KB Output is correct
5 Correct 3183 ms 22868 KB Output is correct
6 Execution timed out 4038 ms 18768 KB Time limit exceeded
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 343 ms 20408 KB Output is correct
3 Correct 1866 ms 20304 KB Output is correct
4 Correct 637 ms 23432 KB Output is correct
5 Correct 3509 ms 24572 KB Output is correct
6 Execution timed out 4078 ms 18808 KB Time limit exceeded
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 2 ms 460 KB Output is correct
6 Correct 4 ms 348 KB Output is correct
7 Correct 4 ms 560 KB Output is correct
8 Correct 4 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 464 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 476 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 ms 344 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 161 ms 25804 KB Output is correct
31 Correct 179 ms 26204 KB Output is correct
32 Correct 165 ms 24788 KB Output is correct
33 Correct 152 ms 25956 KB Output is correct
34 Correct 145 ms 25680 KB Output is correct
35 Correct 152 ms 26448 KB Output is correct
36 Correct 138 ms 26568 KB Output is correct
37 Correct 131 ms 24400 KB Output is correct
38 Correct 230 ms 24916 KB Output is correct
39 Correct 133 ms 25684 KB Output is correct
40 Correct 178 ms 26196 KB Output is correct
41 Execution timed out 4090 ms 18968 KB Time limit exceeded
42 Halted 0 ms 0 KB -