답안 #624971

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
624971 2022-08-09T08:25:13 Z prvocislo 기지국 (IOI20_stations) C++17
100 / 100
984 ms 804 KB
#include "stations.h"
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <vector>
typedef long long ll;
typedef long double ld;
using namespace std;

const int maxn = 1e3 + 5;
vector<int> g[maxn];
int tin[maxn], tout[maxn], t = 0;
vector<int> l;
void dfs(int u, int d, int p = -1)
{
	if (!d) l[u] = tin[u] = t++;
	for (int v : g[u]) if (v != p) dfs(v, d ^ 1, u);
	if (d) l[u] = tout[u] = t++;
}
vector<int> label(int n, int k, vector<int> u, vector<int> v) 
{
	t = 0;
	for (int i = 0; i < n; i++) g[i].clear(), tin[i] = tout[i] = 0;
	for (int i = 0; i < n - 1; i++) g[u[i]].push_back(v[i]), g[v[i]].push_back(u[i]);
	l.assign(n, 0);
	dfs(0, 0);
	return l;
}

int find_next_station(int s, int t, vector<int> c) 
{
	int k = c.size();
	if (s <= c[0]) // ja som tin, c-cka su tout
	{
		int tin = s;
		int tout = (s ? (k > 1 ? c[k - 2] : s) : c[k - 1]);
		if (t < tin || t > tout) return c[k - 1]; // v tomto podstrome nie je t, musim ist do rodica
		int i = 0;
		while (c[i] < t) i++;
		return c[i];
	}
	else // ja som tout, c-cka su tin
	{
		int tin = (k > 1 ? c[1] : s);
		int tout = s;
		if (t < tin || t > tout) return c[0]; // v tomto podstrome nie je t, musim ist do rodica
		int i = 0;
		while (i + 1 < k && c[i + 1] <= t) i++;
		return c[i];
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 561 ms 672 KB Output is correct
2 Correct 373 ms 800 KB Output is correct
3 Correct 718 ms 416 KB Output is correct
4 Correct 696 ms 416 KB Output is correct
5 Correct 600 ms 532 KB Output is correct
6 Correct 456 ms 544 KB Output is correct
7 Correct 469 ms 544 KB Output is correct
8 Correct 1 ms 500 KB Output is correct
9 Correct 5 ms 488 KB Output is correct
10 Correct 1 ms 496 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 478 ms 528 KB Output is correct
2 Correct 517 ms 544 KB Output is correct
3 Correct 900 ms 416 KB Output is correct
4 Correct 676 ms 416 KB Output is correct
5 Correct 475 ms 532 KB Output is correct
6 Correct 417 ms 540 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 522 ms 656 KB Output is correct
2 Correct 407 ms 540 KB Output is correct
3 Correct 897 ms 416 KB Output is correct
4 Correct 649 ms 420 KB Output is correct
5 Correct 613 ms 536 KB Output is correct
6 Correct 453 ms 672 KB Output is correct
7 Correct 414 ms 516 KB Output is correct
8 Correct 2 ms 496 KB Output is correct
9 Correct 4 ms 620 KB Output is correct
10 Correct 0 ms 516 KB Output is correct
11 Correct 588 ms 416 KB Output is correct
12 Correct 431 ms 652 KB Output is correct
13 Correct 399 ms 756 KB Output is correct
14 Correct 442 ms 520 KB Output is correct
15 Correct 55 ms 628 KB Output is correct
16 Correct 68 ms 676 KB Output is correct
17 Correct 89 ms 572 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 947 ms 428 KB Output is correct
2 Correct 507 ms 420 KB Output is correct
3 Correct 521 ms 416 KB Output is correct
4 Correct 2 ms 492 KB Output is correct
5 Correct 3 ms 492 KB Output is correct
6 Correct 0 ms 492 KB Output is correct
7 Correct 562 ms 536 KB Output is correct
8 Correct 790 ms 516 KB Output is correct
9 Correct 703 ms 548 KB Output is correct
10 Correct 589 ms 416 KB Output is correct
11 Correct 4 ms 496 KB Output is correct
12 Correct 4 ms 492 KB Output is correct
13 Correct 4 ms 628 KB Output is correct
14 Correct 3 ms 492 KB Output is correct
15 Correct 1 ms 500 KB Output is correct
16 Correct 557 ms 420 KB Output is correct
17 Correct 424 ms 548 KB Output is correct
18 Correct 452 ms 416 KB Output is correct
19 Correct 455 ms 524 KB Output is correct
20 Correct 510 ms 420 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 501 ms 660 KB Output is correct
2 Correct 461 ms 656 KB Output is correct
3 Correct 970 ms 416 KB Output is correct
4 Correct 621 ms 420 KB Output is correct
5 Correct 553 ms 548 KB Output is correct
6 Correct 438 ms 656 KB Output is correct
7 Correct 414 ms 528 KB Output is correct
8 Correct 1 ms 492 KB Output is correct
9 Correct 4 ms 500 KB Output is correct
10 Correct 0 ms 492 KB Output is correct
11 Correct 445 ms 528 KB Output is correct
12 Correct 573 ms 524 KB Output is correct
13 Correct 984 ms 520 KB Output is correct
14 Correct 603 ms 528 KB Output is correct
15 Correct 548 ms 532 KB Output is correct
16 Correct 431 ms 532 KB Output is correct
17 Correct 594 ms 416 KB Output is correct
18 Correct 445 ms 732 KB Output is correct
19 Correct 359 ms 784 KB Output is correct
20 Correct 438 ms 548 KB Output is correct
21 Correct 58 ms 548 KB Output is correct
22 Correct 74 ms 544 KB Output is correct
23 Correct 85 ms 672 KB Output is correct
24 Correct 3 ms 492 KB Output is correct
25 Correct 5 ms 492 KB Output is correct
26 Correct 5 ms 492 KB Output is correct
27 Correct 3 ms 492 KB Output is correct
28 Correct 2 ms 492 KB Output is correct
29 Correct 555 ms 532 KB Output is correct
30 Correct 495 ms 532 KB Output is correct
31 Correct 443 ms 528 KB Output is correct
32 Correct 568 ms 528 KB Output is correct
33 Correct 530 ms 512 KB Output is correct
34 Correct 260 ms 660 KB Output is correct
35 Correct 478 ms 764 KB Output is correct
36 Correct 487 ms 756 KB Output is correct
37 Correct 421 ms 668 KB Output is correct
38 Correct 473 ms 640 KB Output is correct
39 Correct 503 ms 644 KB Output is correct
40 Correct 498 ms 696 KB Output is correct
41 Correct 701 ms 636 KB Output is correct
42 Correct 57 ms 728 KB Output is correct
43 Correct 125 ms 804 KB Output is correct
44 Correct 134 ms 624 KB Output is correct
45 Correct 176 ms 624 KB Output is correct
46 Correct 285 ms 532 KB Output is correct
47 Correct 258 ms 508 KB Output is correct
48 Correct 67 ms 764 KB Output is correct
49 Correct 55 ms 744 KB Output is correct