Submission #874318

# Submission time Handle Problem Language Result Execution time Memory
874318 2023-11-16T16:31:44 Z svorogaze Sprinkler (JOI22_sprinkler) C++17
100 / 100
631 ms 93620 KB
/*
らららららららら らららららららら
らららららららら らららららららら
らららららららら らららららららら
らららららららら らららららららら
らららららららら らららららららら
らららららららら らららららららら
らららららららら らららららららら
らららららららら らららららららら
ハツネ祭り マジヤバイや
法事中も聴き涙 そりゃ病や
蟻食うバイトがあるけどまーいいや
京急の方の蒲田 満員や
ちょいNAMA-GUSAI シャングリラ
Jpopは だめだこりゃ
コス見りゃ婆 撮るのはマン
さあうたおー
Da-da-da-da-damn!
わけもなく
いみもなく
あめがふるように
Da-da-da-da-damn!
わけもなく
いみもなく
かぜがふくようにうたう
合成みたいなバランスの女装おじさん
学生に癖毛が生えたようなモーツァルト
母性溢れる鮟モチーフのマーメイド
音声祀りに集まった
ああ 最終学歴保育園でも
役3年目の米寿でも
年収図書券2~3枚でも
そこに行けば音はある
Da-da-da-da-damn!
わけもなく
いみもなく
あめがふるように
Da-da-da-da-damn!
わけもなく
いみもなく
かぜがふくように
Da-da-da-da-damn!
わけもなく
いみもなく
ただいきるように
Da-da-da-da-damn!
わけもなく
いみもなく
いきをするようにうたう
らららららららら らららららららら
らららららららら らららららららら
らららららららら らららららららら
らららららららら らららららららら
らららららららら らららららららら
らららららららら らららららららら
らららららららら らららららららら
らららららららら
*/

#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define int long long
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, std::greater<int>, rb_tree_tag,
             tree_order_statistics_node_update>
    indexed_set;
typedef tree<long long, null_type, greater_equal<>, rb_tree_tag,
             tree_order_statistics_node_update>
    ordered_multiset;
#define fastio \
    std::cin.tie(0), std::cout.tie(0), std::ios_base::sync_with_stdio(false)
#define rep(a, b, c, d) for (int a = b; a < c; a += d)
#define INF ((1ll << 48) - 1)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define pb push_back
#define x first
#define y second
#define ld long double
#define MAXN 201000
vector<vector<int>> g;
vector<int> p;
int dp[200000][42];

void dfs1(int v, int pr) {
    p[v] = pr;
    for (auto w : g[v]) {
        if (w != pr) dfs1(w, v);
    }
}

