Submission #312006

# Submission time Handle Problem Language Result Execution time Memory
312006 2020-10-12T06:21:58 Z htc001 Stations (IOI20_stations) C++14
100 / 100
1085 ms 1140 KB
#include<bits/stdc++.h>
#include "stations.h"
using namespace std;

const int N=1005;
int tme;
vector<int> lab;
vector<int> nei[N];

void dfs(int x,int p,int lv){
	if(lv) lab[x-1]=tme++;
	for(int i=0;i<int(nei[x].size());i++){
		int to=nei[x][i];
		if(to!=p) dfs(to,x,lv^1);
	}
	if(!lv) lab[x-1]=tme++;
}

vector<int> label(int n,int k,vector<int> u,vector<int> v){
	lab.clear();
	lab.resize(n);
	tme=0;
	for(int i=0;i<N;i++) nei[i].clear();
	for(int i=0;i<n-1;i++){
		u[i]++;v[i]++;
//		printf("%d %d\n",u[i],v[i]);
		nei[u[i]].push_back(v[i]);
		nei[v[i]].push_back(u[i]);
	}
	dfs(1,-1,0);
	return lab;
}

int find_next_station(int s,int t,vector<int> c){
	vector<int>::iterator it;
	if(s<c[0]){
		if(s<t&&t<=c[int(c.size())-1]){
			it=lower_bound(c.begin(),c.end(),t);
			return *it;
		}else return c[int(c.size())-1];
	}else{
		if(c[0]<=t&&t<s){
			it=upper_bound(c.begin(),c.end(),t);
			it--;
			return *it;
		}else return c[0];
	}
}
# Verdict Execution time Memory Grader output
1 Correct 514 ms 1024 KB Output is correct
2 Correct 445 ms 1024 KB Output is correct
3 Correct 940 ms 784 KB Output is correct
4 Correct 660 ms 768 KB Output is correct
5 Correct 549 ms 876 KB Output is correct
6 Correct 496 ms 768 KB Output is correct
7 Correct 480 ms 780 KB Output is correct
8 Correct 3 ms 1140 KB Output is correct
9 Correct 5 ms 768 KB Output is correct
10 Correct 2 ms 768 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 565 ms 768 KB Output is correct
2 Correct 564 ms 768 KB Output is correct
3 Correct 1085 ms 884 KB Output is correct
4 Correct 682 ms 768 KB Output is correct
5 Correct 583 ms 872 KB Output is correct
6 Correct 459 ms 828 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 570 ms 1048 KB Output is correct
2 Correct 475 ms 1024 KB Output is correct
3 Correct 870 ms 876 KB Output is correct
4 Correct 690 ms 876 KB Output is correct
5 Correct 569 ms 888 KB Output is correct
6 Correct 485 ms 1008 KB Output is correct
7 Correct 466 ms 788 KB Output is correct
8 Correct 3 ms 768 KB Output is correct
9 Correct 4 ms 768 KB Output is correct
10 Correct 2 ms 768 KB Output is correct
11 Correct 586 ms 876 KB Output is correct
12 Correct 475 ms 1024 KB Output is correct
13 Correct 457 ms 1008 KB Output is correct
14 Correct 465 ms 768 KB Output is correct
15 Correct 57 ms 872 KB Output is correct
16 Correct 64 ms 836 KB Output is correct
17 Correct 106 ms 932 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 847 ms 880 KB Output is correct
2 Correct 848 ms 880 KB Output is correct
3 Correct 742 ms 1136 KB Output is correct
4 Correct 3 ms 768 KB Output is correct
5 Correct 5 ms 672 KB Output is correct
6 Correct 2 ms 908 KB Output is correct
7 Correct 742 ms 768 KB Output is correct
8 Correct 960 ms 784 KB Output is correct
9 Correct 655 ms 768 KB Output is correct
10 Correct 671 ms 768 KB Output is correct
11 Correct 5 ms 768 KB Output is correct
12 Correct 5 ms 768 KB Output is correct
13 Correct 7 ms 768 KB Output is correct
14 Correct 4 ms 768 KB Output is correct
15 Correct 1 ms 888 KB Output is correct
16 Correct 515 ms 768 KB Output is correct
17 Correct 663 ms 876 KB Output is correct
18 Correct 547 ms 768 KB Output is correct
19 Correct 519 ms 768 KB Output is correct
20 Correct 545 ms 876 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 578 ms 1024 KB Output is correct
2 Correct 488 ms 1012 KB Output is correct
3 Correct 898 ms 768 KB Output is correct
4 Correct 667 ms 768 KB Output is correct
5 Correct 611 ms 768 KB Output is correct
6 Correct 532 ms 1024 KB Output is correct
7 Correct 469 ms 792 KB Output is correct
8 Correct 3 ms 768 KB Output is correct
9 Correct 5 ms 876 KB Output is correct
10 Correct 2 ms 884 KB Output is correct
11 Correct 566 ms 768 KB Output is correct
12 Correct 645 ms 820 KB Output is correct
13 Correct 898 ms 872 KB Output is correct
14 Correct 712 ms 880 KB Output is correct
15 Correct 622 ms 876 KB Output is correct
16 Correct 455 ms 824 KB Output is correct
17 Correct 627 ms 876 KB Output is correct
18 Correct 517 ms 784 KB Output is correct
19 Correct 522 ms 1024 KB Output is correct
20 Correct 500 ms 828 KB Output is correct
21 Correct 61 ms 768 KB Output is correct
22 Correct 96 ms 768 KB Output is correct
23 Correct 115 ms 812 KB Output is correct
24 Correct 6 ms 876 KB Output is correct
25 Correct 6 ms 768 KB Output is correct
26 Correct 6 ms 768 KB Output is correct
27 Correct 5 ms 876 KB Output is correct
28 Correct 1 ms 880 KB Output is correct
29 Correct 548 ms 768 KB Output is correct
30 Correct 510 ms 872 KB Output is correct
31 Correct 552 ms 1008 KB Output is correct
32 Correct 661 ms 872 KB Output is correct
33 Correct 594 ms 1032 KB Output is correct
34 Correct 309 ms 1024 KB Output is correct
35 Correct 459 ms 1112 KB Output is correct
36 Correct 623 ms 1024 KB Output is correct
37 Correct 448 ms 772 KB Output is correct
38 Correct 523 ms 876 KB Output is correct
39 Correct 511 ms 768 KB Output is correct
40 Correct 561 ms 768 KB Output is correct
41 Correct 496 ms 784 KB Output is correct
42 Correct 84 ms 828 KB Output is correct
43 Correct 115 ms 768 KB Output is correct
44 Correct 143 ms 788 KB Output is correct
45 Correct 213 ms 796 KB Output is correct
46 Correct 348 ms 768 KB Output is correct
47 Correct 318 ms 768 KB Output is correct
48 Correct 64 ms 896 KB Output is correct
49 Correct 62 ms 1028 KB Output is correct