Submission #637991

# Submission time Handle Problem Language Result Execution time Memory
637991 2022-09-04T03:32:21 Z LittleCube Sprinkler (JOI22_sprinkler) C++14
100 / 100
790 ms 95304 KB
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define F first
#define S second
using namespace std;

ll N, Q, L, pre[200050], h[200055], mul[200055][41];
vector<int> E[200050];

void dfs(int u)
{
	for(int v : E[u])
		if(pre[u] != v)
		{
			pre[v] = u;
			dfs(v);
		}
}

signed main()
{
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	cin >> N >> L;
	for(int i = 1; i <= N - 1; i++)
	{
		int u, v;
		cin >> u >> v;
		E[u].emplace_back(v);
		E[v].emplace_back(u);
	}
	for(int i = 1; i <= 40; i++)
		E[N + i].emplace_back(N + i - 1);
	dfs(N + 40);
	for(int i = 1; i <= N; i++)
		cin >> h[i];
	for(int i = 1; i <= N + 40; i++)
		for(int j = 0; j <= 40; j++)
			mul[i][j] = 1;
	cin >> Q;
	while(Q--)
	{
		ll T, X, D, W;
		cin >> T;
		if(T == 1)
		{
			cin >> X >> D >> W;
			for(int i = D; i >= 0; i--)
			{
				mul[X][i] = mul[X][i] * W % L;
				if(i)
					mul[X][i - 1] = mul[X][i - 1] * W % L;
				X = pre[X];
			}
		}
		else
		{
			cin >> X;
			ll ans = h[X];
			for(int i = 0; i <= 40; i++)
			{
				ans = ans * mul[X][i] % L;
				X = pre[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 4992 KB Output is correct
4 Correct 4 ms 5460 KB Output is correct
5 Correct 4 ms 5420 KB Output is correct
6 Correct 4 ms 5372 KB Output is correct
7 Correct 4 ms 5428 KB Output is correct
8 Correct 4 ms 5424 KB Output is correct
9 Correct 3 ms 5076 KB Output is correct
10 Correct 3 ms 5076 KB Output is correct
11 Correct 3 ms 5076 KB Output is correct
12 Correct 3 ms 5076 KB Output is correct
13 Correct 3 ms 5076 KB Output is correct
14 Correct 4 ms 5036 KB Output is correct
15 Correct 3 ms 5164 KB Output is correct
16 Correct 3 ms 5076 KB Output is correct
17 Correct 3 ms 5076 KB Output is correct
18 Correct 3 ms 5076 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 5032 KB Output is correct
24 Correct 4 ms 5076 KB Output is correct
25 Correct 3 ms 5076 KB Output is correct
26 Correct 3 ms 5028 KB Output is correct
27 Correct 3 ms 5076 KB Output is correct
28 Correct 3 ms 5076 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4948 KB Output is correct
2 Correct 550 ms 82848 KB Output is correct
3 Correct 350 ms 79592 KB Output is correct
4 Correct 493 ms 83956 KB Output is correct
5 Correct 467 ms 81220 KB Output is correct
6 Correct 354 ms 81028 KB Output is correct
7 Correct 344 ms 81420 KB Output is correct
8 Correct 286 ms 81880 KB Output is correct
9 Correct 611 ms 85432 KB Output is correct
10 Correct 364 ms 82796 KB Output is correct
11 Correct 564 ms 82572 KB Output is correct
12 Correct 354 ms 79448 KB Output is correct
13 Correct 236 ms 79884 KB Output is correct
14 Correct 236 ms 79860 KB Output is correct
15 Correct 231 ms 79980 KB Output is correct
16 Correct 257 ms 79948 KB Output is correct
17 Correct 239 ms 80440 KB Output is correct
18 Correct 3 ms 5076 KB Output is correct
19 Correct 3 ms 5036 KB Output is correct
20 Correct 3 ms 5076 KB Output is correct
21 Correct 3 ms 5076 KB Output is correct
22 Correct 3 ms 5076 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4948 KB Output is correct
2 Correct 550 ms 82848 KB Output is correct
3 Correct 350 ms 79592 KB Output is correct
4 Correct 493 ms 83956 KB Output is correct
5 Correct 467 ms 81220 KB Output is correct
6 Correct 354 ms 81028 KB Output is correct
7 Correct 344 ms 81420 KB Output is correct
8 Correct 286 ms 81880 KB Output is correct
9 Correct 611 ms 85432 KB Output is correct
10 Correct 364 ms 82796 KB Output is correct
11 Correct 564 ms 82572 KB Output is correct
12 Correct 354 ms 79448 KB Output is correct
13 Correct 236 ms 79884 KB Output is correct
14 Correct 236 ms 79860 KB Output is correct
15 Correct 231 ms 79980 KB Output is correct
16 Correct 257 ms 79948 KB Output is correct
17 Correct 239 ms 80440 KB Output is correct
18 Correct 3 ms 5076 KB Output is correct
19 Correct 3 ms 5036 KB Output is correct
20 Correct 3 ms 5076 KB Output is correct
21 Correct 3 ms 5076 KB Output is correct
22 Correct 3 ms 5076 KB Output is correct
23 Correct 2 ms 4948 KB Output is correct
24 Correct 545 ms 82424 KB Output is correct
25 Correct 340 ms 79256 KB Output is correct
26 Correct 492 ms 85432 KB Output is correct
27 Correct 452 ms 80924 KB Output is correct
28 Correct 351 ms 81052 KB Output is correct
29 Correct 323 ms 81040 KB Output is correct
30 Correct 282 ms 81580 KB Output is correct
31 Correct 576 ms 86792 KB Output is correct
32 Correct 361 ms 82124 KB Output is correct
33 Correct 542 ms 82436 KB Output is correct
34 Correct 348 ms 79368 KB Output is correct
35 Correct 3 ms 5076 KB Output is correct
36 Correct 3 ms 5076 KB Output is correct
37 Correct 3 ms 5076 KB Output is correct
38 Correct 3 ms 5076 KB Output is correct
39 Correct 4 ms 5032 KB Output is correct
40 Correct 3 ms 4948 KB Output is correct
41 Correct 4 ms 4948 KB Output is correct
42 Correct 4 ms 5028 KB Output is correct
43 Correct 3 ms 4948 KB Output is correct
44 Correct 3 ms 4948 KB Output is correct
45 Correct 3 ms 4948 KB Output is correct
46 Correct 3 ms 5076 KB Output is correct
47 Correct 3 ms 4948 KB Output is correct
48 Correct 3 ms 5076 KB Output is correct
49 Correct 3 ms 4948 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 5028 KB Output is correct
2 Correct 615 ms 83692 KB Output is correct
3 Correct 731 ms 88572 KB Output is correct
4 Correct 568 ms 89852 KB Output is correct
5 Correct 526 ms 84592 KB Output is correct
6 Correct 376 ms 84864 KB Output is correct
7 Correct 356 ms 84964 KB Output is correct
8 Correct 320 ms 85232 KB Output is correct
9 Correct 615 ms 88096 KB Output is correct
10 Correct 705 ms 89104 KB Output is correct
11 Correct 576 ms 84940 KB Output is correct
12 Correct 618 ms 84204 KB Output is correct
13 Correct 399 ms 85140 KB Output is correct
14 Correct 398 ms 85604 KB Output is correct
15 Correct 3 ms 4948 KB Output is correct
16 Correct 3 ms 4948 KB Output is correct
17 Correct 3 ms 4948 KB Output is correct
18 Correct 3 ms 5024 KB Output is correct
19 Correct 3 ms 4948 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 5024 KB Output is correct
2 Correct 639 ms 86088 KB Output is correct
3 Correct 673 ms 91476 KB Output is correct
4 Correct 579 ms 93452 KB Output is correct
5 Correct 527 ms 89284 KB Output is correct
6 Correct 429 ms 89448 KB Output is correct
7 Correct 388 ms 89320 KB Output is correct
8 Correct 322 ms 89536 KB Output is correct
9 Correct 683 ms 94508 KB Output is correct
10 Correct 721 ms 91860 KB Output is correct
11 Correct 605 ms 90104 KB Output is correct
12 Correct 623 ms 88540 KB Output is correct
13 Correct 405 ms 89232 KB Output is correct
14 Correct 430 ms 89764 KB Output is correct
15 Correct 3 ms 4948 KB Output is correct
16 Correct 3 ms 4948 KB Output is correct
17 Correct 3 ms 5036 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 4992 KB Output is correct
4 Correct 4 ms 5460 KB Output is correct
5 Correct 4 ms 5420 KB Output is correct
6 Correct 4 ms 5372 KB Output is correct
7 Correct 4 ms 5428 KB Output is correct
8 Correct 4 ms 5424 KB Output is correct
9 Correct 3 ms 5076 KB Output is correct
10 Correct 3 ms 5076 KB Output is correct
11 Correct 3 ms 5076 KB Output is correct
12 Correct 3 ms 5076 KB Output is correct
13 Correct 3 ms 5076 KB Output is correct
14 Correct 4 ms 5036 KB Output is correct
15 Correct 3 ms 5164 KB Output is correct
16 Correct 3 ms 5076 KB Output is correct
17 Correct 3 ms 5076 KB Output is correct
18 Correct 3 ms 5076 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 5032 KB Output is correct
24 Correct 4 ms 5076 KB Output is correct
25 Correct 3 ms 5076 KB Output is correct
26 Correct 3 ms 5028 KB Output is correct
27 Correct 3 ms 5076 KB Output is correct
28 Correct 3 ms 5076 KB Output is correct
29 Correct 3 ms 4948 KB Output is correct
30 Correct 550 ms 82848 KB Output is correct
31 Correct 350 ms 79592 KB Output is correct
32 Correct 493 ms 83956 KB Output is correct
33 Correct 467 ms 81220 KB Output is correct
34 Correct 354 ms 81028 KB Output is correct
35 Correct 344 ms 81420 KB Output is correct
36 Correct 286 ms 81880 KB Output is correct
37 Correct 611 ms 85432 KB Output is correct
38 Correct 364 ms 82796 KB Output is correct
39 Correct 564 ms 82572 KB Output is correct
40 Correct 354 ms 79448 KB Output is correct
41 Correct 236 ms 79884 KB Output is correct
42 Correct 236 ms 79860 KB Output is correct
43 Correct 231 ms 79980 KB Output is correct
44 Correct 257 ms 79948 KB Output is correct
45 Correct 239 ms 80440 KB Output is correct
46 Correct 3 ms 5076 KB Output is correct
47 Correct 3 ms 5036 KB Output is correct
48 Correct 3 ms 5076 KB Output is correct
49 Correct 3 ms 5076 KB Output is correct
50 Correct 3 ms 5076 KB Output is correct
51 Correct 2 ms 4948 KB Output is correct
52 Correct 545 ms 82424 KB Output is correct
53 Correct 340 ms 79256 KB Output is correct
54 Correct 492 ms 85432 KB Output is correct
55 Correct 452 ms 80924 KB Output is correct
56 Correct 351 ms 81052 KB Output is correct
57 Correct 323 ms 81040 KB Output is correct
58 Correct 282 ms 81580 KB Output is correct
59 Correct 576 ms 86792 KB Output is correct
60 Correct 361 ms 82124 KB Output is correct
61 Correct 542 ms 82436 KB Output is correct
62 Correct 348 ms 79368 KB Output is correct
63 Correct 3 ms 5076 KB Output is correct
64 Correct 3 ms 5076 KB Output is correct
65 Correct 3 ms 5076 KB Output is correct
66 Correct 3 ms 5076 KB Output is correct
67 Correct 4 ms 5032 KB Output is correct
68 Correct 3 ms 4948 KB Output is correct
69 Correct 4 ms 4948 KB Output is correct
70 Correct 4 ms 5028 KB Output is correct
71 Correct 3 ms 4948 KB Output is correct
72 Correct 3 ms 4948 KB Output is correct
73 Correct 3 ms 4948 KB Output is correct
74 Correct 3 ms 5076 KB Output is correct
75 Correct 3 ms 4948 KB Output is correct
76 Correct 3 ms 5076 KB Output is correct
77 Correct 3 ms 4948 KB Output is correct
78 Correct 3 ms 5028 KB Output is correct
79 Correct 615 ms 83692 KB Output is correct
80 Correct 731 ms 88572 KB Output is correct
81 Correct 568 ms 89852 KB Output is correct
82 Correct 526 ms 84592 KB Output is correct
83 Correct 376 ms 84864 KB Output is correct
84 Correct 356 ms 84964 KB Output is correct
85 Correct 320 ms 85232 KB Output is correct
86 Correct 615 ms 88096 KB Output is correct
87 Correct 705 ms 89104 KB Output is correct
88 Correct 576 ms 84940 KB Output is correct
89 Correct 618 ms 84204 KB Output is correct
90 Correct 399 ms 85140 KB Output is correct
91 Correct 398 ms 85604 KB Output is correct
92 Correct 3 ms 4948 KB Output is correct
93 Correct 3 ms 4948 KB Output is correct
94 Correct 3 ms 4948 KB Output is correct
95 Correct 3 ms 5024 KB Output is correct
96 Correct 3 ms 4948 KB Output is correct
97 Correct 3 ms 5024 KB Output is correct
98 Correct 639 ms 86088 KB Output is correct
99 Correct 673 ms 91476 KB Output is correct
100 Correct 579 ms 93452 KB Output is correct
101 Correct 527 ms 89284 KB Output is correct
102 Correct 429 ms 89448 KB Output is correct
103 Correct 388 ms 89320 KB Output is correct
104 Correct 322 ms 89536 KB Output is correct
105 Correct 683 ms 94508 KB Output is correct
106 Correct 721 ms 91860 KB Output is correct
107 Correct 605 ms 90104 KB Output is correct
108 Correct 623 ms 88540 KB Output is correct
109 Correct 405 ms 89232 KB Output is correct
110 Correct 430 ms 89764 KB Output is correct
111 Correct 3 ms 4948 KB Output is correct
112 Correct 3 ms 4948 KB Output is correct
113 Correct 3 ms 5036 KB Output is correct
114 Correct 3 ms 5076 KB Output is correct
115 Correct 3 ms 4948 KB Output is correct
116 Correct 627 ms 88492 KB Output is correct
117 Correct 663 ms 90960 KB Output is correct
118 Correct 627 ms 95304 KB Output is correct
119 Correct 597 ms 90740 KB Output is correct
120 Correct 437 ms 90304 KB Output is correct
121 Correct 435 ms 91168 KB Output is correct
122 Correct 373 ms 91592 KB Output is correct
123 Correct 646 ms 93336 KB Output is correct
124 Correct 790 ms 93644 KB Output is correct
125 Correct 594 ms 89816 KB Output is correct
126 Correct 644 ms 91024 KB Output is correct
127 Correct 661 ms 91500 KB Output is correct
128 Correct 509 ms 92184 KB Output is correct
129 Correct 521 ms 92604 KB Output is correct