답안 #395931

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
395931 2021-04-29T08:32:47 Z jeroenodb 기지국 (IOI20_stations) C++14
100 / 100
1128 ms 784 KB
#include "stations.h"
#include "bits/stdc++.h"
using namespace std;
#define all(x) begin(x),end(x)
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }
template<typename T_container, typename T = typename enable_if<!is_same<T_container, string>::value, typename T_container::value_type>::type> ostream& operator<<(ostream &os, const T_container &v) { string sep; for (const T &x : v) os << sep << x, sep = " "; return os; }
#define debug(a) cerr << "(" << #a << ": " << a << ")\n";
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pi;
const int mxN = 1e5+1, oo = 1e9;
int cnt = 0;
void dfs(vvi& adj, vi& label, int at=0, int from=-1, bool odd = false) {
	if(!odd) label[at] = cnt++;
	for(int to: adj[at]) if(to!=from) {
		dfs(adj,label,to,at,!odd);
	}
	if(odd) label[at] = cnt++;
}
vi label(int n, int k, vector<int> u, vector<int> v) {
	vi labels(n);
	cnt=0;
	vvi adj(n);
	for(int i=0;i<n-1;++i) {
		adj[u[i]].push_back(v[i]);
		adj[v[i]].push_back(u[i]);
	}
	dfs(adj,labels);
	return labels;
}

int find_next_station(int s, int t, std::vector<int> c) {
	for(int to: c) if(to==t) return to;
	if(s<c[0]) {
		// s has in label
		int parentout = c.back();
		c.insert(c.begin(),s);
		int n = c.size();
		for(int i=1;i<n;++i) {
			if(c[i-1]< t and t<c[i]) {
				return c[i];
			}
		}
		return parentout;
	} else {
		// s has out label
		
		int parentin = c[0];
		c.push_back(s);
		int n = c.size();
		for(int i=2;i<n;++i) {
			if(c[i-1]<t and t <c[i]) {
				return c[i-1];
			}
		}
		return parentin;


	}
}
  
# 결과 실행 시간 메모리 Grader output
1 Correct 576 ms 612 KB Output is correct
2 Correct 486 ms 784 KB Output is correct
3 Correct 1027 ms 488 KB Output is correct
4 Correct 755 ms 400 KB Output is correct
5 Correct 756 ms 488 KB Output is correct
6 Correct 511 ms 528 KB Output is correct
7 Correct 562 ms 536 KB Output is correct
8 Correct 3 ms 472 KB Output is correct
9 Correct 4 ms 472 KB Output is correct
10 Correct 2 ms 472 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 495 ms 548 KB Output is correct
2 Correct 614 ms 528 KB Output is correct
3 Correct 944 ms 492 KB Output is correct
4 Correct 733 ms 488 KB Output is correct
5 Correct 744 ms 400 KB Output is correct
6 Correct 534 ms 556 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 556 ms 620 KB Output is correct
2 Correct 556 ms 648 KB Output is correct
3 Correct 1045 ms 520 KB Output is correct
4 Correct 775 ms 404 KB Output is correct
5 Correct 665 ms 404 KB Output is correct
6 Correct 459 ms 532 KB Output is correct
7 Correct 583 ms 612 KB Output is correct
8 Correct 3 ms 472 KB Output is correct
9 Correct 5 ms 468 KB Output is correct
10 Correct 2 ms 472 KB Output is correct
11 Correct 734 ms 400 KB Output is correct
12 Correct 576 ms 640 KB Output is correct
13 Correct 504 ms 684 KB Output is correct
14 Correct 542 ms 528 KB Output is correct
15 Correct 64 ms 432 KB Output is correct
16 Correct 63 ms 528 KB Output is correct
17 Correct 135 ms 544 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1117 ms 400 KB Output is correct
2 Correct 746 ms 492 KB Output is correct
3 Correct 752 ms 400 KB Output is correct
4 Correct 2 ms 472 KB Output is correct
5 Correct 4 ms 472 KB Output is correct
6 Correct 2 ms 472 KB Output is correct
7 Correct 638 ms 568 KB Output is correct
8 Correct 1071 ms 468 KB Output is correct
9 Correct 833 ms 556 KB Output is correct
10 Correct 725 ms 492 KB Output is correct
11 Correct 7 ms 472 KB Output is correct
12 Correct 6 ms 620 KB Output is correct
13 Correct 6 ms 472 KB Output is correct
14 Correct 6 ms 472 KB Output is correct
15 Correct 2 ms 476 KB Output is correct
16 Correct 656 ms 404 KB Output is correct
17 Correct 538 ms 400 KB Output is correct
18 Correct 470 ms 400 KB Output is correct
19 Correct 633 ms 400 KB Output is correct
20 Correct 500 ms 528 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 689 ms 528 KB Output is correct
2 Correct 586 ms 528 KB Output is correct
3 Correct 1128 ms 468 KB Output is correct
4 Correct 773 ms 400 KB Output is correct
5 Correct 788 ms 400 KB Output is correct
6 Correct 498 ms 684 KB Output is correct
7 Correct 641 ms 500 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 472 KB Output is correct
11 Correct 421 ms 524 KB Output is correct
12 Correct 580 ms 532 KB Output is correct
13 Correct 952 ms 400 KB Output is correct
14 Correct 840 ms 484 KB Output is correct
15 Correct 649 ms 492 KB Output is correct
16 Correct 663 ms 492 KB Output is correct
17 Correct 633 ms 400 KB Output is correct
18 Correct 599 ms 708 KB Output is correct
19 Correct 510 ms 620 KB Output is correct
20 Correct 475 ms 492 KB Output is correct
21 Correct 63 ms 416 KB Output is correct
22 Correct 91 ms 696 KB Output is correct
23 Correct 122 ms 528 KB Output is correct
24 Correct 7 ms 472 KB Output is correct
25 Correct 6 ms 472 KB Output is correct
26 Correct 6 ms 472 KB Output is correct
27 Correct 5 ms 472 KB Output is correct
28 Correct 2 ms 472 KB Output is correct
29 Correct 619 ms 400 KB Output is correct
30 Correct 659 ms 404 KB Output is correct
31 Correct 662 ms 492 KB Output is correct
32 Correct 586 ms 520 KB Output is correct
33 Correct 592 ms 400 KB Output is correct
34 Correct 412 ms 528 KB Output is correct
35 Correct 614 ms 744 KB Output is correct
36 Correct 425 ms 652 KB Output is correct
37 Correct 518 ms 652 KB Output is correct
38 Correct 437 ms 684 KB Output is correct
39 Correct 459 ms 528 KB Output is correct
40 Correct 472 ms 688 KB Output is correct
41 Correct 620 ms 680 KB Output is correct
42 Correct 78 ms 528 KB Output is correct
43 Correct 101 ms 548 KB Output is correct
44 Correct 169 ms 556 KB Output is correct
45 Correct 179 ms 528 KB Output is correct
46 Correct 393 ms 556 KB Output is correct
47 Correct 356 ms 520 KB Output is correct
48 Correct 77 ms 568 KB Output is correct
49 Correct 70 ms 656 KB Output is correct