답안 #811953

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
811953 2023-08-07T06:34:07 Z hgmhc 기지국 (IOI20_stations) C++17
100 / 100
831 ms 768 KB
#include "stations.h"
#include <algorithm>
using namespace std;
using vi = vector<int>;

int n, c;
vector<int> adj[1000], res;

void dfs(int d=0, int s=0, int e=-1) {
	if (d&1) res[s] = c++;
	for (const auto &u : adj[s]) if (u != e) dfs(d+1,u,s);
	if (~d&1) res[s] = c++;
}

vi label(int _n, int k, vi u, vi v) {
	n = _n;
	for (int i = 0; i < n-1; ++i) {
		adj[u[i]].push_back(v[i]);
		adj[v[i]].push_back(u[i]);
	}
    c=0, res.resize(n), dfs();
    for (int i = 0; i < n; ++i) adj[i].clear();
	return res;
}

int find_next_station(int s, int t, vi c) {
	bool flag = s > c[0];
	if (flag) reverse(begin(c),end(c));
	int x, y = s;
	for (const auto &u : c) {
		x = y, y = u;
		if (flag) { if (y <= t and t < x) return u; }
		else { if (x < t and t <= y) return u; }
	}
	return c.back();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 505 ms 636 KB Output is correct
2 Correct 395 ms 648 KB Output is correct
3 Correct 831 ms 516 KB Output is correct
4 Correct 563 ms 516 KB Output is correct
5 Correct 560 ms 512 KB Output is correct
6 Correct 421 ms 648 KB Output is correct
7 Correct 377 ms 544 KB Output is correct
8 Correct 2 ms 492 KB Output is correct
9 Correct 3 ms 488 KB Output is correct
10 Correct 1 ms 492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 339 ms 520 KB Output is correct
2 Correct 394 ms 516 KB Output is correct
3 Correct 612 ms 516 KB Output is correct
4 Correct 458 ms 576 KB Output is correct
5 Correct 563 ms 516 KB Output is correct
6 Correct 291 ms 548 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 440 ms 652 KB Output is correct
2 Correct 339 ms 644 KB Output is correct
3 Correct 768 ms 420 KB Output is correct
4 Correct 582 ms 544 KB Output is correct
5 Correct 475 ms 416 KB Output is correct
6 Correct 306 ms 644 KB Output is correct
7 Correct 567 ms 524 KB Output is correct
8 Correct 2 ms 492 KB Output is correct
9 Correct 2 ms 492 KB Output is correct
10 Correct 1 ms 492 KB Output is correct
11 Correct 349 ms 516 KB Output is correct
12 Correct 475 ms 676 KB Output is correct
13 Correct 463 ms 740 KB Output is correct
14 Correct 330 ms 544 KB Output is correct
15 Correct 33 ms 432 KB Output is correct
16 Correct 69 ms 544 KB Output is correct
17 Correct 67 ms 548 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 721 ms 516 KB Output is correct
2 Correct 656 ms 416 KB Output is correct
3 Correct 387 ms 416 KB Output is correct
4 Correct 2 ms 492 KB Output is correct
5 Correct 4 ms 524 KB Output is correct
6 Correct 1 ms 488 KB Output is correct
7 Correct 553 ms 420 KB Output is correct
8 Correct 513 ms 416 KB Output is correct
9 Correct 618 ms 416 KB Output is correct
10 Correct 491 ms 520 KB Output is correct
11 Correct 6 ms 488 KB Output is correct
12 Correct 4 ms 492 KB Output is correct
13 Correct 3 ms 492 KB Output is correct
14 Correct 2 ms 492 KB Output is correct
15 Correct 2 ms 492 KB Output is correct
16 Correct 340 ms 516 KB Output is correct
17 Correct 593 ms 416 KB Output is correct
18 Correct 313 ms 512 KB Output is correct
19 Correct 382 ms 416 KB Output is correct
20 Correct 362 ms 420 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 532 ms 544 KB Output is correct
2 Correct 450 ms 548 KB Output is correct
3 Correct 642 ms 524 KB Output is correct
4 Correct 543 ms 548 KB Output is correct
5 Correct 361 ms 520 KB Output is correct
6 Correct 444 ms 628 KB Output is correct
7 Correct 320 ms 516 KB Output is correct
8 Correct 1 ms 492 KB Output is correct
9 Correct 2 ms 492 KB Output is correct
10 Correct 1 ms 492 KB Output is correct
11 Correct 282 ms 544 KB Output is correct
12 Correct 322 ms 500 KB Output is correct
13 Correct 579 ms 516 KB Output is correct
14 Correct 630 ms 524 KB Output is correct
15 Correct 566 ms 416 KB Output is correct
16 Correct 338 ms 516 KB Output is correct
17 Correct 467 ms 516 KB Output is correct
18 Correct 298 ms 612 KB Output is correct
19 Correct 368 ms 724 KB Output is correct
20 Correct 293 ms 516 KB Output is correct
21 Correct 49 ms 492 KB Output is correct
22 Correct 42 ms 596 KB Output is correct
23 Correct 86 ms 572 KB Output is correct
24 Correct 4 ms 500 KB Output is correct
25 Correct 2 ms 500 KB Output is correct
26 Correct 3 ms 492 KB Output is correct
27 Correct 2 ms 496 KB Output is correct
28 Correct 1 ms 492 KB Output is correct
29 Correct 346 ms 416 KB Output is correct
30 Correct 457 ms 512 KB Output is correct
31 Correct 461 ms 576 KB Output is correct
32 Correct 392 ms 528 KB Output is correct
33 Correct 475 ms 420 KB Output is correct
34 Correct 219 ms 628 KB Output is correct
35 Correct 269 ms 648 KB Output is correct
36 Correct 312 ms 632 KB Output is correct
37 Correct 349 ms 604 KB Output is correct
38 Correct 370 ms 608 KB Output is correct
39 Correct 320 ms 700 KB Output is correct
40 Correct 334 ms 644 KB Output is correct
41 Correct 265 ms 644 KB Output is correct
42 Correct 39 ms 600 KB Output is correct
43 Correct 70 ms 544 KB Output is correct
44 Correct 84 ms 548 KB Output is correct
45 Correct 132 ms 572 KB Output is correct
46 Correct 176 ms 544 KB Output is correct
47 Correct 171 ms 512 KB Output is correct
48 Correct 50 ms 600 KB Output is correct
49 Correct 38 ms 768 KB Output is correct