답안 #589821

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
589821 2022-07-05T10:29:32 Z Lucpp 기지국 (IOI20_stations) C++17
100 / 100
916 ms 756 KB
#include "stations.h"
#include <bits/stdc++.h>
using namespace std;

vector<vector<int>> g;
int cnt;
vector<int> labels;

void dfs(int u, int par, bool b){
	if(b) labels[u] = cnt++;
	for(int v : g[u]){
		if(v == par) continue;
		dfs(v, u, !b);
	}
	if(!b) labels[u] = cnt++;
}

vector<int> label(int n, int k, vector<int> u, vector<int> v) {
	cnt = 0;
	g.clear();
	g.resize(n);
	for(int i = 0; i < n-1; i++){
		g[u[i]].push_back(v[i]);
		g[v[i]].push_back(u[i]);
	}
	labels.assign(n, -1);
	dfs(0, -1, true);
	return labels;
}

int find_next_station(int s, int t, vector<int> c) {
	int n = (int)c.size();
	if(s < c[0]){ // IN node
		if(t < s) return c[n-1];
		for(int i = 0; i < n-1; i++){
			if(t <= c[i]) return c[i];
		}
		return c[n-1];
	}
	else{
		if(t > s) return c[0];
		for(int i = n-1; i > 0; i--){
			if(c[i] <= t) return c[i];
		}
		return c[0];
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 505 ms 668 KB Output is correct
2 Correct 395 ms 632 KB Output is correct
3 Correct 843 ms 504 KB Output is correct
4 Correct 690 ms 488 KB Output is correct
5 Correct 622 ms 492 KB Output is correct
6 Correct 437 ms 616 KB Output is correct
7 Correct 401 ms 632 KB Output is correct
8 Correct 2 ms 492 KB Output is correct
9 Correct 4 ms 492 KB Output is correct
10 Correct 0 ms 492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 466 ms 596 KB Output is correct
2 Correct 546 ms 496 KB Output is correct
3 Correct 916 ms 416 KB Output is correct
4 Correct 766 ms 496 KB Output is correct
5 Correct 582 ms 416 KB Output is correct
6 Correct 519 ms 500 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 547 ms 636 KB Output is correct
2 Correct 472 ms 608 KB Output is correct
3 Correct 855 ms 416 KB Output is correct
4 Correct 648 ms 416 KB Output is correct
5 Correct 555 ms 420 KB Output is correct
6 Correct 431 ms 608 KB Output is correct
7 Correct 426 ms 632 KB Output is correct
8 Correct 3 ms 444 KB Output is correct
9 Correct 3 ms 500 KB Output is correct
10 Correct 2 ms 492 KB Output is correct
11 Correct 531 ms 500 KB Output is correct
12 Correct 513 ms 740 KB Output is correct
13 Correct 416 ms 704 KB Output is correct
14 Correct 415 ms 540 KB Output is correct
15 Correct 50 ms 416 KB Output is correct
16 Correct 56 ms 568 KB Output is correct
17 Correct 97 ms 588 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 802 ms 416 KB Output is correct
2 Correct 551 ms 504 KB Output is correct
3 Correct 535 ms 420 KB Output is correct
4 Correct 2 ms 496 KB Output is correct
5 Correct 3 ms 500 KB Output is correct
6 Correct 0 ms 492 KB Output is correct
7 Correct 471 ms 500 KB Output is correct
8 Correct 819 ms 420 KB Output is correct
9 Correct 535 ms 540 KB Output is correct
10 Correct 510 ms 420 KB Output is correct
11 Correct 4 ms 500 KB Output is correct
12 Correct 3 ms 500 KB Output is correct
13 Correct 5 ms 492 KB Output is correct
14 Correct 4 ms 500 KB Output is correct
15 Correct 2 ms 500 KB Output is correct
16 Correct 409 ms 416 KB Output is correct
17 Correct 521 ms 504 KB Output is correct
18 Correct 483 ms 420 KB Output is correct
19 Correct 376 ms 512 KB Output is correct
20 Correct 468 ms 508 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 476 ms 644 KB Output is correct
2 Correct 372 ms 672 KB Output is correct
3 Correct 788 ms 416 KB Output is correct
4 Correct 544 ms 568 KB Output is correct
5 Correct 585 ms 416 KB Output is correct
6 Correct 346 ms 628 KB Output is correct
7 Correct 422 ms 496 KB Output is correct
8 Correct 1 ms 492 KB Output is correct
9 Correct 2 ms 496 KB Output is correct
10 Correct 0 ms 492 KB Output is correct
11 Correct 411 ms 540 KB Output is correct
12 Correct 575 ms 500 KB Output is correct
13 Correct 816 ms 492 KB Output is correct
14 Correct 561 ms 504 KB Output is correct
15 Correct 551 ms 608 KB Output is correct
16 Correct 452 ms 500 KB Output is correct
17 Correct 585 ms 420 KB Output is correct
18 Correct 399 ms 628 KB Output is correct
19 Correct 544 ms 692 KB Output is correct
20 Correct 442 ms 516 KB Output is correct
21 Correct 63 ms 444 KB Output is correct
22 Correct 52 ms 528 KB Output is correct
23 Correct 106 ms 544 KB Output is correct
24 Correct 2 ms 492 KB Output is correct
25 Correct 6 ms 492 KB Output is correct
26 Correct 5 ms 492 KB Output is correct
27 Correct 2 ms 504 KB Output is correct
28 Correct 1 ms 492 KB Output is correct
29 Correct 483 ms 508 KB Output is correct
30 Correct 595 ms 504 KB Output is correct
31 Correct 517 ms 416 KB Output is correct
32 Correct 572 ms 420 KB Output is correct
33 Correct 384 ms 512 KB Output is correct
34 Correct 322 ms 628 KB Output is correct
35 Correct 455 ms 692 KB Output is correct
36 Correct 439 ms 756 KB Output is correct
37 Correct 426 ms 712 KB Output is correct
38 Correct 404 ms 620 KB Output is correct
39 Correct 415 ms 644 KB Output is correct
40 Correct 460 ms 724 KB Output is correct
41 Correct 445 ms 632 KB Output is correct
42 Correct 59 ms 612 KB Output is correct
43 Correct 124 ms 500 KB Output is correct
44 Correct 126 ms 508 KB Output is correct
45 Correct 143 ms 548 KB Output is correct
46 Correct 275 ms 512 KB Output is correct
47 Correct 344 ms 548 KB Output is correct
48 Correct 70 ms 700 KB Output is correct
49 Correct 49 ms 628 KB Output is correct