답안 #824403

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
824403 2023-08-14T05:30:21 Z ymm 기지국 (IOI20_stations) C++17
100 / 100
709 ms 772 KB
#include "stations.h"
#include <bits/stdc++.h>
#define Loop(x,l,r) for (ll x = (l); x < (r); ++x)
typedef long long ll;
typedef std::pair<ll,ll> pll;
using namespace std;

const int N = 1024;
vector<int> A[N];
int ans[N];

void dfs(int v, int p, int &t, int c)
{
	if (!c)
		ans[v] = t++;
	for (int u : A[v])
		if (u != p)
			dfs(u, v, t, !c);
	if (c)
		ans[v] = t++;
}

std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
	Loop (i,0,n)
		A[i].clear();
	Loop (i,0,n-1) {
		int x = v[i], y = u[i];
		A[x].push_back(y);
		A[y].push_back(x);
	}
	int dard = 0;
	dfs(0, -1, dard, 0);
	return vector<int>(ans, ans+n);
}

int find_next_station(int s, int t, std::vector<int> c) {
	sort(c.begin(), c.end());
	if (s == 0)
		return *lower_bound(c.begin(), c.end(), t);
	if (c[0] > s) {
		if (t < s || t > c.end()[-2])
			return c.back();
		return *lower_bound(c.begin(), c.end()-1, t);
	} else {
		if (t > s || t < c[1])
			return c[0];
		return *(upper_bound(c.begin()+1, c.end(), t) - 1);
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 421 ms 752 KB Output is correct
2 Correct 323 ms 728 KB Output is correct
3 Correct 702 ms 540 KB Output is correct
4 Correct 502 ms 416 KB Output is correct
5 Correct 491 ms 552 KB Output is correct
6 Correct 444 ms 548 KB Output is correct
7 Correct 353 ms 536 KB Output is correct
8 Correct 1 ms 500 KB Output is correct
9 Correct 2 ms 492 KB Output is correct
10 Correct 0 ms 488 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 337 ms 548 KB Output is correct
2 Correct 442 ms 548 KB Output is correct
3 Correct 680 ms 528 KB Output is correct
4 Correct 476 ms 420 KB Output is correct
5 Correct 453 ms 552 KB Output is correct
6 Correct 270 ms 544 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 319 ms 544 KB Output is correct
2 Correct 308 ms 668 KB Output is correct
3 Correct 566 ms 536 KB Output is correct
4 Correct 597 ms 488 KB Output is correct
5 Correct 477 ms 532 KB Output is correct
6 Correct 390 ms 544 KB Output is correct
7 Correct 309 ms 548 KB Output is correct
8 Correct 1 ms 504 KB Output is correct
9 Correct 3 ms 492 KB Output is correct
10 Correct 0 ms 492 KB Output is correct
11 Correct 449 ms 416 KB Output is correct
12 Correct 358 ms 668 KB Output is correct
13 Correct 405 ms 772 KB Output is correct
14 Correct 322 ms 536 KB Output is correct
15 Correct 40 ms 572 KB Output is correct
16 Correct 60 ms 612 KB Output is correct
17 Correct 69 ms 672 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 550 ms 568 KB Output is correct
2 Correct 546 ms 568 KB Output is correct
3 Correct 354 ms 528 KB Output is correct
4 Correct 1 ms 496 KB Output is correct
5 Correct 4 ms 632 KB Output is correct
6 Correct 0 ms 492 KB Output is correct
7 Correct 434 ms 540 KB Output is correct
8 Correct 687 ms 416 KB Output is correct
9 Correct 443 ms 416 KB Output is correct
10 Correct 395 ms 532 KB Output is correct
11 Correct 4 ms 500 KB Output is correct
12 Correct 3 ms 500 KB Output is correct
13 Correct 2 ms 492 KB Output is correct
14 Correct 3 ms 488 KB Output is correct
15 Correct 1 ms 492 KB Output is correct
16 Correct 391 ms 664 KB Output is correct
17 Correct 295 ms 420 KB Output is correct
18 Correct 374 ms 420 KB Output is correct
19 Correct 395 ms 560 KB Output is correct
20 Correct 356 ms 420 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 412 ms 564 KB Output is correct
2 Correct 291 ms 548 KB Output is correct
3 Correct 602 ms 420 KB Output is correct
4 Correct 498 ms 416 KB Output is correct
5 Correct 399 ms 536 KB Output is correct
6 Correct 336 ms 668 KB Output is correct
7 Correct 375 ms 544 KB Output is correct
8 Correct 1 ms 492 KB Output is correct
9 Correct 2 ms 492 KB Output is correct
10 Correct 0 ms 492 KB Output is correct
11 Correct 287 ms 528 KB Output is correct
12 Correct 424 ms 536 KB Output is correct
13 Correct 709 ms 420 KB Output is correct
14 Correct 498 ms 416 KB Output is correct
15 Correct 373 ms 540 KB Output is correct
16 Correct 421 ms 528 KB Output is correct
17 Correct 431 ms 532 KB Output is correct
18 Correct 327 ms 536 KB Output is correct
19 Correct 306 ms 652 KB Output is correct
20 Correct 428 ms 544 KB Output is correct
21 Correct 38 ms 616 KB Output is correct
22 Correct 48 ms 696 KB Output is correct
23 Correct 77 ms 588 KB Output is correct
24 Correct 3 ms 500 KB Output is correct
25 Correct 3 ms 496 KB Output is correct
26 Correct 3 ms 492 KB Output is correct
27 Correct 2 ms 500 KB Output is correct
28 Correct 1 ms 492 KB Output is correct
29 Correct 338 ms 420 KB Output is correct
30 Correct 322 ms 420 KB Output is correct
31 Correct 343 ms 420 KB Output is correct
32 Correct 337 ms 420 KB Output is correct
33 Correct 338 ms 424 KB Output is correct
34 Correct 178 ms 640 KB Output is correct
35 Correct 297 ms 724 KB Output is correct
36 Correct 282 ms 668 KB Output is correct
37 Correct 321 ms 604 KB Output is correct
38 Correct 312 ms 652 KB Output is correct
39 Correct 280 ms 768 KB Output is correct
40 Correct 277 ms 548 KB Output is correct
41 Correct 332 ms 732 KB Output is correct
42 Correct 38 ms 596 KB Output is correct
43 Correct 64 ms 664 KB Output is correct
44 Correct 78 ms 640 KB Output is correct
45 Correct 112 ms 544 KB Output is correct
46 Correct 209 ms 532 KB Output is correct
47 Correct 246 ms 544 KB Output is correct
48 Correct 43 ms 672 KB Output is correct
49 Correct 50 ms 676 KB Output is correct