Submission #312016

# Submission time Handle Problem Language Result Execution time Memory
312016 2020-10-12T06:35:47 Z MrGary Stations (IOI20_stations) C++17
100 / 100
1144 ms 1280 KB
/*
{
######################
#       Author       #
#        Gary        #
#        2020        #
######################
*/
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define POB pop_back
#define ff fflush(stdout)
#define fastio ios::sync_with_stdio(false)
#define R(a) cin>>a
#define R2(a,b) cin>>a>>b
#define check_min(a,b) a=min(a,b)
#define check_max(a,b) a=max(a,b)
#include "stations.h"
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
/*}
*/
vector<int> g[1001];
int id[1001];
int cnt=0;
void run(int now,int pre=0,int depth=1){
	if(depth) id[now]=cnt++;
	for(auto it:g[now]){
		if(it!=pre){
			run(it,now,depth^1);
		}
	}
	if(!depth) id[now]=cnt++;
}
std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
	std::vector<int> labels(n);
	cnt=0;
	rep(i,n)
		g[i].clear();
	rep(i,n-1)
		g[u[i]].PB(v[i]),g[v[i]].PB(u[i]);
	run(0); 
	rep(i,n)
		labels[i]=id[i];
	return labels;
}
int find_next_station(int s, int t, std::vector<int> c) {
	if(s<c[0]){
		if((s==0||(c.size()>=2&&t<=c[c.size()-2]))&&t>s){
			return *lower_bound(ALL(c),t);
		}
		return c.back();
	} 
	else{
		if(c.size()>=2&&t>=c[1]&&t<s){
			return *(upper_bound(ALL(c),t)-1); 
		}
		return c[0];
	}
	return 0;
}
//int main(){
//	fastio;
//	vector<int>v=label(4, 10, {2, 2,0}, {3, 0, 1});
////	cout<<find_next_station(4,3,{1,3,6})<<endl;
//	for(auto it:v) cout<<it<<' ';
//	cout<<endl;
//	cout<<find_next_station(2,1,{0,1})<<endl;
//	return 0;
//}
# Verdict Execution time Memory Grader output
1 Correct 552 ms 1024 KB Output is correct
2 Correct 527 ms 1008 KB Output is correct
3 Correct 752 ms 768 KB Output is correct
4 Correct 831 ms 800 KB Output is correct
5 Correct 753 ms 768 KB Output is correct
6 Correct 588 ms 1024 KB Output is correct
7 Correct 442 ms 772 KB Output is correct
8 Correct 3 ms 768 KB Output is correct
9 Correct 4 ms 832 KB Output is correct
10 Correct 1 ms 876 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 450 ms 780 KB Output is correct
2 Correct 513 ms 824 KB Output is correct
3 Correct 813 ms 876 KB Output is correct
4 Correct 656 ms 872 KB Output is correct
5 Correct 720 ms 800 KB Output is correct
6 Correct 468 ms 768 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 645 ms 1024 KB Output is correct
2 Correct 534 ms 1024 KB Output is correct
3 Correct 1144 ms 768 KB Output is correct
4 Correct 705 ms 868 KB Output is correct
5 Correct 802 ms 872 KB Output is correct
6 Correct 482 ms 1024 KB Output is correct
7 Correct 706 ms 768 KB Output is correct
8 Correct 4 ms 884 KB Output is correct
9 Correct 4 ms 876 KB Output is correct
10 Correct 1 ms 876 KB Output is correct
11 Correct 692 ms 768 KB Output is correct
12 Correct 633 ms 1008 KB Output is correct
13 Correct 601 ms 1024 KB Output is correct
14 Correct 564 ms 824 KB Output is correct
15 Correct 59 ms 872 KB Output is correct
16 Correct 69 ms 964 KB Output is correct
17 Correct 143 ms 768 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 911 ms 768 KB Output is correct
2 Correct 570 ms 880 KB Output is correct
3 Correct 613 ms 792 KB Output is correct
4 Correct 3 ms 768 KB Output is correct
5 Correct 6 ms 768 KB Output is correct
6 Correct 1 ms 768 KB Output is correct
7 Correct 631 ms 768 KB Output is correct
8 Correct 859 ms 868 KB Output is correct
9 Correct 700 ms 768 KB Output is correct
10 Correct 588 ms 868 KB Output is correct
11 Correct 6 ms 1012 KB Output is correct
12 Correct 6 ms 876 KB Output is correct
13 Correct 5 ms 872 KB Output is correct
14 Correct 4 ms 768 KB Output is correct
15 Correct 1 ms 768 KB Output is correct
16 Correct 550 ms 768 KB Output is correct
17 Correct 536 ms 876 KB Output is correct
18 Correct 516 ms 768 KB Output is correct
19 Correct 489 ms 868 KB Output is correct
20 Correct 487 ms 1000 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 543 ms 1008 KB Output is correct
2 Correct 456 ms 1144 KB Output is correct
3 Correct 903 ms 872 KB Output is correct
4 Correct 743 ms 768 KB Output is correct
5 Correct 625 ms 880 KB Output is correct
6 Correct 485 ms 1024 KB Output is correct
7 Correct 494 ms 784 KB Output is correct
8 Correct 3 ms 876 KB Output is correct
9 Correct 5 ms 768 KB Output is correct
10 Correct 1 ms 768 KB Output is correct
11 Correct 459 ms 812 KB Output is correct
12 Correct 526 ms 768 KB Output is correct
13 Correct 1136 ms 880 KB Output is correct
14 Correct 753 ms 768 KB Output is correct
15 Correct 628 ms 1052 KB Output is correct
16 Correct 497 ms 832 KB Output is correct
17 Correct 621 ms 872 KB Output is correct
18 Correct 475 ms 768 KB Output is correct
19 Correct 472 ms 1024 KB Output is correct
20 Correct 444 ms 824 KB Output is correct
21 Correct 61 ms 860 KB Output is correct
22 Correct 76 ms 1040 KB Output is correct
23 Correct 106 ms 936 KB Output is correct
24 Correct 6 ms 768 KB Output is correct
25 Correct 6 ms 888 KB Output is correct
26 Correct 5 ms 768 KB Output is correct
27 Correct 4 ms 768 KB Output is correct
28 Correct 2 ms 1000 KB Output is correct
29 Correct 536 ms 768 KB Output is correct
30 Correct 535 ms 768 KB Output is correct
31 Correct 508 ms 768 KB Output is correct
32 Correct 506 ms 876 KB Output is correct
33 Correct 515 ms 768 KB Output is correct
34 Correct 354 ms 1280 KB Output is correct
35 Correct 444 ms 1024 KB Output is correct
36 Correct 464 ms 1024 KB Output is correct
37 Correct 448 ms 776 KB Output is correct
38 Correct 518 ms 784 KB Output is correct
39 Correct 472 ms 768 KB Output is correct
40 Correct 522 ms 896 KB Output is correct
41 Correct 421 ms 884 KB Output is correct
42 Correct 74 ms 824 KB Output is correct
43 Correct 125 ms 808 KB Output is correct
44 Correct 181 ms 1024 KB Output is correct
45 Correct 197 ms 796 KB Output is correct
46 Correct 335 ms 820 KB Output is correct
47 Correct 379 ms 768 KB Output is correct
48 Correct 75 ms 980 KB Output is correct
49 Correct 74 ms 1024 KB Output is correct