Submission #588864

# Submission time Handle Problem Language Result Execution time Memory
588864 2022-07-04T06:40:54 Z Tekor Sprinkler (JOI22_sprinkler) C++17
12 / 100
2318 ms 75636 KB
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define ll long long
#define f first
#define s second
#define pii pair <int,int>
#define en '\n'
void boos() {
	ios_base :: sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}
const int N = 4e5 + 100;
vector <int> g[N];
pii c[N];
ll a[N],L;
int d[N][50];
int n;
void dfs(int v,int p,int k) {
	for(auto to : g[v]) {
		d[to][k - 1] = min(d[to][k - 1],d[v][k]);
		if(to == p)continue;
		dfs(to,v,k);
	}
}
void solve() {
	cin >> n >> L;
	for(int i = 1;i <= n;i++) {
		for(int j = 0;j <= 40;j++)d[i][j] = N;
	}
	for(int i = 1;i < n;i++) {
		int x,y;
		cin >> x >> y;
		g[x].pb(y);
		g[y].pb(x);
	}
	for(int i = 1;i <= n;i++)cin >> a[i];
	int q;
	cin >> q;
	int l = 1;
	for(int i = 1;i <= q;i++) {
		cin >> c[i].f;
		if(c[i].f == 1) {
			int x,dist;
			ll w;
			cin >> x >> dist >> w;
			for(int j = dist;j >= 0;j--)d[x][j] = min(d[x][j],i);
		}else cin >> c[i].s;
		
	}
	for(int i = 40;i >= 1;i--)dfs(1,-1,i);
	for(int i = 1;i <= n;i++) {
		for(int j = 39;j >= 0;j--) {
			d[i][j] = min(d[i][j],d[i][j + 1]);
		}
	}
	for(int i = 1;i <= q;i++) {
		if(c[i].f == 2) {
			if(d[c[i].s][0] <= i) {
				cout << 0 << en;
			}else {
				cout << a[c[i].s] << en;
			}
		}
	}
}

int main() {
	boos();
	int ttt;
	ttt = 1;
	while(ttt--) {
		solve();
	}
}

Compilation message

sprinkler.cpp: In function 'void solve()':
sprinkler.cpp:42:6: warning: unused variable 'l' [-Wunused-variable]
   42 |  int l = 1;
      |      ^
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 9684 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 9684 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 9684 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 9684 KB Output is correct
2 Correct 2188 ms 75636 KB Output is correct
3 Correct 2318 ms 71120 KB Output is correct
4 Correct 2205 ms 72272 KB Output is correct
5 Correct 1687 ms 60332 KB Output is correct
6 Correct 1700 ms 60416 KB Output is correct
7 Correct 1658 ms 60560 KB Output is correct
8 Correct 822 ms 61092 KB Output is correct
9 Correct 2149 ms 71336 KB Output is correct
10 Correct 2269 ms 73532 KB Output is correct
11 Correct 1717 ms 60612 KB Output is correct
12 Correct 1857 ms 59988 KB Output is correct
13 Correct 1489 ms 60988 KB Output is correct
14 Correct 1561 ms 61420 KB Output is correct
15 Correct 5 ms 9684 KB Output is correct
16 Correct 5 ms 9684 KB Output is correct
17 Correct 5 ms 9684 KB Output is correct
18 Correct 6 ms 9684 KB Output is correct
19 Correct 5 ms 9684 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 9684 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 9684 KB Output isn't correct
2 Halted 0 ms 0 KB -