# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
682021 | 2023-01-15T09:14:37 Z | junkbot | 기지국 (IOI20_stations) | C++14 | 884 ms | 1356 KB |
#include "stations.h" #include <bits/stdc++.h> using namespace std; #define D(x...) fprintf(stderr, x) #define D(x...) const int MAX_N = 1005; const int UNLABELLED = -1; const int PENDING = -2; struct Solve { int upto; vector<vector<int>> adjlist; vector<int> labels; Solve(int n, vector<int> u, vector<int> v) : upto(0), adjlist(n), labels(n) { for (auto i=0;i<u.size();i++) { adjlist[u[i]].push_back(v[i]); adjlist[v[i]].push_back(u[i]); } fill(labels.begin(), labels.end(), UNLABELLED); } // label everything in u's subtree. void go(int u, bool isPre) { if (labels[u] != UNLABELLED) return; labels[u] = PENDING; if (isPre) labels[u] = getNext(); for (auto v: adjlist[u]) go(v, !isPre); if (!isPre) labels[u] = getNext(); } int getNext() { int ret = upto; upto++; return ret; } }; std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) { auto solver = new Solve(n, u, v); solver->go(0, true); vector<int> ret; for (auto l: solver->labels) { ret.push_back(l); } D("labels:"); for (auto l: solver->labels) { D(" %d", l); } D("\n"); return ret; } int find_next_station(int s, int t, std::vector<int> c) { if (s < c.front()) { // preorder int left_exclusive = s; for (auto i=0;i<c.size()-1;i++) { auto l = c[i]; if (left_exclusive < t && t <= l) return l; left_exclusive = l; } return c.back(); } else { // postorder int right_exclusive = s; for (auto i=c.size()-1;i>0;i--) { auto l = c[i]; if (l <= t && t < right_exclusive) return l; right_exclusive = l; } return c.front(); } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 559 ms | 840 KB | Output is correct |
2 | Correct | 476 ms | 1008 KB | Output is correct |
3 | Correct | 884 ms | 420 KB | Output is correct |
4 | Correct | 639 ms | 508 KB | Output is correct |
5 | Correct | 577 ms | 420 KB | Output is correct |
6 | Correct | 344 ms | 1140 KB | Output is correct |
7 | Correct | 389 ms | 540 KB | Output is correct |
8 | Correct | 1 ms | 504 KB | Output is correct |
9 | Correct | 4 ms | 496 KB | Output is correct |
10 | Correct | 1 ms | 492 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 441 ms | 1016 KB | Output is correct |
2 | Correct | 489 ms | 612 KB | Output is correct |
3 | Correct | 787 ms | 420 KB | Output is correct |
4 | Correct | 554 ms | 416 KB | Output is correct |
5 | Correct | 531 ms | 420 KB | Output is correct |
6 | Correct | 400 ms | 548 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 471 ms | 804 KB | Output is correct |
2 | Correct | 461 ms | 1072 KB | Output is correct |
3 | Correct | 866 ms | 416 KB | Output is correct |
4 | Correct | 679 ms | 416 KB | Output is correct |
5 | Correct | 506 ms | 500 KB | Output is correct |
6 | Correct | 418 ms | 1060 KB | Output is correct |
7 | Correct | 403 ms | 504 KB | Output is correct |
8 | Correct | 1 ms | 492 KB | Output is correct |
9 | Correct | 3 ms | 496 KB | Output is correct |
10 | Correct | 0 ms | 500 KB | Output is correct |
11 | Correct | 548 ms | 416 KB | Output is correct |
12 | Correct | 439 ms | 1264 KB | Output is correct |
13 | Correct | 445 ms | 1260 KB | Output is correct |
14 | Correct | 467 ms | 504 KB | Output is correct |
15 | Correct | 43 ms | 620 KB | Output is correct |
16 | Correct | 56 ms | 856 KB | Output is correct |
17 | Correct | 114 ms | 1056 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 832 ms | 504 KB | Output is correct |
2 | Correct | 563 ms | 484 KB | Output is correct |
3 | Correct | 572 ms | 500 KB | Output is correct |
4 | Correct | 2 ms | 496 KB | Output is correct |
5 | Correct | 4 ms | 500 KB | Output is correct |
6 | Correct | 2 ms | 492 KB | Output is correct |
7 | Correct | 592 ms | 416 KB | Output is correct |
8 | Correct | 856 ms | 420 KB | Output is correct |
9 | Correct | 630 ms | 512 KB | Output is correct |
10 | Correct | 539 ms | 548 KB | Output is correct |
11 | Correct | 5 ms | 496 KB | Output is correct |
12 | Correct | 5 ms | 492 KB | Output is correct |
13 | Correct | 3 ms | 500 KB | Output is correct |
14 | Correct | 2 ms | 496 KB | Output is correct |
15 | Correct | 1 ms | 492 KB | Output is correct |
16 | Correct | 473 ms | 500 KB | Output is correct |
17 | Correct | 519 ms | 420 KB | Output is correct |
18 | Correct | 436 ms | 420 KB | Output is correct |
19 | Correct | 442 ms | 416 KB | Output is correct |
20 | Correct | 469 ms | 424 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 502 ms | 764 KB | Output is correct |
2 | Correct | 452 ms | 1012 KB | Output is correct |
3 | Correct | 873 ms | 420 KB | Output is correct |
4 | Correct | 702 ms | 420 KB | Output is correct |
5 | Correct | 533 ms | 504 KB | Output is correct |
6 | Correct | 453 ms | 1152 KB | Output is correct |
7 | Correct | 453 ms | 508 KB | Output is correct |
8 | Correct | 3 ms | 496 KB | Output is correct |
9 | Correct | 3 ms | 492 KB | Output is correct |
10 | Correct | 2 ms | 492 KB | Output is correct |
11 | Correct | 405 ms | 1020 KB | Output is correct |
12 | Correct | 562 ms | 616 KB | Output is correct |
13 | Correct | 767 ms | 500 KB | Output is correct |
14 | Correct | 701 ms | 504 KB | Output is correct |
15 | Correct | 823 ms | 504 KB | Output is correct |
16 | Correct | 481 ms | 500 KB | Output is correct |
17 | Correct | 649 ms | 560 KB | Output is correct |
18 | Correct | 463 ms | 1100 KB | Output is correct |
19 | Correct | 491 ms | 1212 KB | Output is correct |
20 | Correct | 431 ms | 504 KB | Output is correct |
21 | Correct | 59 ms | 548 KB | Output is correct |
22 | Correct | 73 ms | 800 KB | Output is correct |
23 | Correct | 112 ms | 1068 KB | Output is correct |
24 | Correct | 7 ms | 568 KB | Output is correct |
25 | Correct | 4 ms | 556 KB | Output is correct |
26 | Correct | 4 ms | 584 KB | Output is correct |
27 | Correct | 1 ms | 500 KB | Output is correct |
28 | Correct | 2 ms | 492 KB | Output is correct |
29 | Correct | 499 ms | 512 KB | Output is correct |
30 | Correct | 548 ms | 632 KB | Output is correct |
31 | Correct | 399 ms | 484 KB | Output is correct |
32 | Correct | 514 ms | 512 KB | Output is correct |
33 | Correct | 538 ms | 512 KB | Output is correct |
34 | Correct | 315 ms | 1072 KB | Output is correct |
35 | Correct | 560 ms | 1216 KB | Output is correct |
36 | Correct | 512 ms | 1244 KB | Output is correct |
37 | Correct | 432 ms | 1008 KB | Output is correct |
38 | Correct | 382 ms | 1156 KB | Output is correct |
39 | Correct | 437 ms | 1312 KB | Output is correct |
40 | Correct | 433 ms | 1356 KB | Output is correct |
41 | Correct | 517 ms | 1168 KB | Output is correct |
42 | Correct | 66 ms | 1048 KB | Output is correct |
43 | Correct | 132 ms | 1144 KB | Output is correct |
44 | Correct | 124 ms | 1064 KB | Output is correct |
45 | Correct | 150 ms | 1152 KB | Output is correct |
46 | Correct | 292 ms | 856 KB | Output is correct |
47 | Correct | 427 ms | 1008 KB | Output is correct |
48 | Correct | 64 ms | 1212 KB | Output is correct |
49 | Correct | 59 ms | 1224 KB | Output is correct |