답안 #350805

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
350805 2021-01-19T08:31:11 Z juggernaut 기지국 (IOI20_stations) C++14
100 / 100
1071 ms 1292 KB
#include"stations.h"
#include<bits/stdc++.h>
using namespace std;
#ifndef EVAL
#include"stub.cpp"
#endif
vector<int>gr[1005];
vector<int>order;
int tiktak;
int tin[1005],tout[1005];
void dfs(int v,int p=-1,bool h=0){
	if(!h){
		tin[v]=tiktak++;
		order[v]=tin[v];
	}
	for(int to:gr[v]){
		if(to==p)continue;
		dfs(to,v,h^1);
	}
	if(h){
		tout[v]=tiktak++;
		order[v]=tout[v];
	}
}
vector<int>label(int n,int k,vector<int>u,vector<int>v){
	order.resize(n);
	for(int i=0;i<n-1;i++){
		gr[u[i]].push_back(v[i]);
		gr[v[i]].push_back(u[i]);
	}
	dfs(0);
	for(int i=0;i<n;i++)gr[i].clear();
	tiktak=0;
	return order;
}
int find_next_station(int s,int t,vector<int>c){
	if(c.size()==1)return c[0];
	int x,y;
	if(s<c[0]){//tin[v]
		x=s;
		if(s==0)y=c[c.size()-1];
		else y=c[c.size()-2];
		if(t<x||t>y)return c.back();
		for(int i=0;i<c.size();i++)if(t<=c[i])return c[i];
	}else{//tout[s]
		x=c[1]-1;
		if(t<x||t>s)return c[0];
		for(int i=c.size()-1;i>=1;i--)if(c[i]<=t)return c[i];
	}
}

Compilation message

stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:44:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |   for(int i=0;i<c.size();i++)if(t<=c[i])return c[i];
      |               ~^~~~~~~~~
stations.cpp:50:1: warning: control reaches end of non-void function [-Wreturn-type]
   50 | }
      | ^
# 결과 실행 시간 메모리 Grader output
1 Correct 564 ms 992 KB Output is correct
2 Correct 490 ms 992 KB Output is correct
3 Correct 1069 ms 896 KB Output is correct
4 Correct 1069 ms 864 KB Output is correct
5 Correct 764 ms 864 KB Output is correct
6 Correct 509 ms 1076 KB Output is correct
7 Correct 480 ms 992 KB Output is correct
8 Correct 3 ms 992 KB Output is correct
9 Correct 5 ms 944 KB Output is correct
10 Correct 2 ms 736 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 485 ms 864 KB Output is correct
2 Correct 644 ms 884 KB Output is correct
3 Correct 979 ms 736 KB Output is correct
4 Correct 890 ms 864 KB Output is correct
5 Correct 664 ms 864 KB Output is correct
6 Correct 454 ms 864 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 659 ms 1056 KB Output is correct
2 Correct 467 ms 1060 KB Output is correct
3 Correct 995 ms 896 KB Output is correct
4 Correct 686 ms 884 KB Output is correct
5 Correct 595 ms 864 KB Output is correct
6 Correct 438 ms 864 KB Output is correct
7 Correct 532 ms 1124 KB Output is correct
8 Correct 3 ms 952 KB Output is correct
9 Correct 5 ms 944 KB Output is correct
10 Correct 2 ms 864 KB Output is correct
11 Correct 766 ms 1120 KB Output is correct
12 Correct 736 ms 1012 KB Output is correct
13 Correct 470 ms 1052 KB Output is correct
14 Correct 468 ms 900 KB Output is correct
15 Correct 52 ms 864 KB Output is correct
16 Correct 75 ms 736 KB Output is correct
17 Correct 99 ms 876 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1071 ms 864 KB Output is correct
2 Correct 764 ms 912 KB Output is correct
3 Correct 621 ms 864 KB Output is correct
4 Correct 3 ms 864 KB Output is correct
5 Correct 5 ms 1072 KB Output is correct
6 Correct 2 ms 944 KB Output is correct
7 Correct 570 ms 864 KB Output is correct
8 Correct 859 ms 884 KB Output is correct
9 Correct 682 ms 736 KB Output is correct
10 Correct 549 ms 884 KB Output is correct
11 Correct 5 ms 864 KB Output is correct
12 Correct 5 ms 952 KB Output is correct
13 Correct 4 ms 992 KB Output is correct
14 Correct 4 ms 736 KB Output is correct
15 Correct 2 ms 992 KB Output is correct
16 Correct 535 ms 944 KB Output is correct
17 Correct 492 ms 864 KB Output is correct
18 Correct 637 ms 992 KB Output is correct
19 Correct 489 ms 864 KB Output is correct
20 Correct 504 ms 944 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 567 ms 944 KB Output is correct
2 Correct 442 ms 1068 KB Output is correct
3 Correct 1017 ms 864 KB Output is correct
4 Correct 732 ms 864 KB Output is correct
5 Correct 758 ms 864 KB Output is correct
6 Correct 441 ms 864 KB Output is correct
7 Correct 464 ms 1108 KB Output is correct
8 Correct 3 ms 864 KB Output is correct
9 Correct 5 ms 1072 KB Output is correct
10 Correct 2 ms 736 KB Output is correct
11 Correct 424 ms 900 KB Output is correct
12 Correct 657 ms 736 KB Output is correct
13 Correct 1025 ms 864 KB Output is correct
14 Correct 659 ms 864 KB Output is correct
15 Correct 634 ms 864 KB Output is correct
16 Correct 535 ms 736 KB Output is correct
17 Correct 619 ms 864 KB Output is correct
18 Correct 552 ms 1120 KB Output is correct
19 Correct 484 ms 1120 KB Output is correct
20 Correct 497 ms 992 KB Output is correct
21 Correct 62 ms 864 KB Output is correct
22 Correct 81 ms 1036 KB Output is correct
23 Correct 108 ms 864 KB Output is correct
24 Correct 5 ms 736 KB Output is correct
25 Correct 5 ms 864 KB Output is correct
26 Correct 6 ms 864 KB Output is correct
27 Correct 3 ms 736 KB Output is correct
28 Correct 3 ms 864 KB Output is correct
29 Correct 529 ms 736 KB Output is correct
30 Correct 576 ms 864 KB Output is correct
31 Correct 560 ms 944 KB Output is correct
32 Correct 616 ms 1044 KB Output is correct
33 Correct 602 ms 864 KB Output is correct
34 Correct 357 ms 1128 KB Output is correct
35 Correct 342 ms 992 KB Output is correct
36 Correct 634 ms 1292 KB Output is correct
37 Correct 391 ms 900 KB Output is correct
38 Correct 510 ms 1112 KB Output is correct
39 Correct 453 ms 1280 KB Output is correct
40 Correct 470 ms 1240 KB Output is correct
41 Correct 494 ms 1120 KB Output is correct
42 Correct 98 ms 864 KB Output is correct
43 Correct 129 ms 876 KB Output is correct
44 Correct 153 ms 864 KB Output is correct
45 Correct 187 ms 864 KB Output is correct
46 Correct 385 ms 1128 KB Output is correct
47 Correct 365 ms 1108 KB Output is correct
48 Correct 59 ms 992 KB Output is correct
49 Correct 73 ms 864 KB Output is correct