답안 #998410

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
998410 2024-06-14T00:11:50 Z efishel Sprinkler (JOI22_sprinkler) C++17
9 / 100
709 ms 59732 KB
//Emmanuel B
//Sprinker




#include <bits/stdc++.h>
using namespace std;
using lli=long long int;
#define pb push_back
#define deb(x) cout<<#x<<": "<<x<<endl;
#define deb2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl;


void dfs(lli n, lli par, vector<lli> &parent, vector<vector<lli>> &adj, vector<vector<lli>> &sons){
    parent[n]=par;
    for(lli x: adj[n]){
        if(x==par) continue;
        sons[n].pb(x);
        dfs(x,n,parent,adj,sons);
    }
}
lli L;
void update(lli n, lli p, vector<vector<lli>> &adj, lli c, vector<lli> &values, lli &w){
    if(c<0) return;
    values[n]*=w;
    values[n]%=L;
    if(c==0) return;
    for(lli x: adj[n]){
        if(x==p) continue;
        update(x,n,adj,c-1, values, w);
    }
}

int main(){
    lli N;
    cin>>N>>L;
    vector<vector<lli>> adj (N+5);
    for(lli i=0; i<N-1; ++i){
        lli a,b;
        cin>>a>>b;
        adj[a].pb(b);
        adj[b].pb(a);
    }
    vector<lli> parent (N+5);
    vector<vector<lli>> sons (N+5);
    vector<lli> mult1 (N+5,1);
    vector<lli> mult2 (N+5,1);
    dfs(1,0,parent,adj,sons);
    vector<lli> values (N+5);
    for(lli i=1; i<=N; ++i){
        cin>>values[i];
    }
    lli Q;
    cin>>Q;
    while(Q--){
        lli type;
        cin>>type;
        if(type==1){
            lli x,d,w;
            cin>>x>>d>>w;
            if(d==0){
                values[x]*=w;
                values[x]%=L;
            }
            else{
                values[x]*=w;
                values[x]%=L;
                mult1[x]*=w;
                mult1[x]%=L;
                if(x!=1){
                mult2[parent[x]]*=w;
                mult2[parent[x]]%=L;
                }
            }
        }
        else{
            lli x;
            cin>>x;
            lli ans=values[x]*mult2[x];
            ans%=L;
            if(x!=1){
            ans*=mult1[parent[x]];
            ans%=L;
            }
            cout<<ans<<endl;
        }
    }
    
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 703 ms 37764 KB Output is correct
3 Correct 449 ms 37200 KB Output is correct
4 Correct 594 ms 52348 KB Output is correct
5 Correct 546 ms 37456 KB Output is correct
6 Correct 571 ms 36852 KB Output is correct
7 Correct 555 ms 37028 KB Output is correct
8 Correct 549 ms 35308 KB Output is correct
9 Correct 668 ms 59732 KB Output is correct
10 Correct 506 ms 57604 KB Output is correct
11 Correct 672 ms 37804 KB Output is correct
12 Correct 452 ms 37252 KB Output is correct
13 Correct 411 ms 35268 KB Output is correct
14 Correct 389 ms 35748 KB Output is correct
15 Correct 412 ms 35336 KB Output is correct
16 Correct 430 ms 35312 KB Output is correct
17 Correct 419 ms 36180 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 448 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 703 ms 37764 KB Output is correct
3 Correct 449 ms 37200 KB Output is correct
4 Correct 594 ms 52348 KB Output is correct
5 Correct 546 ms 37456 KB Output is correct
6 Correct 571 ms 36852 KB Output is correct
7 Correct 555 ms 37028 KB Output is correct
8 Correct 549 ms 35308 KB Output is correct
9 Correct 668 ms 59732 KB Output is correct
10 Correct 506 ms 57604 KB Output is correct
11 Correct 672 ms 37804 KB Output is correct
12 Correct 452 ms 37252 KB Output is correct
13 Correct 411 ms 35268 KB Output is correct
14 Correct 389 ms 35748 KB Output is correct
15 Correct 412 ms 35336 KB Output is correct
16 Correct 430 ms 35312 KB Output is correct
17 Correct 419 ms 36180 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 448 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Incorrect 709 ms 37824 KB Output isn't correct
25 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 668 ms 58644 KB Output isn't correct
3 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 344 KB Output isn't correct
2 Halted 0 ms 0 KB -