답안 #308162

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
308162 2020-09-30T07:34:55 Z ainta 기지국 (IOI20_stations) C++17
100 / 100
1013 ms 1160 KB
#include "stations.h"
#include <vector>
#include <algorithm>
using namespace std;
vector<int>E[1010];

int Num[1010], cnt;

void DFS(int a, int pp, int dep){
	int i;
	if(!dep)Num[a]=++cnt;
	for(auto &x : E[a]){
		if(x==pp)continue;
		DFS(x,a,!dep);
	}
	if(dep)Num[a]=++cnt;
}

std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
	std::vector<int> labels(n);
	cnt = 0;
	for(int i=0;i<n;i++)E[i].clear();
	for (int i = 0; i < n; i++) {
		labels[i] = i;
	}
	for(int i=0;i<n-1;i++){
		E[u[i]].push_back(v[i]);
		E[v[i]].push_back(u[i]);
	}
	DFS(0,-1,0);
	for(int i=0;i<n;i++){
		labels[i] = Num[i]-1;
	}
	return labels;
}

bool Include(int a, int b){
}

int find_next_station(int s, int t, std::vector<int> c) {
	int i;
	int b = s, e = s;
	int sz =c.size();
	if(s < c[0]){
		if(sz>=2)e = c[sz-2];
		if(b<=t && t<=e){
			for(auto &x : c){
				if(x>=t)return x;
			}
		}
		return c[sz-1];
	}
	else{
		if(sz>=2)b = c[1];
		if(b<=t && t<=e){
			reverse(c.begin(),c.end());
			for(auto &x : c){
				if(x<=t)return x;
			}
		}
		return c[0];
	}
}

Compilation message

stations.cpp: In function 'void DFS(int, int, int)':
stations.cpp:10:6: warning: unused variable 'i' [-Wunused-variable]
   10 |  int i;
      |      ^
stations.cpp: In function 'bool Include(int, int)':
stations.cpp:38:1: warning: no return statement in function returning non-void [-Wreturn-type]
   38 | }
      | ^
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:41:6: warning: unused variable 'i' [-Wunused-variable]
   41 |  int i;
      |      ^
# 결과 실행 시간 메모리 Grader output
1 Correct 546 ms 772 KB Output is correct
2 Correct 467 ms 776 KB Output is correct
3 Correct 838 ms 884 KB Output is correct
4 Correct 660 ms 884 KB Output is correct
5 Correct 566 ms 884 KB Output is correct
6 Correct 440 ms 776 KB Output is correct
7 Correct 460 ms 792 KB Output is correct
8 Correct 2 ms 888 KB Output is correct
9 Correct 4 ms 892 KB Output is correct
10 Correct 1 ms 900 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 483 ms 896 KB Output is correct
2 Correct 592 ms 1048 KB Output is correct
3 Correct 1001 ms 1004 KB Output is correct
4 Correct 734 ms 884 KB Output is correct
5 Correct 654 ms 1012 KB Output is correct
6 Correct 506 ms 836 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 678 ms 768 KB Output is correct
2 Correct 505 ms 1040 KB Output is correct
3 Correct 872 ms 1008 KB Output is correct
4 Correct 719 ms 892 KB Output is correct
5 Correct 569 ms 768 KB Output is correct
6 Correct 457 ms 768 KB Output is correct
7 Correct 522 ms 796 KB Output is correct
8 Correct 3 ms 768 KB Output is correct
9 Correct 3 ms 896 KB Output is correct
10 Correct 1 ms 768 KB Output is correct
11 Correct 597 ms 884 KB Output is correct
12 Correct 503 ms 768 KB Output is correct
13 Correct 549 ms 772 KB Output is correct
14 Correct 443 ms 768 KB Output is correct
15 Correct 70 ms 768 KB Output is correct
16 Correct 73 ms 768 KB Output is correct
17 Correct 126 ms 836 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1013 ms 884 KB Output is correct
2 Correct 780 ms 768 KB Output is correct
3 Correct 590 ms 888 KB Output is correct
4 Correct 3 ms 768 KB Output is correct
5 Correct 5 ms 768 KB Output is correct
6 Correct 2 ms 768 KB Output is correct
7 Correct 586 ms 1032 KB Output is correct
8 Correct 863 ms 888 KB Output is correct
9 Correct 693 ms 892 KB Output is correct
10 Correct 592 ms 768 KB Output is correct
11 Correct 6 ms 896 KB Output is correct
12 Correct 6 ms 768 KB Output is correct
13 Correct 5 ms 768 KB Output is correct
14 Correct 4 ms 892 KB Output is correct
15 Correct 2 ms 768 KB Output is correct
16 Correct 507 ms 876 KB Output is correct
17 Correct 488 ms 888 KB Output is correct
18 Correct 509 ms 880 KB Output is correct
19 Correct 516 ms 888 KB Output is correct
20 Correct 507 ms 884 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 546 ms 1012 KB Output is correct
2 Correct 464 ms 776 KB Output is correct
3 Correct 904 ms 1024 KB Output is correct
4 Correct 660 ms 1136 KB Output is correct
5 Correct 609 ms 768 KB Output is correct
6 Correct 491 ms 764 KB Output is correct
7 Correct 461 ms 816 KB Output is correct
8 Correct 2 ms 768 KB Output is correct
9 Correct 4 ms 768 KB Output is correct
10 Correct 1 ms 884 KB Output is correct
11 Correct 548 ms 904 KB Output is correct
12 Correct 570 ms 824 KB Output is correct
13 Correct 891 ms 884 KB Output is correct
14 Correct 688 ms 884 KB Output is correct
15 Correct 613 ms 884 KB Output is correct
16 Correct 588 ms 768 KB Output is correct
17 Correct 601 ms 884 KB Output is correct
18 Correct 474 ms 888 KB Output is correct
19 Correct 531 ms 1008 KB Output is correct
20 Correct 515 ms 836 KB Output is correct
21 Correct 62 ms 800 KB Output is correct
22 Correct 82 ms 856 KB Output is correct
23 Correct 104 ms 768 KB Output is correct
24 Correct 6 ms 768 KB Output is correct
25 Correct 7 ms 768 KB Output is correct
26 Correct 6 ms 884 KB Output is correct
27 Correct 5 ms 768 KB Output is correct
28 Correct 2 ms 888 KB Output is correct
29 Correct 572 ms 768 KB Output is correct
30 Correct 574 ms 784 KB Output is correct
31 Correct 608 ms 768 KB Output is correct
32 Correct 501 ms 1008 KB Output is correct
33 Correct 493 ms 768 KB Output is correct
34 Correct 320 ms 784 KB Output is correct
35 Correct 504 ms 1124 KB Output is correct
36 Correct 484 ms 896 KB Output is correct
37 Correct 462 ms 916 KB Output is correct
38 Correct 467 ms 1160 KB Output is correct
39 Correct 473 ms 788 KB Output is correct
40 Correct 428 ms 780 KB Output is correct
41 Correct 471 ms 800 KB Output is correct
42 Correct 67 ms 768 KB Output is correct
43 Correct 146 ms 828 KB Output is correct
44 Correct 182 ms 1024 KB Output is correct
45 Correct 150 ms 768 KB Output is correct
46 Correct 333 ms 960 KB Output is correct
47 Correct 315 ms 800 KB Output is correct
48 Correct 67 ms 788 KB Output is correct
49 Correct 63 ms 772 KB Output is correct