Submission #655996

# Submission time Handle Problem Language Result Execution time Memory
655996 2022-11-06T08:24:53 Z onlk97 Sprinkler (JOI22_sprinkler) C++14
100 / 100
835 ms 97736 KB
#include <bits/stdc++.h>
using namespace std;
vector <int> g[200050];
long long pa[200050],mut[200050][41];
void dfs(int cur,int prv){
	for (int i=0; i<=40; i++) mut[cur][i]=1;
	pa[cur]=prv;
	for (int i:g[cur]){
		if (i!=prv) dfs(i,cur);
	}
}
signed main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	long long 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);
	}
	g[n+1].push_back(1);
	for (int i=n+2; i<=n+40; i++) g[i].push_back(i-1);
	dfs(n+40,0);
	long long h[n+1];
	for (int i=1; i<=n; i++) cin>>h[i];
	int q; cin>>q;
	while (q--){
		int type; cin>>type;
		if (type==1){
			long long x,d,w;
			cin>>x>>d>>w;
			int x1=x,d1=d-1;
			while (d>=0){
				mut[x][d]=mut[x][d]*w%l;
				x=pa[x];
				d--;
			}
			x=x1;
			while (d1>=0){
				mut[x][d1]=mut[x][d1]*w%l;
				x=pa[x];
				d1--;
			}
		} else if (type==2){
			long long x;
			cin>>x;
			long long ans=h[x]%l;
			for (int i=0; i<=40; i++){
				ans=ans*mut[x][i]%l;
				x=pa[x];
			}
			cout<<ans<<'\n';
		}
	}
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4948 KB Output is correct
2 Correct 3 ms 4948 KB Output is correct
3 Correct 3 ms 4948 KB Output is correct
4 Correct 4 ms 5460 KB Output is correct
5 Correct 4 ms 5452 KB Output is correct
6 Correct 4 ms 5424 KB Output is correct
7 Correct 4 ms 5460 KB Output is correct
8 Correct 4 ms 5460 KB Output is correct
9 Correct 3 ms 4948 KB Output is correct
10 Correct 3 ms 5040 KB Output is correct
11 Correct 3 ms 5076 KB Output is correct
12 Correct 5 ms 5040 KB Output is correct
13 Correct 4 ms 5040 KB Output is correct
14 Correct 4 ms 4948 KB Output is correct
15 Correct 4 ms 4948 KB Output is correct
16 Correct 4 ms 5040 KB Output is correct
17 Correct 3 ms 5040 KB Output is correct
18 Correct 4 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 4 ms 4944 KB Output is correct
23 Correct 3 ms 4964 KB Output is correct
24 Correct 3 ms 5040 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 5076 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 634 ms 87344 KB Output is correct
3 Correct 398 ms 90312 KB Output is correct
4 Correct 516 ms 94892 KB Output is correct
5 Correct 523 ms 90644 KB Output is correct
6 Correct 398 ms 90288 KB Output is correct
7 Correct 471 ms 91024 KB Output is correct
8 Correct 320 ms 91480 KB Output is correct
9 Correct 703 ms 97736 KB Output is correct
10 Correct 467 ms 97180 KB Output is correct
11 Correct 632 ms 90360 KB Output is correct
12 Correct 421 ms 90528 KB Output is correct
13 Correct 303 ms 91172 KB Output is correct
14 Correct 291 ms 91080 KB Output is correct
15 Correct 318 ms 91044 KB Output is correct
16 Correct 305 ms 91008 KB Output is correct
17 Correct 318 ms 91664 KB Output is correct
18 Correct 3 ms 4948 KB Output is correct
19 Correct 4 ms 5076 KB Output is correct
20 Correct 4 ms 5072 KB Output is correct
21 Correct 4 ms 5036 KB Output is correct
22 Correct 4 ms 5044 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4948 KB Output is correct
2 Correct 634 ms 87344 KB Output is correct
3 Correct 398 ms 90312 KB Output is correct
4 Correct 516 ms 94892 KB Output is correct
5 Correct 523 ms 90644 KB Output is correct
6 Correct 398 ms 90288 KB Output is correct
7 Correct 471 ms 91024 KB Output is correct
8 Correct 320 ms 91480 KB Output is correct
9 Correct 703 ms 97736 KB Output is correct
10 Correct 467 ms 97180 KB Output is correct
11 Correct 632 ms 90360 KB Output is correct
12 Correct 421 ms 90528 KB Output is correct
13 Correct 303 ms 91172 KB Output is correct
14 Correct 291 ms 91080 KB Output is correct
15 Correct 318 ms 91044 KB Output is correct
16 Correct 305 ms 91008 KB Output is correct
17 Correct 318 ms 91664 KB Output is correct
18 Correct 3 ms 4948 KB Output is correct
19 Correct 4 ms 5076 KB Output is correct
20 Correct 4 ms 5072 KB Output is correct
21 Correct 4 ms 5036 KB Output is correct
22 Correct 4 ms 5044 KB Output is correct
23 Correct 3 ms 4948 KB Output is correct
24 Correct 675 ms 90348 KB Output is correct
25 Correct 465 ms 90464 KB Output is correct
26 Correct 612 ms 97696 KB Output is correct
27 Correct 554 ms 90620 KB Output is correct
28 Correct 413 ms 90752 KB Output is correct
29 Correct 396 ms 90572 KB Output is correct
30 Correct 342 ms 91420 KB Output is correct
31 Correct 628 ms 95176 KB Output is correct
32 Correct 402 ms 97056 KB Output is correct
33 Correct 595 ms 90416 KB Output is correct
34 Correct 477 ms 90232 KB Output is correct
35 Correct 4 ms 5040 KB Output is correct
36 Correct 3 ms 5040 KB Output is correct
37 Correct 3 ms 5076 KB Output is correct
38 Correct 3 ms 5076 KB Output is correct
39 Correct 3 ms 4948 KB Output is correct
40 Correct 3 ms 5032 KB Output is correct
41 Correct 3 ms 5032 KB Output is correct
42 Correct 4 ms 4948 KB Output is correct
43 Correct 4 ms 4948 KB Output is correct
44 Correct 5 ms 4948 KB Output is correct
45 Correct 3 ms 5032 KB Output is correct
46 Correct 3 ms 5036 KB Output is correct
47 Correct 3 ms 4952 KB Output is correct
48 Correct 3 ms 4948 KB Output is correct
49 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 759 ms 91984 KB Output is correct
3 Correct 827 ms 93424 KB Output is correct
4 Correct 693 ms 93284 KB Output is correct
5 Correct 604 ms 87644 KB Output is correct
6 Correct 421 ms 87792 KB Output is correct
7 Correct 448 ms 88052 KB Output is correct
8 Correct 348 ms 88640 KB Output is correct
9 Correct 651 ms 92212 KB Output is correct
10 Correct 819 ms 94512 KB Output is correct
11 Correct 619 ms 87348 KB Output is correct
12 Correct 706 ms 88188 KB Output is correct
13 Correct 504 ms 89128 KB Output is correct
14 Correct 527 ms 89656 KB Output is correct
15 Correct 3 ms 4948 KB Output is correct
16 Correct 3 ms 5076 KB Output is correct
17 Correct 3 ms 4948 KB Output is correct
18 Correct 4 ms 5040 KB Output is correct
19 Correct 3 ms 4948 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 4948 KB Output is correct
2 Correct 727 ms 91728 KB Output is correct
3 Correct 812 ms 91528 KB Output is correct
4 Correct 667 ms 93196 KB Output is correct
5 Correct 596 ms 89320 KB Output is correct
6 Correct 500 ms 89456 KB Output is correct
7 Correct 418 ms 89164 KB Output is correct
8 Correct 459 ms 89504 KB Output is correct
9 Correct 777 ms 96892 KB Output is correct
10 Correct 835 ms 95404 KB Output is correct
11 Correct 653 ms 89968 KB Output is correct
12 Correct 730 ms 88548 KB Output is correct
13 Correct 538 ms 89436 KB Output is correct
14 Correct 512 ms 89700 KB Output is correct
15 Correct 3 ms 4948 KB Output is correct
16 Correct 3 ms 5036 KB Output is correct
17 Correct 3 ms 4948 KB Output is correct
18 Correct 3 ms 5076 KB Output is correct
19 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 3 ms 4948 KB Output is correct
3 Correct 3 ms 4948 KB Output is correct
4 Correct 4 ms 5460 KB Output is correct
5 Correct 4 ms 5452 KB Output is correct
6 Correct 4 ms 5424 KB Output is correct
7 Correct 4 ms 5460 KB Output is correct
8 Correct 4 ms 5460 KB Output is correct
9 Correct 3 ms 4948 KB Output is correct
10 Correct 3 ms 5040 KB Output is correct
11 Correct 3 ms 5076 KB Output is correct
12 Correct 5 ms 5040 KB Output is correct
13 Correct 4 ms 5040 KB Output is correct
14 Correct 4 ms 4948 KB Output is correct
15 Correct 4 ms 4948 KB Output is correct
16 Correct 4 ms 5040 KB Output is correct
17 Correct 3 ms 5040 KB Output is correct
18 Correct 4 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 4 ms 4944 KB Output is correct
23 Correct 3 ms 4964 KB Output is correct
24 Correct 3 ms 5040 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 5076 KB Output is correct
28 Correct 3 ms 4948 KB Output is correct
29 Correct 3 ms 4948 KB Output is correct
30 Correct 634 ms 87344 KB Output is correct
31 Correct 398 ms 90312 KB Output is correct
32 Correct 516 ms 94892 KB Output is correct
33 Correct 523 ms 90644 KB Output is correct
34 Correct 398 ms 90288 KB Output is correct
35 Correct 471 ms 91024 KB Output is correct
36 Correct 320 ms 91480 KB Output is correct
37 Correct 703 ms 97736 KB Output is correct
38 Correct 467 ms 97180 KB Output is correct
39 Correct 632 ms 90360 KB Output is correct
40 Correct 421 ms 90528 KB Output is correct
41 Correct 303 ms 91172 KB Output is correct
42 Correct 291 ms 91080 KB Output is correct
43 Correct 318 ms 91044 KB Output is correct
44 Correct 305 ms 91008 KB Output is correct
45 Correct 318 ms 91664 KB Output is correct
46 Correct 3 ms 4948 KB Output is correct
47 Correct 4 ms 5076 KB Output is correct
48 Correct 4 ms 5072 KB Output is correct
49 Correct 4 ms 5036 KB Output is correct
50 Correct 4 ms 5044 KB Output is correct
51 Correct 3 ms 4948 KB Output is correct
52 Correct 675 ms 90348 KB Output is correct
53 Correct 465 ms 90464 KB Output is correct
54 Correct 612 ms 97696 KB Output is correct
55 Correct 554 ms 90620 KB Output is correct
56 Correct 413 ms 90752 KB Output is correct
57 Correct 396 ms 90572 KB Output is correct
58 Correct 342 ms 91420 KB Output is correct
59 Correct 628 ms 95176 KB Output is correct
60 Correct 402 ms 97056 KB Output is correct
61 Correct 595 ms 90416 KB Output is correct
62 Correct 477 ms 90232 KB Output is correct
63 Correct 4 ms 5040 KB Output is correct
64 Correct 3 ms 5040 KB Output is correct
65 Correct 3 ms 5076 KB Output is correct
66 Correct 3 ms 5076 KB Output is correct
67 Correct 3 ms 4948 KB Output is correct
68 Correct 3 ms 5032 KB Output is correct
69 Correct 3 ms 5032 KB Output is correct
70 Correct 4 ms 4948 KB Output is correct
71 Correct 4 ms 4948 KB Output is correct
72 Correct 5 ms 4948 KB Output is correct
73 Correct 3 ms 5032 KB Output is correct
74 Correct 3 ms 5036 KB Output is correct
75 Correct 3 ms 4952 KB Output is correct
76 Correct 3 ms 4948 KB Output is correct
77 Correct 3 ms 4948 KB Output is correct
78 Correct 3 ms 4948 KB Output is correct
79 Correct 759 ms 91984 KB Output is correct
80 Correct 827 ms 93424 KB Output is correct
81 Correct 693 ms 93284 KB Output is correct
82 Correct 604 ms 87644 KB Output is correct
83 Correct 421 ms 87792 KB Output is correct
84 Correct 448 ms 88052 KB Output is correct
85 Correct 348 ms 88640 KB Output is correct
86 Correct 651 ms 92212 KB Output is correct
87 Correct 819 ms 94512 KB Output is correct
88 Correct 619 ms 87348 KB Output is correct
89 Correct 706 ms 88188 KB Output is correct
90 Correct 504 ms 89128 KB Output is correct
91 Correct 527 ms 89656 KB Output is correct
92 Correct 3 ms 4948 KB Output is correct
93 Correct 3 ms 5076 KB Output is correct
94 Correct 3 ms 4948 KB Output is correct
95 Correct 4 ms 5040 KB Output is correct
96 Correct 3 ms 4948 KB Output is correct
97 Correct 4 ms 4948 KB Output is correct
98 Correct 727 ms 91728 KB Output is correct
99 Correct 812 ms 91528 KB Output is correct
100 Correct 667 ms 93196 KB Output is correct
101 Correct 596 ms 89320 KB Output is correct
102 Correct 500 ms 89456 KB Output is correct
103 Correct 418 ms 89164 KB Output is correct
104 Correct 459 ms 89504 KB Output is correct
105 Correct 777 ms 96892 KB Output is correct
106 Correct 835 ms 95404 KB Output is correct
107 Correct 653 ms 89968 KB Output is correct
108 Correct 730 ms 88548 KB Output is correct
109 Correct 538 ms 89436 KB Output is correct
110 Correct 512 ms 89700 KB Output is correct
111 Correct 3 ms 4948 KB Output is correct
112 Correct 3 ms 5036 KB Output is correct
113 Correct 3 ms 4948 KB Output is correct
114 Correct 3 ms 5076 KB Output is correct
115 Correct 3 ms 4948 KB Output is correct
116 Correct 703 ms 88452 KB Output is correct
117 Correct 824 ms 88692 KB Output is correct
118 Correct 618 ms 97228 KB Output is correct
119 Correct 602 ms 90016 KB Output is correct
120 Correct 464 ms 90112 KB Output is correct
121 Correct 481 ms 90340 KB Output is correct
122 Correct 402 ms 90584 KB Output is correct
123 Correct 700 ms 96024 KB Output is correct
124 Correct 801 ms 92176 KB Output is correct
125 Correct 623 ms 89788 KB Output is correct
126 Correct 757 ms 87620 KB Output is correct
127 Correct 780 ms 87500 KB Output is correct
128 Correct 580 ms 88164 KB Output is correct
129 Correct 599 ms 88360 KB Output is correct