Submission #1097002

# Submission time Handle Problem Language Result Execution time Memory
1097002 2024-10-05T17:09:09 Z efishel Sprinkler (JOI22_sprinkler) C++17
3 / 100
4000 ms 26484 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector <ll>;
using ii = pair <ll, ll>;
using vii = vector <ii>;

const ll MAXN = 2E5+16;
vll adj[MAXN];
ll L;
vll ve;

void dfs (ll u, ll par, ll w, ll dis, ll maxD) {
    (ve[u] *= w) %= L;
    if (dis == maxD) return;
    for (ll v : adj[u]) {
        if (v == par) continue;
        dfs(v, u, w, dis+1, maxD);
    }
}

int main () {
    cin.tie(nullptr) -> sync_with_stdio(false);
    ll n;
    cin >> n >> L;
    for (ll i = 1; i < n; i++) {
        ll u, v;
        cin >> u >> v;
        u--; v--;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    ve = vll(n);
    for (ll &i : ve) cin >> i;
    ll Q;
    cin >> Q;
    for (ll q = 0; q < Q; q++) {
        char type;
        cin >> type;
        switch (type) {
            case '1':
            {ll u, maxD, w;
            cin >> u >> maxD >> w;
            u--;
            dfs(u, u, w, 0, maxD);}
            break;
            case '2':
            {ll u;
            cin >> u;
            u--;
            cout << ve[u] << '\n';}
            break;
        }
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4956 KB Output is correct
2 Correct 2 ms 5152 KB Output is correct
3 Correct 2 ms 4956 KB Output is correct
4 Correct 3 ms 5080 KB Output is correct
5 Correct 3 ms 5212 KB Output is correct
6 Correct 5 ms 5208 KB Output is correct
7 Correct 4 ms 5236 KB Output is correct
8 Correct 4 ms 5212 KB Output is correct
9 Correct 2 ms 5212 KB Output is correct
10 Correct 2 ms 4956 KB Output is correct
11 Correct 2 ms 4956 KB Output is correct
12 Correct 2 ms 4956 KB Output is correct
13 Correct 2 ms 4956 KB Output is correct
14 Correct 2 ms 4956 KB Output is correct
15 Correct 2 ms 4956 KB Output is correct
16 Correct 3 ms 5056 KB Output is correct
17 Correct 2 ms 4952 KB Output is correct
18 Correct 2 ms 4956 KB Output is correct
19 Correct 2 ms 4956 KB Output is correct
20 Correct 2 ms 5152 KB Output is correct
21 Correct 2 ms 4956 KB Output is correct
22 Correct 2 ms 5156 KB Output is correct
23 Correct 2 ms 4956 KB Output is correct
24 Correct 2 ms 5088 KB Output is correct
25 Correct 2 ms 4956 KB Output is correct
26 Correct 2 ms 4956 KB Output is correct
27 Correct 2 ms 4956 KB Output is correct
28 Correct 2 ms 4956 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4956 KB Output is correct
2 Correct 139 ms 25688 KB Output is correct
3 Correct 159 ms 26196 KB Output is correct
4 Correct 136 ms 24656 KB Output is correct
5 Correct 138 ms 25956 KB Output is correct
6 Correct 132 ms 25588 KB Output is correct
7 Correct 142 ms 26452 KB Output is correct
8 Correct 126 ms 26484 KB Output is correct
9 Correct 128 ms 24612 KB Output is correct
10 Correct 160 ms 24916 KB Output is correct
11 Correct 126 ms 25680 KB Output is correct
12 Correct 185 ms 26032 KB Output is correct
13 Execution timed out 4051 ms 18880 KB Time limit exceeded
14 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4956 KB Output is correct
2 Correct 139 ms 25688 KB Output is correct
3 Correct 159 ms 26196 KB Output is correct
4 Correct 136 ms 24656 KB Output is correct
5 Correct 138 ms 25956 KB Output is correct
6 Correct 132 ms 25588 KB Output is correct
7 Correct 142 ms 26452 KB Output is correct
8 Correct 126 ms 26484 KB Output is correct
9 Correct 128 ms 24612 KB Output is correct
10 Correct 160 ms 24916 KB Output is correct
11 Correct 126 ms 25680 KB Output is correct
12 Correct 185 ms 26032 KB Output is correct
13 Execution timed out 4051 ms 18880 KB Time limit exceeded
14 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4952 KB Output is correct
2 Correct 292 ms 21588 KB Output is correct
3 Correct 1688 ms 22364 KB Output is correct
4 Correct 547 ms 21840 KB Output is correct
5 Correct 2566 ms 22876 KB Output is correct
6 Execution timed out 4065 ms 18800 KB Time limit exceeded
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4952 KB Output is correct
2 Correct 288 ms 24400 KB Output is correct
3 Correct 1573 ms 22868 KB Output is correct
4 Correct 564 ms 23344 KB Output is correct
5 Correct 2564 ms 24628 KB Output is correct
6 Execution timed out 4050 ms 18804 KB Time limit exceeded
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4956 KB Output is correct
2 Correct 2 ms 5152 KB Output is correct
3 Correct 2 ms 4956 KB Output is correct
4 Correct 3 ms 5080 KB Output is correct
5 Correct 3 ms 5212 KB Output is correct
6 Correct 5 ms 5208 KB Output is correct
7 Correct 4 ms 5236 KB Output is correct
8 Correct 4 ms 5212 KB Output is correct
9 Correct 2 ms 5212 KB Output is correct
10 Correct 2 ms 4956 KB Output is correct
11 Correct 2 ms 4956 KB Output is correct
12 Correct 2 ms 4956 KB Output is correct
13 Correct 2 ms 4956 KB Output is correct
14 Correct 2 ms 4956 KB Output is correct
15 Correct 2 ms 4956 KB Output is correct
16 Correct 3 ms 5056 KB Output is correct
17 Correct 2 ms 4952 KB Output is correct
18 Correct 2 ms 4956 KB Output is correct
19 Correct 2 ms 4956 KB Output is correct
20 Correct 2 ms 5152 KB Output is correct
21 Correct 2 ms 4956 KB Output is correct
22 Correct 2 ms 5156 KB Output is correct
23 Correct 2 ms 4956 KB Output is correct
24 Correct 2 ms 5088 KB Output is correct
25 Correct 2 ms 4956 KB Output is correct
26 Correct 2 ms 4956 KB Output is correct
27 Correct 2 ms 4956 KB Output is correct
28 Correct 2 ms 4956 KB Output is correct
29 Correct 2 ms 4956 KB Output is correct
30 Correct 139 ms 25688 KB Output is correct
31 Correct 159 ms 26196 KB Output is correct
32 Correct 136 ms 24656 KB Output is correct
33 Correct 138 ms 25956 KB Output is correct
34 Correct 132 ms 25588 KB Output is correct
35 Correct 142 ms 26452 KB Output is correct
36 Correct 126 ms 26484 KB Output is correct
37 Correct 128 ms 24612 KB Output is correct
38 Correct 160 ms 24916 KB Output is correct
39 Correct 126 ms 25680 KB Output is correct
40 Correct 185 ms 26032 KB Output is correct
41 Execution timed out 4051 ms 18880 KB Time limit exceeded
42 Halted 0 ms 0 KB -