Submission #892309

# Submission time Handle Problem Language Result Execution time Memory
892309 2023-12-25T07:09:05 Z vjudge1 Sprinkler (JOI22_sprinkler) C++17
3 / 100
4000 ms 22896 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) x.begin(), x.end()
#define size(x) (int)x.size()

template<class S, class T>
bool chmin(S &a, const T &b) {
    return a > b && (a = b) == b;
}
template<class S, class T>
bool chmax(S &a, const T &b) {
    return a < b && (a = b) == b;
}
const int inf = 1e9 + 7;
const int INF = 1e18 + 7;
const int mod = 998244353;
const int N = 2e5 + 1;

int n, l;
vector<int> g[N];
int h[N];

void dfs(int v, int p, int d, int bound, int w) {
    h[v] *= w;
    h[v] %= l;
    if (d == bound) return;
    for (int to : g[v]) {
        if (to != p) {
            dfs(to, v, d + 1, bound, w);
        }
    }
}

signed main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    cin >> n >> l;
    for (int i = 1; i < n; ++i) {
        int a, b;
        cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    for (int i = 1; i <= n; ++i) {
        cin >> h[i];
    }
    int q;
    cin >> q;
    while (q--) {
        int t;
        cin >> t;
        if (t == 1) {
            int v, d, w;
            cin >> v >> d >> w;
            dfs(v, -1, 0, d, w);
        } else {
            int v;
            cin >> v;
            cout << h[v] << '\n';
        }
    }
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 6488 KB Output is correct
2 Correct 2 ms 6488 KB Output is correct
3 Correct 2 ms 6492 KB Output is correct
4 Correct 2 ms 6492 KB Output is correct
5 Correct 3 ms 6492 KB Output is correct
6 Correct 5 ms 6492 KB Output is correct
7 Correct 6 ms 6580 KB Output is correct
8 Correct 6 ms 6492 KB Output is correct
9 Correct 2 ms 6492 KB Output is correct
10 Correct 2 ms 6488 KB Output is correct
11 Correct 3 ms 6492 KB Output is correct
12 Correct 2 ms 6492 KB Output is correct
13 Correct 2 ms 6492 KB Output is correct
14 Correct 2 ms 6492 KB Output is correct
15 Correct 2 ms 6492 KB Output is correct
16 Correct 2 ms 6488 KB Output is correct
17 Correct 2 ms 6492 KB Output is correct
18 Correct 2 ms 6492 KB Output is correct
19 Correct 2 ms 6492 KB Output is correct
20 Correct 2 ms 6492 KB Output is correct
21 Correct 2 ms 6492 KB Output is correct
22 Correct 2 ms 6492 KB Output is correct
23 Correct 2 ms 6492 KB Output is correct
24 Correct 2 ms 6492 KB Output is correct
25 Correct 2 ms 6492 KB Output is correct
26 Correct 2 ms 6536 KB Output is correct
27 Correct 2 ms 6488 KB Output is correct
28 Correct 2 ms 6488 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 6488 KB Output is correct
2 Correct 159 ms 17492 KB Output is correct
3 Correct 185 ms 14256 KB Output is correct
4 Correct 158 ms 14812 KB Output is correct
5 Correct 156 ms 15956 KB Output is correct
6 Correct 153 ms 15820 KB Output is correct
7 Correct 190 ms 16208 KB Output is correct
8 Correct 139 ms 16324 KB Output is correct
9 Correct 140 ms 16208 KB Output is correct
10 Correct 170 ms 13316 KB Output is correct
11 Correct 149 ms 17488 KB Output is correct
12 Correct 186 ms 14348 KB Output is correct
13 Execution timed out 4062 ms 14400 KB Time limit exceeded
14 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 6488 KB Output is correct
2 Correct 159 ms 17492 KB Output is correct
3 Correct 185 ms 14256 KB Output is correct
4 Correct 158 ms 14812 KB Output is correct
5 Correct 156 ms 15956 KB Output is correct
6 Correct 153 ms 15820 KB Output is correct
7 Correct 190 ms 16208 KB Output is correct
8 Correct 139 ms 16324 KB Output is correct
9 Correct 140 ms 16208 KB Output is correct
10 Correct 170 ms 13316 KB Output is correct
11 Correct 149 ms 17488 KB Output is correct
12 Correct 186 ms 14348 KB Output is correct
13 Execution timed out 4062 ms 14400 KB Time limit exceeded
14 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 6492 KB Output is correct
2 Correct 321 ms 13620 KB Output is correct
3 Correct 1468 ms 13168 KB Output is correct
4 Correct 541 ms 13516 KB Output is correct
5 Correct 2817 ms 22896 KB Output is correct
6 Execution timed out 4045 ms 18776 KB Time limit exceeded
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 6492 KB Output is correct
2 Correct 357 ms 16712 KB Output is correct
3 Correct 1523 ms 13500 KB Output is correct
4 Correct 534 ms 15044 KB Output is correct
5 Correct 2925 ms 15748 KB Output is correct
6 Execution timed out 4065 ms 14192 KB Time limit exceeded
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 6488 KB Output is correct
2 Correct 2 ms 6488 KB Output is correct
3 Correct 2 ms 6492 KB Output is correct
4 Correct 2 ms 6492 KB Output is correct
5 Correct 3 ms 6492 KB Output is correct
6 Correct 5 ms 6492 KB Output is correct
7 Correct 6 ms 6580 KB Output is correct
8 Correct 6 ms 6492 KB Output is correct
9 Correct 2 ms 6492 KB Output is correct
10 Correct 2 ms 6488 KB Output is correct
11 Correct 3 ms 6492 KB Output is correct
12 Correct 2 ms 6492 KB Output is correct
13 Correct 2 ms 6492 KB Output is correct
14 Correct 2 ms 6492 KB Output is correct
15 Correct 2 ms 6492 KB Output is correct
16 Correct 2 ms 6488 KB Output is correct
17 Correct 2 ms 6492 KB Output is correct
18 Correct 2 ms 6492 KB Output is correct
19 Correct 2 ms 6492 KB Output is correct
20 Correct 2 ms 6492 KB Output is correct
21 Correct 2 ms 6492 KB Output is correct
22 Correct 2 ms 6492 KB Output is correct
23 Correct 2 ms 6492 KB Output is correct
24 Correct 2 ms 6492 KB Output is correct
25 Correct 2 ms 6492 KB Output is correct
26 Correct 2 ms 6536 KB Output is correct
27 Correct 2 ms 6488 KB Output is correct
28 Correct 2 ms 6488 KB Output is correct
29 Correct 2 ms 6488 KB Output is correct
30 Correct 159 ms 17492 KB Output is correct
31 Correct 185 ms 14256 KB Output is correct
32 Correct 158 ms 14812 KB Output is correct
33 Correct 156 ms 15956 KB Output is correct
34 Correct 153 ms 15820 KB Output is correct
35 Correct 190 ms 16208 KB Output is correct
36 Correct 139 ms 16324 KB Output is correct
37 Correct 140 ms 16208 KB Output is correct
38 Correct 170 ms 13316 KB Output is correct
39 Correct 149 ms 17488 KB Output is correct
40 Correct 186 ms 14348 KB Output is correct
41 Execution timed out 4062 ms 14400 KB Time limit exceeded
42 Halted 0 ms 0 KB -