Submission #874310

# Submission time Handle Problem Language Result Execution time Memory
874310 2023-11-16T16:24:05 Z svorogaze Sprinkler (JOI22_sprinkler) C++17
100 / 100
662 ms 101116 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 10 ms 66140 KB Output is correct
2 Correct 10 ms 65968 KB Output is correct
3 Correct 10 ms 66052 KB Output is correct
4 Correct 11 ms 66204 KB Output is correct
5 Correct 11 ms 66208 KB Output is correct
6 Correct 11 ms 66140 KB Output is correct
7 Correct 12 ms 66148 KB Output is correct
8 Correct 11 ms 66140 KB Output is correct
9 Correct 10 ms 66140 KB Output is correct
10 Correct 10 ms 66140 KB Output is correct
11 Correct 10 ms 66140 KB Output is correct
12 Correct 10 ms 66140 KB Output is correct
13 Correct 10 ms 66140 KB Output is correct
14 Correct 10 ms 65988 KB Output is correct
15 Correct 11 ms 66140 KB Output is correct
16 Correct 10 ms 66036 KB Output is correct
17 Correct 10 ms 66140 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 66208 KB Output is correct
21 Correct 11 ms 66292 KB Output is correct
22 Correct 13 ms 66216 KB Output is correct
23 Correct 10 ms 66140 KB Output is correct
24 Correct 11 ms 66140 KB Output is correct
25 Correct 10 ms 66208 KB Output is correct
26 Correct 10 ms 66004 KB Output is correct
27 Correct 11 ms 66140 KB Output is correct
28 Correct 11 ms 66020 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11 ms 66140 KB Output is correct
2 Correct 467 ms 92976 KB Output is correct
3 Correct 258 ms 93700 KB Output is correct
4 Correct 427 ms 98268 KB Output is correct
5 Correct 393 ms 93268 KB Output is correct
6 Correct 274 ms 93036 KB Output is correct
7 Correct 260 ms 93592 KB Output is correct
8 Correct 213 ms 93884 KB Output is correct
9 Correct 542 ms 100976 KB Output is correct
10 Correct 285 ms 100692 KB Output is correct
11 Correct 462 ms 93108 KB Output is correct
12 Correct 271 ms 93560 KB Output is correct
13 Correct 165 ms 93588 KB Output is correct
14 Correct 184 ms 94396 KB Output is correct
15 Correct 170 ms 93380 KB Output is correct
16 Correct 177 ms 93780 KB Output is correct
17 Correct 185 ms 94332 KB Output is correct
18 Correct 10 ms 66140 KB Output is correct
19 Correct 10 ms 66140 KB Output is correct
20 Correct 11 ms 66140 KB Output is correct
21 Correct 12 ms 66036 KB Output is correct
22 Correct 10 ms 66140 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11 ms 66140 KB Output is correct
2 Correct 467 ms 92976 KB Output is correct
3 Correct 258 ms 93700 KB Output is correct
4 Correct 427 ms 98268 KB Output is correct
5 Correct 393 ms 93268 KB Output is correct
6 Correct 274 ms 93036 KB Output is correct
7 Correct 260 ms 93592 KB Output is correct
8 Correct 213 ms 93884 KB Output is correct
9 Correct 542 ms 100976 KB Output is correct
10 Correct 285 ms 100692 KB Output is correct
11 Correct 462 ms 93108 KB Output is correct
12 Correct 271 ms 93560 KB Output is correct
13 Correct 165 ms 93588 KB Output is correct
14 Correct 184 ms 94396 KB Output is correct
15 Correct 170 ms 93380 KB Output is correct
16 Correct 177 ms 93780 KB Output is correct
17 Correct 185 ms 94332 KB Output is correct
18 Correct 10 ms 66140 KB Output is correct
19 Correct 10 ms 66140 KB Output is correct
20 Correct 11 ms 66140 KB Output is correct
21 Correct 12 ms 66036 KB Output is correct
22 Correct 10 ms 66140 KB Output is correct
23 Correct 11 ms 66248 KB Output is correct
24 Correct 453 ms 93072 KB Output is correct
25 Correct 307 ms 93676 KB Output is correct
26 Correct 418 ms 101092 KB Output is correct
27 Correct 372 ms 93304 KB Output is correct
28 Correct 306 ms 93508 KB Output is correct
29 Correct 256 ms 93428 KB Output is correct
30 Correct 240 ms 93784 KB Output is correct
31 Correct 584 ms 98620 KB Output is correct
32 Correct 380 ms 101116 KB Output is correct
33 Correct 426 ms 92996 KB Output is correct
34 Correct 299 ms 93676 KB Output is correct
35 Correct 11 ms 66140 KB Output is correct
36 Correct 10 ms 66216 KB Output is correct
37 Correct 13 ms 66140 KB Output is correct
38 Correct 12 ms 66140 KB Output is correct
39 Correct 11 ms 66140 KB Output is correct
40 Correct 12 ms 66140 KB Output is correct
41 Correct 10 ms 66016 KB Output is correct
42 Correct 12 ms 66212 KB Output is correct
43 Correct 10 ms 66184 KB Output is correct
44 Correct 11 ms 66140 KB Output is correct
45 Correct 12 ms 66140 KB Output is correct
46 Correct 11 ms 66192 KB Output is correct
47 Correct 10 ms 66140 KB Output is correct
48 Correct 11 ms 66004 KB Output is correct
49 Correct 10 ms 66140 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 66140 KB Output is correct
2 Correct 626 ms 98064 KB Output is correct
3 Correct 566 ms 96888 KB Output is correct
4 Correct 509 ms 96340 KB Output is correct
5 Correct 412 ms 90452 KB Output is correct
6 Correct 307 ms 90452 KB Output is correct
7 Correct 272 ms 90576 KB Output is correct
8 Correct 214 ms 91048 KB Output is correct
9 Correct 604 ms 95428 KB Output is correct
10 Correct 580 ms 97760 KB Output is correct
11 Correct 446 ms 89940 KB Output is correct
12 Correct 487 ms 90972 KB Output is correct
13 Correct 293 ms 91748 KB Output is correct
14 Correct 297 ms 92552 KB Output is correct
15 Correct 11 ms 66140 KB Output is correct
16 Correct 12 ms 66000 KB Output is correct
17 Correct 11 ms 66140 KB Output is correct
18 Correct 10 ms 66140 KB Output is correct
19 Correct 11 ms 66140 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 66140 KB Output is correct
2 Correct 649 ms 97744 KB Output is correct
3 Correct 594 ms 94916 KB Output is correct
4 Correct 539 ms 96432 KB Output is correct
5 Correct 400 ms 91988 KB Output is correct
6 Correct 301 ms 92140 KB Output is correct
7 Correct 296 ms 91972 KB Output is correct
8 Correct 213 ms 91576 KB Output is correct
9 Correct 662 ms 100036 KB Output is correct
10 Correct 607 ms 98932 KB Output is correct
11 Correct 467 ms 92752 KB Output is correct
12 Correct 444 ms 91380 KB Output is correct
13 Correct 296 ms 91988 KB Output is correct
14 Correct 303 ms 92876 KB Output is correct
15 Correct 11 ms 66140 KB Output is correct
16 Correct 11 ms 66140 KB Output is correct
17 Correct 11 ms 66220 KB Output is correct
18 Correct 11 ms 66140 KB Output is correct
19 Correct 12 ms 65972 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 66140 KB Output is correct
2 Correct 10 ms 65968 KB Output is correct
3 Correct 10 ms 66052 KB Output is correct
4 Correct 11 ms 66204 KB Output is correct
5 Correct 11 ms 66208 KB Output is correct
6 Correct 11 ms 66140 KB Output is correct
7 Correct 12 ms 66148 KB Output is correct
8 Correct 11 ms 66140 KB Output is correct
9 Correct 10 ms 66140 KB Output is correct
10 Correct 10 ms 66140 KB Output is correct
11 Correct 10 ms 66140 KB Output is correct
12 Correct 10 ms 66140 KB Output is correct
13 Correct 10 ms 66140 KB Output is correct
14 Correct 10 ms 65988 KB Output is correct
15 Correct 11 ms 66140 KB Output is correct
16 Correct 10 ms 66036 KB Output is correct
17 Correct 10 ms 66140 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 66208 KB Output is correct
21 Correct 11 ms 66292 KB Output is correct
22 Correct 13 ms 66216 KB Output is correct
23 Correct 10 ms 66140 KB Output is correct
24 Correct 11 ms 66140 KB Output is correct
25 Correct 10 ms 66208 KB Output is correct
26 Correct 10 ms 66004 KB Output is correct
27 Correct 11 ms 66140 KB Output is correct
28 Correct 11 ms 66020 KB Output is correct
29 Correct 11 ms 66140 KB Output is correct
30 Correct 467 ms 92976 KB Output is correct
31 Correct 258 ms 93700 KB Output is correct
32 Correct 427 ms 98268 KB Output is correct
33 Correct 393 ms 93268 KB Output is correct
34 Correct 274 ms 93036 KB Output is correct
35 Correct 260 ms 93592 KB Output is correct
36 Correct 213 ms 93884 KB Output is correct
37 Correct 542 ms 100976 KB Output is correct
38 Correct 285 ms 100692 KB Output is correct
39 Correct 462 ms 93108 KB Output is correct
40 Correct 271 ms 93560 KB Output is correct
41 Correct 165 ms 93588 KB Output is correct
42 Correct 184 ms 94396 KB Output is correct
43 Correct 170 ms 93380 KB Output is correct
44 Correct 177 ms 93780 KB Output is correct
45 Correct 185 ms 94332 KB Output is correct
46 Correct 10 ms 66140 KB Output is correct
47 Correct 10 ms 66140 KB Output is correct
48 Correct 11 ms 66140 KB Output is correct
49 Correct 12 ms 66036 KB Output is correct
50 Correct 10 ms 66140 KB Output is correct
51 Correct 11 ms 66248 KB Output is correct
52 Correct 453 ms 93072 KB Output is correct
53 Correct 307 ms 93676 KB Output is correct
54 Correct 418 ms 101092 KB Output is correct
55 Correct 372 ms 93304 KB Output is correct
56 Correct 306 ms 93508 KB Output is correct
57 Correct 256 ms 93428 KB Output is correct
58 Correct 240 ms 93784 KB Output is correct
59 Correct 584 ms 98620 KB Output is correct
60 Correct 380 ms 101116 KB Output is correct
61 Correct 426 ms 92996 KB Output is correct
62 Correct 299 ms 93676 KB Output is correct
63 Correct 11 ms 66140 KB Output is correct
64 Correct 10 ms 66216 KB Output is correct
65 Correct 13 ms 66140 KB Output is correct
66 Correct 12 ms 66140 KB Output is correct
67 Correct 11 ms 66140 KB Output is correct
68 Correct 12 ms 66140 KB Output is correct
69 Correct 10 ms 66016 KB Output is correct
70 Correct 12 ms 66212 KB Output is correct
71 Correct 10 ms 66184 KB Output is correct
72 Correct 11 ms 66140 KB Output is correct
73 Correct 12 ms 66140 KB Output is correct
74 Correct 11 ms 66192 KB Output is correct
75 Correct 10 ms 66140 KB Output is correct
76 Correct 11 ms 66004 KB Output is correct
77 Correct 10 ms 66140 KB Output is correct
78 Correct 12 ms 66140 KB Output is correct
79 Correct 626 ms 98064 KB Output is correct
80 Correct 566 ms 96888 KB Output is correct
81 Correct 509 ms 96340 KB Output is correct
82 Correct 412 ms 90452 KB Output is correct
83 Correct 307 ms 90452 KB Output is correct
84 Correct 272 ms 90576 KB Output is correct
85 Correct 214 ms 91048 KB Output is correct
86 Correct 604 ms 95428 KB Output is correct
87 Correct 580 ms 97760 KB Output is correct
88 Correct 446 ms 89940 KB Output is correct
89 Correct 487 ms 90972 KB Output is correct
90 Correct 293 ms 91748 KB Output is correct
91 Correct 297 ms 92552 KB Output is correct
92 Correct 11 ms 66140 KB Output is correct
93 Correct 12 ms 66000 KB Output is correct
94 Correct 11 ms 66140 KB Output is correct
95 Correct 10 ms 66140 KB Output is correct
96 Correct 11 ms 66140 KB Output is correct
97 Correct 10 ms 66140 KB Output is correct
98 Correct 649 ms 97744 KB Output is correct
99 Correct 594 ms 94916 KB Output is correct
100 Correct 539 ms 96432 KB Output is correct
101 Correct 400 ms 91988 KB Output is correct
102 Correct 301 ms 92140 KB Output is correct
103 Correct 296 ms 91972 KB Output is correct
104 Correct 213 ms 91576 KB Output is correct
105 Correct 662 ms 100036 KB Output is correct
106 Correct 607 ms 98932 KB Output is correct
107 Correct 467 ms 92752 KB Output is correct
108 Correct 444 ms 91380 KB Output is correct
109 Correct 296 ms 91988 KB Output is correct
110 Correct 303 ms 92876 KB Output is correct
111 Correct 11 ms 66140 KB Output is correct
112 Correct 11 ms 66140 KB Output is correct
113 Correct 11 ms 66220 KB Output is correct
114 Correct 11 ms 66140 KB Output is correct
115 Correct 12 ms 65972 KB Output is correct
116 Correct 488 ms 91156 KB Output is correct
117 Correct 488 ms 93860 KB Output is correct
118 Correct 488 ms 100876 KB Output is correct
119 Correct 438 ms 93352 KB Output is correct
120 Correct 331 ms 93064 KB Output is correct
121 Correct 321 ms 93752 KB Output is correct
122 Correct 223 ms 93892 KB Output is correct
123 Correct 612 ms 99292 KB Output is correct
124 Correct 582 ms 98076 KB Output is correct
125 Correct 468 ms 92244 KB Output is correct
126 Correct 450 ms 93460 KB Output is correct
127 Correct 442 ms 94040 KB Output is correct
128 Correct 347 ms 94720 KB Output is correct
129 Correct 339 ms 95560 KB Output is correct