답안 #653282

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
653282 2022-10-26T11:16:00 Z mychecksedad 기지국 (IOI20_stations) C++17
100 / 100
980 ms 756 KB
#include <bits/stdc++.h>
using namespace std;
#define pb push_back


vector<int> label(int n, int k, vector<int> u, vector<int> v){
	int timer = 0, tin[n], tout[n];
	vector<int> l(n);
	vector<vector<int>> g(n);
	for(int i = 0; i < n-1; ++i) g[u[i]].pb(v[i]), g[v[i]].pb(u[i]);
	function<void(int, int, int)> dfs = [&](int v, int p, int d){
		if(d) l[v] = timer++;
		for(int u: g[v]){
			if(u != p) dfs(u, v, d^1);
		}
		if(!d) l[v] = timer++;
	};
	dfs(0, 0, 1);
	return l;
}
int find_next_station(int s, int t, vector<int> c){
	int m = c.size();
	if (s < c[0]) {
	    if (s < t && t <= c[0]) {
	      return c[0];
	    }
	    for (int i = 1; i < m - 1; i++) {
	      if (c[i - 1] < t && t <= c[i]) {
	        return c[i];
	      }
	    }
    	return c[m - 1];
	  } else {
	    if (c[m - 1] <= t && t < s) {
	      return c[m - 1];
	    }
	    for (int i = 1; i < m - 1; i++) {
	      if (c[i] <= t && t < c[i + 1]) {
	        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:7:17: warning: unused variable 'tin' [-Wunused-variable]
    7 |  int timer = 0, tin[n], tout[n];
      |                 ^~~
stations.cpp:7:25: warning: unused variable 'tout' [-Wunused-variable]
    7 |  int timer = 0, tin[n], tout[n];
      |                         ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 594 ms 664 KB Output is correct
2 Correct 567 ms 684 KB Output is correct
3 Correct 894 ms 436 KB Output is correct
4 Correct 718 ms 416 KB Output is correct
5 Correct 586 ms 420 KB Output is correct
6 Correct 389 ms 624 KB Output is correct
7 Correct 495 ms 628 KB Output is correct
8 Correct 3 ms 492 KB Output is correct
9 Correct 5 ms 504 KB Output is correct
10 Correct 1 ms 492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 436 ms 548 KB Output is correct
2 Correct 495 ms 548 KB Output is correct
3 Correct 950 ms 416 KB Output is correct
4 Correct 663 ms 480 KB Output is correct
5 Correct 661 ms 504 KB Output is correct
6 Correct 508 ms 488 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 657 ms 676 KB Output is correct
2 Correct 546 ms 664 KB Output is correct
3 Correct 863 ms 420 KB Output is correct
4 Correct 635 ms 420 KB Output is correct
5 Correct 600 ms 500 KB Output is correct
6 Correct 437 ms 612 KB Output is correct
7 Correct 412 ms 636 KB Output is correct
8 Correct 2 ms 496 KB Output is correct
9 Correct 5 ms 492 KB Output is correct
10 Correct 1 ms 492 KB Output is correct
11 Correct 513 ms 420 KB Output is correct
12 Correct 441 ms 744 KB Output is correct
13 Correct 497 ms 708 KB Output is correct
14 Correct 414 ms 504 KB Output is correct
15 Correct 62 ms 416 KB Output is correct
16 Correct 73 ms 596 KB Output is correct
17 Correct 96 ms 572 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 903 ms 420 KB Output is correct
2 Correct 679 ms 504 KB Output is correct
3 Correct 578 ms 504 KB Output is correct
4 Correct 1 ms 492 KB Output is correct
5 Correct 2 ms 500 KB Output is correct
6 Correct 0 ms 500 KB Output is correct
7 Correct 568 ms 420 KB Output is correct
8 Correct 840 ms 416 KB Output is correct
9 Correct 643 ms 420 KB Output is correct
10 Correct 585 ms 504 KB Output is correct
11 Correct 5 ms 492 KB Output is correct
12 Correct 5 ms 500 KB Output is correct
13 Correct 6 ms 492 KB Output is correct
14 Correct 5 ms 500 KB Output is correct
15 Correct 3 ms 500 KB Output is correct
16 Correct 580 ms 504 KB Output is correct
17 Correct 570 ms 504 KB Output is correct
18 Correct 406 ms 500 KB Output is correct
19 Correct 496 ms 544 KB Output is correct
20 Correct 528 ms 420 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 443 ms 632 KB Output is correct
2 Correct 374 ms 540 KB Output is correct
3 Correct 675 ms 420 KB Output is correct
4 Correct 627 ms 428 KB Output is correct
5 Correct 669 ms 416 KB Output is correct
6 Correct 495 ms 628 KB Output is correct
7 Correct 442 ms 548 KB Output is correct
8 Correct 2 ms 492 KB Output is correct
9 Correct 5 ms 492 KB Output is correct
10 Correct 2 ms 492 KB Output is correct
11 Correct 402 ms 492 KB Output is correct
12 Correct 508 ms 544 KB Output is correct
13 Correct 980 ms 436 KB Output is correct
14 Correct 675 ms 504 KB Output is correct
15 Correct 551 ms 500 KB Output is correct
16 Correct 455 ms 548 KB Output is correct
17 Correct 522 ms 420 KB Output is correct
18 Correct 443 ms 628 KB Output is correct
19 Correct 497 ms 756 KB Output is correct
20 Correct 514 ms 548 KB Output is correct
21 Correct 56 ms 440 KB Output is correct
22 Correct 76 ms 612 KB Output is correct
23 Correct 111 ms 600 KB Output is correct
24 Correct 4 ms 492 KB Output is correct
25 Correct 5 ms 496 KB Output is correct
26 Correct 4 ms 500 KB Output is correct
27 Correct 2 ms 508 KB Output is correct
28 Correct 2 ms 500 KB Output is correct
29 Correct 533 ms 420 KB Output is correct
30 Correct 453 ms 500 KB Output is correct
31 Correct 470 ms 420 KB Output is correct
32 Correct 547 ms 508 KB Output is correct
33 Correct 493 ms 500 KB Output is correct
34 Correct 259 ms 676 KB Output is correct
35 Correct 418 ms 716 KB Output is correct
36 Correct 410 ms 756 KB Output is correct
37 Correct 420 ms 628 KB Output is correct
38 Correct 422 ms 668 KB Output is correct
39 Correct 426 ms 664 KB Output is correct
40 Correct 483 ms 708 KB Output is correct
41 Correct 422 ms 628 KB Output is correct
42 Correct 48 ms 544 KB Output is correct
43 Correct 116 ms 548 KB Output is correct
44 Correct 112 ms 548 KB Output is correct
45 Correct 174 ms 508 KB Output is correct
46 Correct 335 ms 544 KB Output is correct
47 Correct 346 ms 496 KB Output is correct
48 Correct 73 ms 692 KB Output is correct
49 Correct 49 ms 664 KB Output is correct