Submission #910144

# Submission time Handle Problem Language Result Execution time Memory
910144 2024-01-18T00:09:50 Z vjudge1 Sprinkler (JOI22_sprinkler) C++17
0 / 100
1 ms 348 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

vector<vector<ll>> tree;
vector<ll> initialHeights;
vector<bool> visited;

void dfs(ll current, ll L, ll W, ll pos, ll size) {
    if (pos == size) return;

    ll newHeight = (initialHeights[current] * W) % L;
    initialHeights[current] = newHeight;
    visited[current] = true;

    for (ll neighbor : tree[current]) {
        if (!visited[neighbor]) {
            dfs(neighbor, L, W, pos + 1, size);
        }
    }
}

int main() {
    ll N, L;
    cin >> N >> L;

    tree.resize(N + 1);
    initialHeights.resize(N + 1);

    for (ll i = 1; i <= N - 1; ++i) {
        ll A, B;
        cin >> A >> B;
        tree[A].push_back(B);
        tree[B].push_back(A);
    }

    ll Q;
    cin >> Q;

    for (ll i = 1; i <= Q; ++i) {
        ll T;
        cin >> T;

        if (T == 1) {
            ll X, D, W;
            cin >> X >> D >> W;
            visited.assign(N + 1, false);  
            dfs(X, L, W, 0, D);
        } else if (T == 2) {
            ll X;
            cin >> X;
            cout << initialHeights[X] << endl;
        }
    }

    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 344 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 344 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -