답안 #876862

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
876862 2023-11-22T12:44:53 Z serkanrashid Sprinkler (JOI22_sprinkler) C++14
3 / 100
4000 ms 16504 KB
#include <bits/stdc++.h>
#define endl "\n"

using namespace std;

const int maxn = 2*1e5+5;

long long n,l,q;
long long type,x,d,w;
long long h[maxn];
vector<int>g[maxn];

void dfs(int beg, int par, int rg)
{
    h[beg] = (h[beg]*w)%l;
    if(rg==d) return;
    for(int nb:g[beg])
    {
        if(nb!=par) dfs(nb,beg,rg+1);
    }
}

void read()
{
    cin >> n >> l;
    int a,b;
    for(int i=1;i<n;i++)
    {
        cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    for(int i=1;i<=n;i++) cin >> h[i];
    cin >> q;
    for(int i=1;i<=q;i++)
    {
        cin >> type >> x;
        if(type==2) cout << h[x] << endl;
        else
        {
            cin >> d >> w;
            dfs(x,x,0);
        }
    }
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	read();
return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4956 KB Output is correct
2 Correct 1 ms 4956 KB Output is correct
3 Correct 1 ms 4956 KB Output is correct
4 Correct 2 ms 5028 KB Output is correct
5 Correct 4 ms 5212 KB Output is correct
6 Correct 6 ms 4956 KB Output is correct
7 Correct 6 ms 5212 KB Output is correct
8 Correct 6 ms 5208 KB Output is correct
9 Correct 2 ms 4956 KB Output is correct
10 Correct 2 ms 4956 KB Output is correct
11 Correct 2 ms 4956 KB Output is correct
12 Correct 2 ms 4952 KB Output is correct
13 Correct 2 ms 4956 KB Output is correct
14 Correct 2 ms 4952 KB Output is correct
15 Correct 2 ms 4956 KB Output is correct
16 Correct 2 ms 4956 KB Output is correct
17 Correct 2 ms 4976 KB Output is correct
18 Correct 2 ms 4952 KB Output is correct
19 Correct 2 ms 4956 KB Output is correct
20 Correct 2 ms 5016 KB Output is correct
21 Correct 2 ms 4956 KB Output is correct
22 Correct 1 ms 4956 KB Output is correct
23 Correct 2 ms 4956 KB Output is correct
24 Correct 1 ms 4956 KB Output is correct
25 Correct 2 ms 4956 KB Output is correct
26 Correct 2 ms 4956 KB Output is correct
27 Correct 2 ms 4956 KB Output is correct
28 Correct 2 ms 4956 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4956 KB Output is correct
2 Correct 209 ms 16504 KB Output is correct
3 Correct 247 ms 13288 KB Output is correct
4 Correct 219 ms 14856 KB Output is correct
5 Correct 188 ms 14904 KB Output is correct
6 Correct 200 ms 14972 KB Output is correct
7 Correct 203 ms 15244 KB Output is correct
8 Correct 174 ms 15544 KB Output is correct
9 Correct 157 ms 16344 KB Output is correct
10 Correct 261 ms 13340 KB Output is correct
11 Correct 176 ms 16384 KB Output is correct
12 Correct 251 ms 13260 KB Output is correct
13 Execution timed out 4070 ms 13676 KB Time limit exceeded
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4956 KB Output is correct
2 Correct 209 ms 16504 KB Output is correct
3 Correct 247 ms 13288 KB Output is correct
4 Correct 219 ms 14856 KB Output is correct
5 Correct 188 ms 14904 KB Output is correct
6 Correct 200 ms 14972 KB Output is correct
7 Correct 203 ms 15244 KB Output is correct
8 Correct 174 ms 15544 KB Output is correct
9 Correct 157 ms 16344 KB Output is correct
10 Correct 261 ms 13340 KB Output is correct
11 Correct 176 ms 16384 KB Output is correct
12 Correct 251 ms 13260 KB Output is correct
13 Execution timed out 4070 ms 13676 KB Time limit exceeded
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 4956 KB Output is correct
2 Correct 509 ms 13728 KB Output is correct
3 Correct 2578 ms 12996 KB Output is correct
4 Correct 934 ms 13356 KB Output is correct
5 Correct 3372 ms 13416 KB Output is correct
6 Execution timed out 4056 ms 13140 KB Time limit exceeded
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4956 KB Output is correct
2 Correct 428 ms 16380 KB Output is correct
3 Correct 1877 ms 13328 KB Output is correct
4 Correct 716 ms 14932 KB Output is correct
5 Correct 3002 ms 14976 KB Output is correct
6 Execution timed out 4011 ms 13180 KB Time limit exceeded
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4956 KB Output is correct
2 Correct 1 ms 4956 KB Output is correct
3 Correct 1 ms 4956 KB Output is correct
4 Correct 2 ms 5028 KB Output is correct
5 Correct 4 ms 5212 KB Output is correct
6 Correct 6 ms 4956 KB Output is correct
7 Correct 6 ms 5212 KB Output is correct
8 Correct 6 ms 5208 KB Output is correct
9 Correct 2 ms 4956 KB Output is correct
10 Correct 2 ms 4956 KB Output is correct
11 Correct 2 ms 4956 KB Output is correct
12 Correct 2 ms 4952 KB Output is correct
13 Correct 2 ms 4956 KB Output is correct
14 Correct 2 ms 4952 KB Output is correct
15 Correct 2 ms 4956 KB Output is correct
16 Correct 2 ms 4956 KB Output is correct
17 Correct 2 ms 4976 KB Output is correct
18 Correct 2 ms 4952 KB Output is correct
19 Correct 2 ms 4956 KB Output is correct
20 Correct 2 ms 5016 KB Output is correct
21 Correct 2 ms 4956 KB Output is correct
22 Correct 1 ms 4956 KB Output is correct
23 Correct 2 ms 4956 KB Output is correct
24 Correct 1 ms 4956 KB Output is correct
25 Correct 2 ms 4956 KB Output is correct
26 Correct 2 ms 4956 KB Output is correct
27 Correct 2 ms 4956 KB Output is correct
28 Correct 2 ms 4956 KB Output is correct
29 Correct 1 ms 4956 KB Output is correct
30 Correct 209 ms 16504 KB Output is correct
31 Correct 247 ms 13288 KB Output is correct
32 Correct 219 ms 14856 KB Output is correct
33 Correct 188 ms 14904 KB Output is correct
34 Correct 200 ms 14972 KB Output is correct
35 Correct 203 ms 15244 KB Output is correct
36 Correct 174 ms 15544 KB Output is correct
37 Correct 157 ms 16344 KB Output is correct
38 Correct 261 ms 13340 KB Output is correct
39 Correct 176 ms 16384 KB Output is correct
40 Correct 251 ms 13260 KB Output is correct
41 Execution timed out 4070 ms 13676 KB Time limit exceeded
42 Halted 0 ms 0 KB -