답안 #910138

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
910138 2024-01-18T00:04:12 Z vjudge1 Sprinkler (JOI22_sprinkler) C++17
0 / 100
799 ms 22136 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 parent, ll L, ll W, ll pos, ll size) {
    if(size==pos)return;
    ll newHeight = (initialHeights[current] * W) % L;
    initialHeights[current] = newHeight;
    visited[current]=true;
    for (ll neighbor : tree[current]) {
        if (neighbor != parent&&!visited[neighbor]) {
            dfs(neighbor, current, 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);
    }
    for (ll i = 1; i <= N; ++i) {
        cin >> initialHeights[i];
    }
    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.resize(N,false);
            dfs(X, 0, L, W,0,D);
        } else if (T == 2) {
            ll X;
            cin >> X;
            cout << initialHeights[X] << endl;
        }
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Incorrect 799 ms 22136 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -