답안 #396255

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
396255 2021-04-29T15:42:56 Z faresbasbs 기지국 (IOI20_stations) C++14
100 / 100
1117 ms 992 KB
#include <bits/stdc++.h>
#include "stations.h"
using namespace std;

void dfs(int curr , int par , int hi , vector<vector<int>> &graph , int &cnt , vector<int> &ret){
	if(hi%2 == 0){
		ret[curr] = cnt;
		cnt += 1;
	}
	for(auto i : graph[curr]){
		if(i == par){
			continue;
		}
		dfs(i,curr,hi+1,graph,cnt,ret);
	}
	if(hi%2 == 1){
		ret[curr] = cnt;
		cnt += 1;
	}
}

vector<int> label(int n , int k , vector<int> u , vector<int> v){
	vector<vector<int>> graph(1001);
	int cnt = 0;
	for(int i = 0 ; i < u.size() ; i += 1){
		graph[u[i]].push_back(v[i]);
		graph[v[i]].push_back(u[i]);
	}
	vector<int> labels(n);
	dfs(0,0,0,graph,cnt,labels);
	return labels;
}

int find_next_station(int s , int t , vector<int> c){
	sort(c.begin(),c.end());
	if(c.size() == 1){
		return c[0];
	}
	if(s < c[0]){
		if(t >= s && t <= c[c.size()-2]){
			for(int i = 0 ; i < c.size() ; i += 1){
				if(t <= c[i]){
					return c[i];
				}
			}
		}
		return c.back();
	}else{
		if(t <= s && t >= c[1]){
			for(int i = c.size()-1 ; i >= 0 ; i -= 1){
				if(t >= c[i]){
					return c[i];
				}
			}
		}
		return c[0];
	}
}

Compilation message

stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:25:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |  for(int i = 0 ; i < u.size() ; i += 1){
      |                  ~~^~~~~~~~~~
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:41:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |    for(int i = 0 ; i < c.size() ; i += 1){
      |                    ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 556 ms 600 KB Output is correct
2 Correct 527 ms 656 KB Output is correct
3 Correct 955 ms 492 KB Output is correct
4 Correct 874 ms 520 KB Output is correct
5 Correct 621 ms 564 KB Output is correct
6 Correct 606 ms 568 KB Output is correct
7 Correct 531 ms 624 KB Output is correct
8 Correct 3 ms 600 KB Output is correct
9 Correct 4 ms 600 KB Output is correct
10 Correct 2 ms 600 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 568 ms 496 KB Output is correct
2 Correct 661 ms 528 KB Output is correct
3 Correct 872 ms 556 KB Output is correct
4 Correct 949 ms 476 KB Output is correct
5 Correct 612 ms 564 KB Output is correct
6 Correct 530 ms 528 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 816 ms 608 KB Output is correct
2 Correct 471 ms 788 KB Output is correct
3 Correct 885 ms 616 KB Output is correct
4 Correct 763 ms 480 KB Output is correct
5 Correct 760 ms 520 KB Output is correct
6 Correct 580 ms 616 KB Output is correct
7 Correct 501 ms 664 KB Output is correct
8 Correct 4 ms 600 KB Output is correct
9 Correct 7 ms 588 KB Output is correct
10 Correct 2 ms 664 KB Output is correct
11 Correct 839 ms 500 KB Output is correct
12 Correct 516 ms 700 KB Output is correct
13 Correct 462 ms 992 KB Output is correct
14 Correct 516 ms 492 KB Output is correct
15 Correct 61 ms 548 KB Output is correct
16 Correct 54 ms 560 KB Output is correct
17 Correct 141 ms 528 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 974 ms 492 KB Output is correct
2 Correct 834 ms 520 KB Output is correct
3 Correct 556 ms 476 KB Output is correct
4 Correct 3 ms 600 KB Output is correct
5 Correct 6 ms 600 KB Output is correct
6 Correct 2 ms 604 KB Output is correct
7 Correct 845 ms 492 KB Output is correct
8 Correct 974 ms 480 KB Output is correct
9 Correct 647 ms 520 KB Output is correct
10 Correct 764 ms 576 KB Output is correct
11 Correct 4 ms 600 KB Output is correct
12 Correct 5 ms 600 KB Output is correct
13 Correct 5 ms 600 KB Output is correct
14 Correct 4 ms 580 KB Output is correct
15 Correct 5 ms 600 KB Output is correct
16 Correct 599 ms 528 KB Output is correct
17 Correct 567 ms 600 KB Output is correct
18 Correct 594 ms 528 KB Output is correct
19 Correct 545 ms 528 KB Output is correct
20 Correct 599 ms 528 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 622 ms 620 KB Output is correct
2 Correct 610 ms 596 KB Output is correct
3 Correct 1117 ms 484 KB Output is correct
4 Correct 743 ms 520 KB Output is correct
5 Correct 798 ms 492 KB Output is correct
6 Correct 516 ms 656 KB Output is correct
7 Correct 713 ms 644 KB Output is correct
8 Correct 3 ms 592 KB Output is correct
9 Correct 4 ms 600 KB Output is correct
10 Correct 2 ms 600 KB Output is correct
11 Correct 531 ms 468 KB Output is correct
12 Correct 687 ms 528 KB Output is correct
13 Correct 1087 ms 484 KB Output is correct
14 Correct 817 ms 564 KB Output is correct
15 Correct 626 ms 504 KB Output is correct
16 Correct 618 ms 528 KB Output is correct
17 Correct 681 ms 516 KB Output is correct
18 Correct 565 ms 608 KB Output is correct
19 Correct 474 ms 696 KB Output is correct
20 Correct 553 ms 580 KB Output is correct
21 Correct 67 ms 588 KB Output is correct
22 Correct 97 ms 728 KB Output is correct
23 Correct 140 ms 528 KB Output is correct
24 Correct 4 ms 608 KB Output is correct
25 Correct 7 ms 608 KB Output is correct
26 Correct 6 ms 760 KB Output is correct
27 Correct 4 ms 600 KB Output is correct
28 Correct 2 ms 600 KB Output is correct
29 Correct 515 ms 528 KB Output is correct
30 Correct 547 ms 492 KB Output is correct
31 Correct 634 ms 600 KB Output is correct
32 Correct 675 ms 592 KB Output is correct
33 Correct 475 ms 528 KB Output is correct
34 Correct 334 ms 612 KB Output is correct
35 Correct 515 ms 688 KB Output is correct
36 Correct 629 ms 680 KB Output is correct
37 Correct 556 ms 716 KB Output is correct
38 Correct 467 ms 556 KB Output is correct
39 Correct 493 ms 608 KB Output is correct
40 Correct 500 ms 636 KB Output is correct
41 Correct 537 ms 572 KB Output is correct
42 Correct 68 ms 508 KB Output is correct
43 Correct 132 ms 528 KB Output is correct
44 Correct 128 ms 532 KB Output is correct
45 Correct 204 ms 528 KB Output is correct
46 Correct 329 ms 600 KB Output is correct
47 Correct 385 ms 532 KB Output is correct
48 Correct 69 ms 532 KB Output is correct
49 Correct 68 ms 712 KB Output is correct