답안 #433047

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
433047 2021-06-18T18:55:22 Z peuch 기지국 (IOI20_stations) C++17
100 / 100
899 ms 756 KB
#include "stations.h"
#include <bits/stdc++.h>
using namespace std;

int cnt;
vector<vector<int> > ar;
vector<int> ord;
vector<int> lbl;

void dfs(int cur, int pai, int prof){
	if(prof % 2 == 0) ord.push_back(cur);
	for(int i = 0; i < ar[cur].size(); i++){
		int viz = ar[cur][i];
		if(viz == pai) continue;
		dfs(viz, cur, prof + 1);
	}
	if(prof % 2 == 1) ord.push_back(cur);
}

vector<int> label(int n, int k, vector<int> u, vector<int> v) {
	ar = vector<vector<int> > (n);
	lbl = vector<int> (n);
	ord.clear();
	for(int i = 0; i < u.size(); i++){
		ar[u[i]].push_back(v[i]);
		ar[v[i]].push_back(u[i]);
	}
	dfs(0, 0, 0);
	assert(ord.size() == n);
	for(int i = 0; i < n; i++)
		lbl[ord[i]] = i;
	return lbl;
}

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

Compilation message

stations.cpp: In function 'void dfs(int, int, int)':
stations.cpp:12:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 |  for(int i = 0; i < ar[cur].size(); i++){
      |                 ~~^~~~~~~~~~~~~~~~
stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:24:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |  for(int i = 0; i < u.size(); i++){
      |                 ~~^~~~~~~~~~
In file included from /usr/include/c++/10/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from stations.cpp:2:
stations.cpp:29:20: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   29 |  assert(ord.size() == n);
      |         ~~~~~~~~~~~^~~~
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:40:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |   for(int i = 0; i < c.size(); i++)
      |                  ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 516 ms 620 KB Output is correct
2 Correct 446 ms 656 KB Output is correct
3 Correct 858 ms 400 KB Output is correct
4 Correct 651 ms 488 KB Output is correct
5 Correct 556 ms 524 KB Output is correct
6 Correct 442 ms 608 KB Output is correct
7 Correct 451 ms 476 KB Output is correct
8 Correct 3 ms 468 KB Output is correct
9 Correct 3 ms 468 KB Output is correct
10 Correct 1 ms 476 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 469 ms 528 KB Output is correct
2 Correct 520 ms 528 KB Output is correct
3 Correct 878 ms 400 KB Output is correct
4 Correct 638 ms 404 KB Output is correct
5 Correct 580 ms 400 KB Output is correct
6 Correct 434 ms 528 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 524 ms 712 KB Output is correct
2 Correct 414 ms 756 KB Output is correct
3 Correct 862 ms 484 KB Output is correct
4 Correct 576 ms 400 KB Output is correct
5 Correct 495 ms 400 KB Output is correct
6 Correct 405 ms 660 KB Output is correct
7 Correct 420 ms 528 KB Output is correct
8 Correct 3 ms 468 KB Output is correct
9 Correct 5 ms 468 KB Output is correct
10 Correct 1 ms 468 KB Output is correct
11 Correct 583 ms 496 KB Output is correct
12 Correct 462 ms 740 KB Output is correct
13 Correct 440 ms 640 KB Output is correct
14 Correct 483 ms 528 KB Output is correct
15 Correct 48 ms 452 KB Output is correct
16 Correct 61 ms 488 KB Output is correct
17 Correct 105 ms 528 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 779 ms 476 KB Output is correct
2 Correct 645 ms 400 KB Output is correct
3 Correct 613 ms 484 KB Output is correct
4 Correct 2 ms 468 KB Output is correct
5 Correct 4 ms 464 KB Output is correct
6 Correct 0 ms 468 KB Output is correct
7 Correct 607 ms 404 KB Output is correct
8 Correct 847 ms 400 KB Output is correct
9 Correct 642 ms 520 KB Output is correct
10 Correct 570 ms 520 KB Output is correct
11 Correct 5 ms 468 KB Output is correct
12 Correct 5 ms 476 KB Output is correct
13 Correct 4 ms 476 KB Output is correct
14 Correct 3 ms 472 KB Output is correct
15 Correct 2 ms 468 KB Output is correct
16 Correct 511 ms 400 KB Output is correct
17 Correct 487 ms 400 KB Output is correct
18 Correct 483 ms 484 KB Output is correct
19 Correct 474 ms 480 KB Output is correct
20 Correct 514 ms 404 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 529 ms 620 KB Output is correct
2 Correct 478 ms 608 KB Output is correct
3 Correct 899 ms 400 KB Output is correct
4 Correct 621 ms 424 KB Output is correct
5 Correct 582 ms 656 KB Output is correct
6 Correct 467 ms 656 KB Output is correct
7 Correct 408 ms 484 KB Output is correct
8 Correct 2 ms 468 KB Output is correct
9 Correct 4 ms 468 KB Output is correct
10 Correct 2 ms 468 KB Output is correct
11 Correct 444 ms 620 KB Output is correct
12 Correct 540 ms 656 KB Output is correct
13 Correct 874 ms 528 KB Output is correct
14 Correct 626 ms 400 KB Output is correct
15 Correct 580 ms 484 KB Output is correct
16 Correct 464 ms 556 KB Output is correct
17 Correct 567 ms 488 KB Output is correct
18 Correct 433 ms 608 KB Output is correct
19 Correct 439 ms 684 KB Output is correct
20 Correct 418 ms 484 KB Output is correct
21 Correct 56 ms 476 KB Output is correct
22 Correct 61 ms 576 KB Output is correct
23 Correct 97 ms 528 KB Output is correct
24 Correct 6 ms 468 KB Output is correct
25 Correct 6 ms 468 KB Output is correct
26 Correct 4 ms 468 KB Output is correct
27 Correct 3 ms 468 KB Output is correct
28 Correct 1 ms 452 KB Output is correct
29 Correct 493 ms 484 KB Output is correct
30 Correct 504 ms 496 KB Output is correct
31 Correct 453 ms 404 KB Output is correct
32 Correct 451 ms 484 KB Output is correct
33 Correct 512 ms 420 KB Output is correct
34 Correct 308 ms 676 KB Output is correct
35 Correct 390 ms 736 KB Output is correct
36 Correct 450 ms 608 KB Output is correct
37 Correct 487 ms 696 KB Output is correct
38 Correct 472 ms 692 KB Output is correct
39 Correct 477 ms 676 KB Output is correct
40 Correct 450 ms 696 KB Output is correct
41 Correct 473 ms 672 KB Output is correct
42 Correct 61 ms 564 KB Output is correct
43 Correct 91 ms 528 KB Output is correct
44 Correct 141 ms 528 KB Output is correct
45 Correct 139 ms 528 KB Output is correct
46 Correct 302 ms 528 KB Output is correct
47 Correct 349 ms 528 KB Output is correct
48 Correct 54 ms 528 KB Output is correct
49 Correct 63 ms 728 KB Output is correct