Submission #986415

# Submission time Handle Problem Language Result Execution time Memory
986415 2024-05-20T12:59:53 Z Pyqe Stations (IOI20_stations) C++17
100 / 100
597 ms 1564 KB
#include "stations.h"
#include <bits/stdc++.h>

using namespace std;

long long nn,sq[1069];
vector<long long> al[1069];
bitset<1069> vtd;

void dfs(long long x,bool bad)
{
	long long i,sz=al[x].size(),l;
	
	vtd[x]=1;
	if(!bad)
	{
		sq[x]=nn;
		nn++;
	}
	for(i=0;i<sz;i++)
	{
		l=al[x][i];
		if(!vtd[l])
		{
			dfs(l,!bad);
		}
	}
	if(bad)
	{
		sq[x]=nn;
		nn++;
	}
}

vector<int> label(int n,int d,vector<int> ka,vector<int> la)
{
	long long i,k,l;
	vector<int> v;
	
	for(i=0;i<n;i++)
	{
		al[i].clear();
		vtd[i]=0;
	}
	for(i=0;i<n-1;i++)
	{
		k=ka[i];
		l=la[i];
		al[k].push_back(l);
		al[l].push_back(k);
	}
	nn=0;
	dfs(0,0);
	for(i=0;i<n;i++)
	{
		v.push_back(sq[i]);
	}
	return v;
}

int find_next_station(int x,int y,vector<int> a)
{
	long long i,sz=a.size();
	
	if(x>a[0])
	{
		x*=-1;
		y*=-1;
		for(i=0;i<sz;i++)
		{
			a[i]*=-1;
		}
	}
	sort(a.begin(),a.end());
	if(y<x||y>a[sz-1])
	{
		return abs(a[sz-1]);
	}
	else
	{
		return abs(*lower_bound(a.begin(),a.end(),y));
	}
}
# Verdict Execution time Memory Grader output
1 Correct 352 ms 1068 KB Output is correct
2 Correct 296 ms 940 KB Output is correct
3 Correct 590 ms 684 KB Output is correct
4 Correct 432 ms 684 KB Output is correct
5 Correct 390 ms 936 KB Output is correct
6 Correct 264 ms 924 KB Output is correct
7 Correct 292 ms 684 KB Output is correct
8 Correct 1 ms 764 KB Output is correct
9 Correct 2 ms 768 KB Output is correct
10 Correct 1 ms 768 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 299 ms 876 KB Output is correct
2 Correct 389 ms 820 KB Output is correct
3 Correct 597 ms 684 KB Output is correct
4 Correct 416 ms 684 KB Output is correct
5 Correct 367 ms 684 KB Output is correct
6 Correct 267 ms 884 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 367 ms 948 KB Output is correct
2 Correct 266 ms 944 KB Output is correct
3 Correct 594 ms 684 KB Output is correct
4 Correct 413 ms 692 KB Output is correct
5 Correct 415 ms 684 KB Output is correct
6 Correct 275 ms 920 KB Output is correct
7 Correct 249 ms 684 KB Output is correct
8 Correct 1 ms 768 KB Output is correct
9 Correct 2 ms 768 KB Output is correct
10 Correct 0 ms 764 KB Output is correct
11 Correct 342 ms 684 KB Output is correct
12 Correct 303 ms 1208 KB Output is correct
13 Correct 290 ms 1196 KB Output is correct
14 Correct 294 ms 684 KB Output is correct
15 Correct 30 ms 764 KB Output is correct
16 Correct 38 ms 888 KB Output is correct
17 Correct 61 ms 932 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 564 ms 936 KB Output is correct
2 Correct 410 ms 684 KB Output is correct
3 Correct 362 ms 684 KB Output is correct
4 Correct 1 ms 764 KB Output is correct
5 Correct 3 ms 768 KB Output is correct
6 Correct 1 ms 768 KB Output is correct
7 Correct 386 ms 940 KB Output is correct
8 Correct 563 ms 684 KB Output is correct
9 Correct 405 ms 684 KB Output is correct
10 Correct 413 ms 684 KB Output is correct
11 Correct 2 ms 768 KB Output is correct
12 Correct 4 ms 768 KB Output is correct
13 Correct 3 ms 768 KB Output is correct
14 Correct 1 ms 768 KB Output is correct
15 Correct 0 ms 768 KB Output is correct
16 Correct 299 ms 684 KB Output is correct
17 Correct 319 ms 684 KB Output is correct
18 Correct 295 ms 684 KB Output is correct
19 Correct 315 ms 684 KB Output is correct
20 Correct 332 ms 684 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 349 ms 936 KB Output is correct
2 Correct 307 ms 932 KB Output is correct
3 Correct 585 ms 684 KB Output is correct
4 Correct 442 ms 684 KB Output is correct
5 Correct 394 ms 684 KB Output is correct
6 Correct 281 ms 940 KB Output is correct
7 Correct 268 ms 684 KB Output is correct
8 Correct 1 ms 768 KB Output is correct
9 Correct 3 ms 768 KB Output is correct
10 Correct 0 ms 768 KB Output is correct
11 Correct 311 ms 880 KB Output is correct
12 Correct 355 ms 852 KB Output is correct
13 Correct 554 ms 684 KB Output is correct
14 Correct 453 ms 684 KB Output is correct
15 Correct 369 ms 684 KB Output is correct
16 Correct 288 ms 684 KB Output is correct
17 Correct 369 ms 684 KB Output is correct
18 Correct 291 ms 1040 KB Output is correct
19 Correct 288 ms 1320 KB Output is correct
20 Correct 274 ms 684 KB Output is correct
21 Correct 37 ms 732 KB Output is correct
22 Correct 37 ms 888 KB Output is correct
23 Correct 60 ms 924 KB Output is correct
24 Correct 3 ms 768 KB Output is correct
25 Correct 4 ms 768 KB Output is correct
26 Correct 3 ms 764 KB Output is correct
27 Correct 3 ms 768 KB Output is correct
28 Correct 1 ms 764 KB Output is correct
29 Correct 338 ms 684 KB Output is correct
30 Correct 332 ms 684 KB Output is correct
31 Correct 377 ms 684 KB Output is correct
32 Correct 368 ms 684 KB Output is correct
33 Correct 345 ms 684 KB Output is correct
34 Correct 263 ms 916 KB Output is correct
35 Correct 276 ms 1116 KB Output is correct
36 Correct 284 ms 1216 KB Output is correct
37 Correct 295 ms 1208 KB Output is correct
38 Correct 302 ms 1196 KB Output is correct
39 Correct 263 ms 1196 KB Output is correct
40 Correct 270 ms 1056 KB Output is correct
41 Correct 323 ms 1300 KB Output is correct
42 Correct 34 ms 1184 KB Output is correct
43 Correct 58 ms 956 KB Output is correct
44 Correct 88 ms 932 KB Output is correct
45 Correct 98 ms 940 KB Output is correct
46 Correct 173 ms 884 KB Output is correct
47 Correct 209 ms 916 KB Output is correct
48 Correct 35 ms 1296 KB Output is correct
49 Correct 38 ms 1564 KB Output is correct