/* Quick Note :
* Jangan Mikir Lama - lama, sampahin dulu aja kalo OI
* Always Try to reset
*/
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
#define debug(val) cerr << "The value of " << #val << " is = " << val << '\n';
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
const ld PI = 4*atan((ld)1);
const ll mod = 1e9 + 7;
const ll inf = 922337203685477;
const ll nax = 2e5 + 5;
ll n, q, l;
ll a[nax], updRange[nax], par[nax];
vector<vector<ll>> v(nax);
void find_par(ll idx, ll bfr){
par[idx] = bfr;
for(auto it : v[idx]){
if(it != bfr){
find_par(it, idx);
}
}
}
void upd_val(ll x, ll d){
if(d < 0 || x == 0) return;
updRange[x] = max(updRange[x], d);
upd_val(par[x], d - 1);
}
ll que_val(ll x, ll d){
if(x == 0 || d > 45) return 0;
if(updRange[x] >= d){
return 1;
}
else{
return que_val(par[x], d + 1);
}
}
int main(){
ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
//freopen("test.in", "r", stdin);
//freopen("test.out", "w", stdout);
cin >> n >> l;
for(ll i = 1; i < n; i++){
ll x, y;
cin >> x >> y;
v[x].pb(y);
v[y].pb(x);
}
for(ll i = 1; i <= n; i++){
cin >> a[i];
}
find_par(1, 0);
memset(updRange, -1, sizeof(updRange));
cin >> q;
while(q--){
ll tp, x, d, w;
cin >> tp;
if(tp == 1){
cin >> x >> d >> w;
upd_val(x, d);
}
else{
cin >> x;
if(que_val(x, 0)){
cout << 0 << '\n';
}
else{
cout << a[x] << '\n';
}
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
6484 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
6484 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
6484 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
6484 KB |
Output is correct |
2 |
Correct |
236 ms |
22168 KB |
Output is correct |
3 |
Correct |
426 ms |
20056 KB |
Output is correct |
4 |
Correct |
305 ms |
20680 KB |
Output is correct |
5 |
Correct |
295 ms |
17368 KB |
Output is correct |
6 |
Correct |
225 ms |
17568 KB |
Output is correct |
7 |
Correct |
215 ms |
17736 KB |
Output is correct |
8 |
Correct |
181 ms |
17900 KB |
Output is correct |
9 |
Correct |
433 ms |
20612 KB |
Output is correct |
10 |
Correct |
475 ms |
20908 KB |
Output is correct |
11 |
Correct |
218 ms |
17744 KB |
Output is correct |
12 |
Correct |
390 ms |
17088 KB |
Output is correct |
13 |
Correct |
231 ms |
17868 KB |
Output is correct |
14 |
Correct |
268 ms |
18748 KB |
Output is correct |
15 |
Correct |
3 ms |
6484 KB |
Output is correct |
16 |
Correct |
4 ms |
6484 KB |
Output is correct |
17 |
Correct |
4 ms |
6484 KB |
Output is correct |
18 |
Correct |
3 ms |
6484 KB |
Output is correct |
19 |
Correct |
3 ms |
6484 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
6484 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
6484 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |