#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<long long, long long>
// jangan kebiasa kalah
// kalo OI, sampah aja dulu, tapi jangan menutup kemungkinan buat AC
long long n,l,tc,h[200069],level[200069],parent_node[200069],mul_par[200069];
vector<long long> adj[200069];
void dfs(long long x, long long p)
{
for(auto j : adj[x])
{
if(j == p) continue;
parent_node[j] = x;
dfs(j,x);
}
}
int main()
{
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
long long i,j;
cin>>n>>l;
for(i=1;i<n;i++)
{
long long u,v;
cin>>u>>v;
adj[u].push_back(v);
adj[v].push_back(u);
}
for(i=1;i<=n;i++)
{
mul_par[i] = 1ll;
cin>>h[i];
}
parent_node[1] = 1ll;
// dfs(1,-1);
cin>>tc;
while(tc--)
{
int typ;
long long x,d,w;
cin>>typ;
if(typ == 1)
{
cin>>x>>d>>w;
if(d == 0)
{
h[x] *= w;
if(h[x] >= l) {
h[x] %= l;
}
}
else
{
h[x] *= w;
if(h[x] >= l) {
h[x] %= l;
}
for(auto it:adj[x])
{
h[it] *= w;
if(h[it] >= l) {
h[it] %= l;
}
}
}
}
else
{
cin>>x;
cout<<h[x]<<'\n';
}
}
}
Compilation message
sprinkler.cpp: In function 'int main()':
sprinkler.cpp:28:17: warning: unused variable 'j' [-Wunused-variable]
28 | long long i,j;
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
4948 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
4948 KB |
Output is correct |
2 |
Correct |
165 ms |
18912 KB |
Output is correct |
3 |
Correct |
193 ms |
15836 KB |
Output is correct |
4 |
Correct |
185 ms |
16292 KB |
Output is correct |
5 |
Correct |
169 ms |
17400 KB |
Output is correct |
6 |
Correct |
168 ms |
17296 KB |
Output is correct |
7 |
Correct |
182 ms |
17804 KB |
Output is correct |
8 |
Correct |
164 ms |
17924 KB |
Output is correct |
9 |
Correct |
155 ms |
17740 KB |
Output is correct |
10 |
Correct |
216 ms |
14908 KB |
Output is correct |
11 |
Correct |
157 ms |
18880 KB |
Output is correct |
12 |
Correct |
185 ms |
15780 KB |
Output is correct |
13 |
Execution timed out |
4094 ms |
15848 KB |
Time limit exceeded |
14 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
4948 KB |
Output is correct |
2 |
Correct |
165 ms |
18912 KB |
Output is correct |
3 |
Correct |
193 ms |
15836 KB |
Output is correct |
4 |
Correct |
185 ms |
16292 KB |
Output is correct |
5 |
Correct |
169 ms |
17400 KB |
Output is correct |
6 |
Correct |
168 ms |
17296 KB |
Output is correct |
7 |
Correct |
182 ms |
17804 KB |
Output is correct |
8 |
Correct |
164 ms |
17924 KB |
Output is correct |
9 |
Correct |
155 ms |
17740 KB |
Output is correct |
10 |
Correct |
216 ms |
14908 KB |
Output is correct |
11 |
Correct |
157 ms |
18880 KB |
Output is correct |
12 |
Correct |
185 ms |
15780 KB |
Output is correct |
13 |
Execution timed out |
4094 ms |
15848 KB |
Time limit exceeded |
14 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
4948 KB |
Output is correct |
2 |
Incorrect |
155 ms |
17272 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
4948 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
4948 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |