답안 #1013357

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1013357 2024-07-03T12:51:52 Z 12345678 Sprinkler (JOI22_sprinkler) C++17
9 / 100
174 ms 32876 KB
#include <bits/stdc++.h>

using namespace std;

const int nx=2e5+5;

#define ll long long

ll n, u, v, q, l, h[nx], lz[nx], pa[nx], t, x, ds, w;
vector<ll> d[nx];

void dfs(int u, int p)
{
    pa[u]=p;
    for (auto v:d[u]) if (v!=p) dfs(v, u);
}
int main()
{
    cin.tie(NULL)->sync_with_stdio(false);
    cin>>n>>l;
    for (int i=1; i<n; i++) cin>>u>>v, d[u].push_back(v), d[v].push_back(u);
    for (int i=1; i<=n; i++) cin>>h[i], lz[i]=1;
    dfs(1, 1);
    cin>>q;
    while (q--)
    {
        cin>>t;
        if (t==1)
        {
            cin>>x>>ds>>w;
            if (ds==0) h[x]=(h[x]*w)%l;
            else
            {
                h[x]=(h[x]*w)%l;
                if (pa[x]!=x) h[pa[x]]=(h[pa[x]]*w)%l;
                lz[x]=(lz[x]*w)%l;
            }
        }
        else
        {
            cin>>u;
            if (pa[u]==u) cout<<h[u]<<'\n';
            else cout<<(h[u]*lz[pa[u]])%l<<'\n';
        }
    }
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 8792 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 8796 KB Output is correct
2 Correct 142 ms 28908 KB Output is correct
3 Correct 152 ms 29268 KB Output is correct
4 Correct 155 ms 31320 KB Output is correct
5 Correct 165 ms 29008 KB Output is correct
6 Correct 138 ms 28612 KB Output is correct
7 Correct 141 ms 29524 KB Output is correct
8 Correct 136 ms 29632 KB Output is correct
9 Correct 150 ms 32596 KB Output is correct
10 Correct 139 ms 32876 KB Output is correct
11 Correct 153 ms 28876 KB Output is correct
12 Correct 174 ms 29264 KB Output is correct
13 Correct 127 ms 29368 KB Output is correct
14 Correct 135 ms 29956 KB Output is correct
15 Correct 153 ms 29108 KB Output is correct
16 Correct 139 ms 29776 KB Output is correct
17 Correct 147 ms 30148 KB Output is correct
18 Correct 1 ms 8796 KB Output is correct
19 Correct 2 ms 8796 KB Output is correct
20 Correct 1 ms 8796 KB Output is correct
21 Correct 2 ms 8796 KB Output is correct
22 Correct 2 ms 8792 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 8796 KB Output is correct
2 Correct 142 ms 28908 KB Output is correct
3 Correct 152 ms 29268 KB Output is correct
4 Correct 155 ms 31320 KB Output is correct
5 Correct 165 ms 29008 KB Output is correct
6 Correct 138 ms 28612 KB Output is correct
7 Correct 141 ms 29524 KB Output is correct
8 Correct 136 ms 29632 KB Output is correct
9 Correct 150 ms 32596 KB Output is correct
10 Correct 139 ms 32876 KB Output is correct
11 Correct 153 ms 28876 KB Output is correct
12 Correct 174 ms 29264 KB Output is correct
13 Correct 127 ms 29368 KB Output is correct
14 Correct 135 ms 29956 KB Output is correct
15 Correct 153 ms 29108 KB Output is correct
16 Correct 139 ms 29776 KB Output is correct
17 Correct 147 ms 30148 KB Output is correct
18 Correct 1 ms 8796 KB Output is correct
19 Correct 2 ms 8796 KB Output is correct
20 Correct 1 ms 8796 KB Output is correct
21 Correct 2 ms 8796 KB Output is correct
22 Correct 2 ms 8792 KB Output is correct
23 Correct 1 ms 8796 KB Output is correct
24 Incorrect 143 ms 28820 KB Output isn't correct
25 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 9052 KB Output is correct
2 Incorrect 136 ms 23904 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 8796 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 8792 KB Output isn't correct
2 Halted 0 ms 0 KB -