답안 #390623

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
390623 2021-04-16T12:15:50 Z AdOjis485 기지국 (IOI20_stations) C++17
100 / 100
1113 ms 956 KB
#include "stations.h"
#include <vector>
#include <iostream>
using namespace std;

void dfs(int v, int p, int type, int& cur, vector<int>& labels, vector<vector<int> >& adi)
{
	if(type == 0)
	{
		labels[v] = cur;
		cur ++;
	}
	for(int next : adi[v])
	{
		if(next == p) continue;
		dfs(next, v, !type, cur, labels, adi);
	}
	if(type == 1)
	{
		labels[v] = cur;
		cur ++;
	}
	cerr << v << " " << type << " " << labels[v] << '\n';
}

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

int find_next_station(int s, int t, vector<int> c)
{
	int ans;
	if(c[0] > s)
	{
		if(t < s) ans = c.back();
		else
		{
			int lo = -1, hi = c.size() - 1;
			while(lo + 1 < hi)
			{
				int m = (hi + lo) / 2;
				if(c[m] >= t) hi = m;
				else lo = m;
			}
			ans = c[hi];
		}
	}
	else
	{
		if(t > s) ans = c[0];
		else
		{
			int lo = 0, hi = c.size();
			while(lo + 1 < hi)
			{
				int m = (hi + lo) / 2;
				if(c[m] > t) hi = m;
				else lo = m;
			}
			ans = c[lo];
		}
	}
	//cerr << ans << '\n';
	return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 793 ms 684 KB Output is correct
2 Correct 664 ms 780 KB Output is correct
3 Correct 1075 ms 524 KB Output is correct
4 Correct 719 ms 400 KB Output is correct
5 Correct 690 ms 400 KB Output is correct
6 Correct 636 ms 748 KB Output is correct
7 Correct 596 ms 528 KB Output is correct
8 Correct 4 ms 480 KB Output is correct
9 Correct 5 ms 480 KB Output is correct
10 Correct 2 ms 472 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 641 ms 640 KB Output is correct
2 Correct 589 ms 524 KB Output is correct
3 Correct 1113 ms 404 KB Output is correct
4 Correct 804 ms 400 KB Output is correct
5 Correct 690 ms 404 KB Output is correct
6 Correct 657 ms 480 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 681 ms 768 KB Output is correct
2 Correct 751 ms 760 KB Output is correct
3 Correct 973 ms 492 KB Output is correct
4 Correct 824 ms 512 KB Output is correct
5 Correct 662 ms 408 KB Output is correct
6 Correct 689 ms 820 KB Output is correct
7 Correct 649 ms 620 KB Output is correct
8 Correct 4 ms 472 KB Output is correct
9 Correct 5 ms 480 KB Output is correct
10 Correct 2 ms 472 KB Output is correct
11 Correct 584 ms 552 KB Output is correct
12 Correct 646 ms 740 KB Output is correct
13 Correct 618 ms 692 KB Output is correct
14 Correct 609 ms 528 KB Output is correct
15 Correct 82 ms 416 KB Output is correct
16 Correct 125 ms 580 KB Output is correct
17 Correct 208 ms 692 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1018 ms 400 KB Output is correct
2 Correct 742 ms 488 KB Output is correct
3 Correct 709 ms 528 KB Output is correct
4 Correct 4 ms 480 KB Output is correct
5 Correct 6 ms 472 KB Output is correct
6 Correct 2 ms 480 KB Output is correct
7 Correct 637 ms 488 KB Output is correct
8 Correct 1065 ms 408 KB Output is correct
9 Correct 816 ms 500 KB Output is correct
10 Correct 713 ms 400 KB Output is correct
11 Correct 5 ms 472 KB Output is correct
12 Correct 8 ms 560 KB Output is correct
13 Correct 6 ms 528 KB Output is correct
14 Correct 5 ms 484 KB Output is correct
15 Correct 2 ms 472 KB Output is correct
16 Correct 589 ms 400 KB Output is correct
17 Correct 546 ms 400 KB Output is correct
18 Correct 533 ms 400 KB Output is correct
19 Correct 666 ms 404 KB Output is correct
20 Correct 624 ms 496 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 638 ms 708 KB Output is correct
2 Correct 657 ms 700 KB Output is correct
3 Correct 828 ms 404 KB Output is correct
4 Correct 676 ms 400 KB Output is correct
5 Correct 672 ms 500 KB Output is correct
6 Correct 666 ms 700 KB Output is correct
7 Correct 597 ms 532 KB Output is correct
8 Correct 3 ms 472 KB Output is correct
9 Correct 5 ms 472 KB Output is correct
10 Correct 2 ms 468 KB Output is correct
11 Correct 599 ms 652 KB Output is correct
12 Correct 706 ms 540 KB Output is correct
13 Correct 1075 ms 492 KB Output is correct
14 Correct 819 ms 404 KB Output is correct
15 Correct 728 ms 400 KB Output is correct
16 Correct 500 ms 492 KB Output is correct
17 Correct 644 ms 400 KB Output is correct
18 Correct 536 ms 896 KB Output is correct
19 Correct 674 ms 808 KB Output is correct
20 Correct 517 ms 576 KB Output is correct
21 Correct 76 ms 452 KB Output is correct
22 Correct 117 ms 592 KB Output is correct
23 Correct 231 ms 704 KB Output is correct
24 Correct 7 ms 480 KB Output is correct
25 Correct 7 ms 480 KB Output is correct
26 Correct 4 ms 480 KB Output is correct
27 Correct 4 ms 488 KB Output is correct
28 Correct 2 ms 484 KB Output is correct
29 Correct 605 ms 400 KB Output is correct
30 Correct 690 ms 400 KB Output is correct
31 Correct 532 ms 400 KB Output is correct
32 Correct 607 ms 400 KB Output is correct
33 Correct 671 ms 400 KB Output is correct
34 Correct 445 ms 820 KB Output is correct
35 Correct 572 ms 856 KB Output is correct
36 Correct 686 ms 936 KB Output is correct
37 Correct 585 ms 676 KB Output is correct
38 Correct 576 ms 772 KB Output is correct
39 Correct 560 ms 788 KB Output is correct
40 Correct 649 ms 956 KB Output is correct
41 Correct 608 ms 736 KB Output is correct
42 Correct 162 ms 808 KB Output is correct
43 Correct 239 ms 640 KB Output is correct
44 Correct 230 ms 676 KB Output is correct
45 Correct 280 ms 688 KB Output is correct
46 Correct 464 ms 608 KB Output is correct
47 Correct 470 ms 676 KB Output is correct
48 Correct 167 ms 620 KB Output is correct
49 Correct 154 ms 720 KB Output is correct