signed main() {
    fastio;
    for (auto& i : dp) for (auto& j : i) j = 1;
    int n, l;
    cin >> n >> l;
    g.resize(n);
    p.resize(n, -1);
    for (int i = 0; i < n - 1; ++i) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    vector<int> h(n);
    for (auto& i : h) cin >> i;
    dfs1(0, -1);
    int q;
    cin >> q;
    while (q--) {
        int t;
        cin >> t;
        if (t == 1) {
            int x, d, w;
            cin >> x >> d >> w;
            x--;
            while (d >= 0) {
                if (x != 0) {
                    dp[x][d] = (dp[x][d] * w) % l;
                } else {
                    for (int j = 0; j <= d; j++) {
                        dp[x][j] = (dp[x][j] * w) % l;
                    }
                }
                d--;
                x = p[x];
                if (x == -1) break;
            }
        } else {
            int x;
            cin >> x;
            x--;
            int r = h[x];
            for (int i = 0; i <= 40; i++) {
                if (x != 0) {
                    r = (r * dp[x][i]) % l;
                    r = (r * dp[x][i + 1]) % l;
                } else {
                    r = (r * dp[x][i]) % l;
                }
                x = p[x];
                if (x == -1) break;
            }
            cout << r << '\n';
        }
    }
}
# Verdict Execution time Memory Grader output
1 Correct 12 ms 66140 KB Output is correct
2 Correct 11 ms 66188 KB Output is correct
3 Correct 11 ms 66140 KB Output is correct
4 Correct 12 ms 66140 KB Output is correct
5 Correct 12 ms 66284 KB Output is correct
6 Correct 14 ms 66196 KB Output is correct
7 Correct 11 ms 66140 KB Output is correct
8 Correct 11 ms 66140 KB Output is correct
9 Correct 11 ms 66140 KB Output is correct
10 Correct 10 ms 66224 KB Output is correct
11 Correct 10 ms 66136 KB Output is correct
12 Correct 10 ms 66000 KB Output is correct
13 Correct 11 ms 66140 KB Output is correct
14 Correct 10 ms 66140 KB Output is correct
15 Correct 10 ms 66216 KB Output is correct
16 Correct 15 ms 66140 KB Output is correct
17 Correct 13 ms 66140 KB Output is correct
18 Correct 11 ms 66220 KB Output is correct
19 Correct 10 ms 65996 KB Output is correct
20 Correct 10 ms 66212 KB Output is correct
21 Correct 10 ms 66140 KB Output is correct
22 Correct 10 ms 66212 KB Output is correct
23 Correct 10 ms 66140 KB Output is correct
24 Correct 11 ms 66140 KB Output is correct
25 Correct 9 ms 65980 KB Output is correct
26 Correct 10 ms 66144 KB Output is correct
27 Correct 11 ms 66140 KB Output is correct
28 Correct 13 ms 66144 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 66140 KB Output is correct
2 Correct 508 ms 89228 KB Output is correct
3 Correct 309 ms 87888 KB Output is correct
4 Correct 499 ms 90868 KB Output is correct
5 Correct 405 ms 88476 KB Output is correct
6 Correct 300 ms 88480 KB Output is correct
7 Correct 294 ms 89036 KB Output is correct
8 Correct 214 ms 89100 KB Output is correct
9 Correct 625 ms 93448 KB Output is correct
10 Correct 375 ms 91864 KB Output is correct
11 Correct 437 ms 89232 KB Output is correct
12 Correct 335 ms 87808 KB Output is correct
13 Correct 168 ms 88248 KB Output is correct
14 Correct 191 ms 88248 KB Output is correct
15 Correct 174 ms 87880 KB Output is correct
16 Correct 175 ms 88148 KB Output is correct
17 Correct 188 ms 88744 KB Output is correct
18 Correct 10 ms 66140 KB Output is correct
19 Correct 10 ms 66140 KB Output is correct
20 Correct 10 ms 66140 KB Output is correct
21 Correct 10 ms 66000 KB Output is correct
22 Correct 9 ms 66136 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 66140 KB Output is correct
2 Correct 508 ms 89228 KB Output is correct
3 Correct 309 ms 87888 KB Output is correct
4 Correct 499 ms 90868 KB Output is correct
5 Correct 405 ms 88476 KB Output is correct
6 Correct 300 ms 88480 KB Output is correct
7 Correct 294 ms 89036 KB Output is correct
8 Correct 214 ms 89100 KB Output is correct
9 Correct 625 ms 93448 KB Output is correct
10 Correct 375 ms 91864 KB Output is correct
11 Correct 437 ms 89232 KB Output is correct
12 Correct 335 ms 87808 KB Output is correct
13 Correct 168 ms 88248 KB Output is correct
14 Correct 191 ms 88248 KB Output is correct
15 Correct 174 ms 87880 KB Output is correct
16 Correct 175 ms 88148 KB Output is correct
17 Correct 188 ms 88744 KB Output is correct
18 Correct 10 ms 66140 KB Output is correct
19 Correct 10 ms 66140 KB Output is correct
20 Correct 10 ms 66140 KB Output is correct
21 Correct 10 ms 66000 KB Output is correct
22 Correct 9 ms 66136 KB Output is correct
23 Correct 9 ms 66136 KB Output is correct
24 Correct 454 ms 89212 KB Output is correct
25 Correct 278 ms 87820 KB Output is correct
26 Correct 426 ms 93104 KB Output is correct
27 Correct 381 ms 88520 KB Output is correct
28 Correct 270 ms 88840 KB Output is correct
29 Correct 255 ms 88656 KB Output is correct
30 Correct 195 ms 89012 KB Output is correct
31 Correct 593 ms 91964 KB Output is correct
32 Correct 339 ms 91604 KB Output is correct
33 Correct 443 ms 89504 KB Output is correct
34 Correct 275 ms 87884 KB Output is correct
35 Correct 9 ms 66140 KB Output is correct
36 Correct 9 ms 66212 KB Output is correct
37 Correct 9 ms 66140 KB Output is correct
38 Correct 9 ms 66004 KB Output is correct
39 Correct 12 ms 66140 KB Output is correct
40 Correct 10 ms 66136 KB Output is correct
41 Correct 9 ms 66220 KB Output is correct
42 Correct 9 ms 66136 KB Output is correct
43 Correct 9 ms 66136 KB Output is correct
44 Correct 9 ms 66140 KB Output is correct
45 Correct 9 ms 66032 KB Output is correct
46 Correct 9 ms 66140 KB Output is correct
47 Correct 9 ms 66140 KB Output is correct
48 Correct 9 ms 66204 KB Output is correct
49 Correct 9 ms 65996 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11 ms 66140 KB Output is correct
2 Correct 615 ms 90844 KB Output is correct
3 Correct 594 ms 89436 KB Output is correct
4 Correct 503 ms 89696 KB Output is correct
5 Correct 407 ms 86176 KB Output is correct
6 Correct 282 ms 86608 KB Output is correct
7 Correct 262 ms 86608 KB Output is correct
8 Correct 194 ms 86720 KB Output is correct
9 Correct 576 ms 89036 KB Output is correct
10 Correct 631 ms 92680 KB Output is correct
11 Correct 468 ms 88700 KB Output is correct
12 Correct 450 ms 89036 KB Output is correct
13 Correct 297 ms 89972 KB Output is correct
14 Correct 292 ms 90708 KB Output is correct
15 Correct 9 ms 66032 KB Output is correct
16 Correct 9 ms 66140 KB Output is correct
17 Correct 9 ms 65996 KB Output is correct
18 Correct 13 ms 66140 KB Output is correct
19 Correct 9 ms 66140 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 66140 KB Output is correct
2 Correct 611 ms 93620 KB Output is correct
3 Correct 601 ms 90956 KB Output is correct
4 Correct 468 ms 92424 KB Output is correct
5 Correct 392 ms 90192 KB Output is correct
6 Correct 289 ms 90452 KB Output is correct
7 Correct 268 ms 90408 KB Output is correct
8 Correct 203 ms 88100 KB Output is correct
9 Correct 597 ms 92776 KB Output is correct
10 Correct 535 ms 90448 KB Output is correct
11 Correct 486 ms 88940 KB Output is correct
12 Correct 491 ms 87000 KB Output is correct
13 Correct 286 ms 87788 KB Output is correct
14 Correct 289 ms 88336 KB Output is correct
15 Correct 9 ms 66140 KB Output is correct
16 Correct 9 ms 65976 KB Output is correct
17 Correct 9 ms 66136 KB Output is correct
18 Correct 9 ms 66140 KB Output is correct
19 Correct 9 ms 66140 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 66140 KB Output is correct
2 Correct 11 ms 66188 KB Output is correct
3 Correct 11 ms 66140 KB Output is correct
4 Correct 12 ms 66140 KB Output is correct
5 Correct 12 ms 66284 KB Output is correct
6 Correct 14 ms 66196 KB Output is correct
7 Correct 11 ms 66140 KB Output is correct
8 Correct 11 ms 66140 KB Output is correct
9 Correct 11 ms 66140 KB Output is correct
10 Correct 10 ms 66224 KB Output is correct
11 Correct 10 ms 66136 KB Output is correct
12 Correct 10 ms 66000 KB Output is correct
13 Correct 11 ms 66140 KB Output is correct
14 Correct 10 ms 66140 KB Output is correct
15 Correct 10 ms 66216 KB Output is correct
16 Correct 15 ms 66140 KB Output is correct
17 Correct 13 ms 66140 KB Output is correct
18 Correct 11 ms 66220 KB Output is correct
19 Correct 10 ms 65996 KB Output is correct
20 Correct 10 ms 66212 KB Output is correct
21 Correct 10 ms 66140 KB Output is correct
22 Correct 10 ms 66212 KB Output is correct
23 Correct 10 ms 66140 KB Output is correct
24 Correct 11 ms 66140 KB Output is correct
25 Correct 9 ms 65980 KB Output is correct
26 Correct 10 ms 66144 KB Output is correct
27 Correct 11 ms 66140 KB Output is correct
28 Correct 13 ms 66144 KB Output is correct
29 Correct 12 ms 66140 KB Output is correct
30 Correct 508 ms 89228 KB Output is correct
31 Correct 309 ms 87888 KB Output is correct
32 Correct 499 ms 90868 KB Output is correct
33 Correct 405 ms 88476 KB Output is correct
34 Correct 300 ms 88480 KB Output is correct
35 Correct 294 ms 89036 KB Output is correct
36 Correct 214 ms 89100 KB Output is correct
37 Correct 625 ms 93448 KB Output is correct
38 Correct 375 ms 91864 KB Output is correct
39 Correct 437 ms 89232 KB Output is correct
40 Correct 335 ms 87808 KB Output is correct
41 Correct 168 ms 88248 KB Output is correct
42 Correct 191 ms 88248 KB Output is correct
43 Correct 174 ms 87880 KB Output is correct
44 Correct 175 ms 88148 KB Output is correct
45 Correct 188 ms 88744 KB Output is correct
46 Correct 10 ms 66140 KB Output is correct
47 Correct 10 ms 66140 KB Output is correct
48 Correct 10 ms 66140 KB Output is correct
49 Correct 10 ms 66000 KB Output is correct
50 Correct 9 ms 66136 KB Output is correct
51 Correct 9 ms 66136 KB Output is correct
52 Correct 454 ms 89212 KB Output is correct
53 Correct 278 ms 87820 KB Output is correct
54 Correct 426 ms 93104 KB Output is correct
55 Correct 381 ms 88520 KB Output is correct
56 Correct 270 ms 88840 KB Output is correct
57 Correct 255 ms 88656 KB Output is correct
58 Correct 195 ms 89012 KB Output is correct
59 Correct 593 ms 91964 KB Output is correct
60 Correct 339 ms 91604 KB Output is correct
61 Correct 443 ms 89504 KB Output is correct
62 Correct 275 ms 87884 KB Output is correct
63 Correct 9 ms 66140 KB Output is correct
64 Correct 9 ms 66212 KB Output is correct
65 Correct 9 ms 66140 KB Output is correct
66 Correct 9 ms 66004 KB Output is correct
67 Correct 12 ms 66140 KB Output is correct
68 Correct 10 ms 66136 KB Output is correct
69 Correct 9 ms 66220 KB Output is correct
70 Correct 9 ms 66136 KB Output is correct
71 Correct 9 ms 66136 KB Output is correct
72 Correct 9 ms 66140 KB Output is correct
73 Correct 9 ms 66032 KB Output is correct
74 Correct 9 ms 66140 KB Output is correct
75 Correct 9 ms 66140 KB Output is correct
76 Correct 9 ms 66204 KB Output is correct
77 Correct 9 ms 65996 KB Output is correct
78 Correct 11 ms 66140 KB Output is correct
79 Correct 615 ms 90844 KB Output is correct
80 Correct 594 ms 89436 KB Output is correct
81 Correct 503 ms 89696 KB Output is correct
82 Correct 407 ms 86176 KB Output is correct
83 Correct 282 ms 86608 KB Output is correct
84 Correct 262 ms 86608 KB Output is correct
85 Correct 194 ms 86720 KB Output is correct
86 Correct 576 ms 89036 KB Output is correct
87 Correct 631 ms 92680 KB Output is correct
88 Correct 468 ms 88700 KB Output is correct
89 Correct 450 ms 89036 KB Output is correct
90 Correct 297 ms 89972 KB Output is correct
91 Correct 292 ms 90708 KB Output is correct
92 Correct 9 ms 66032 KB Output is correct
93 Correct 9 ms 66140 KB Output is correct
94 Correct 9 ms 65996 KB Output is correct
95 Correct 13 ms 66140 KB Output is correct
96 Correct 9 ms 66140 KB Output is correct
97 Correct 9 ms 66140 KB Output is correct
98 Correct 611 ms 93620 KB Output is correct
99 Correct 601 ms 90956 KB Output is correct
100 Correct 468 ms 92424 KB Output is correct
101 Correct 392 ms 90192 KB Output is correct
102 Correct 289 ms 90452 KB Output is correct
103 Correct 268 ms 90408 KB Output is correct
104 Correct 203 ms 88100 KB Output is correct
105 Correct 597 ms 92776 KB Output is correct
106 Correct 535 ms 90448 KB Output is correct
107 Correct 486 ms 88940 KB Output is correct
108 Correct 491 ms 87000 KB Output is correct
109 Correct 286 ms 87788 KB Output is correct
110 Correct 289 ms 88336 KB Output is correct
111 Correct 9 ms 66140 KB Output is correct
112 Correct 9 ms 65976 KB Output is correct
113 Correct 9 ms 66136 KB Output is correct
114 Correct 9 ms 66140 KB Output is correct
115 Correct 9 ms 66140 KB Output is correct
116 Correct 455 ms 87156 KB Output is correct
117 Correct 447 ms 87832 KB Output is correct
118 Correct 492 ms 92756 KB Output is correct
119 Correct 391 ms 88548 KB Output is correct
120 Correct 323 ms 88408 KB Output is correct
121 Correct 292 ms 88996 KB Output is correct
122 Correct 222 ms 89028 KB Output is correct
123 Correct 617 ms 92324 KB Output is correct
124 Correct 574 ms 89936 KB Output is correct
125 Correct 463 ms 88508 KB Output is correct
126 Correct 441 ms 87892 KB Output is correct
127 Correct 422 ms 88124 KB Output is correct
128 Correct 334 ms 88916 KB Output is correct
129 Correct 327 ms 89628 KB Output is correct