답안 #535062

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
535062 2022-03-09T10:56:23 Z chenwz 기지국 (IOI20_stations) C++14
100 / 100
1091 ms 676 KB
#include "stations.h"
#include <vector>
#include <algorithm>
using namespace std;
typedef vector<int> VI;

void dfs(int u, int fa, bool dfs_in, int &clock, const vector<VI>& G, VI& L) {
  if (dfs_in) L[u] = clock++;
  for (int i : G[u])
    if (i != fa) dfs(i, u, !dfs_in, clock, G, L);
  if (!dfs_in) L[u] = clock++;
}

VI label(int n, int k, VI u, VI v) {
  VI L(n);
  vector<VI> G(n, VI());
  for (size_t i = 0; i < u.size(); i++)
    G[u[i]].push_back(v[i]), G[v[i]].push_back(u[i]);
  int clock = 0;
  dfs(0, -1, true, clock, G, L);
  return L;
}

int find_next_station(int s, int t, VI c) {
  int c0 = c[0];
  if (c0 > s) { // Case 1: s is Tin. All the neighbors' label > s.
    if (t < s || t > c.back()) return c.back(); // t not in this subtree, go to parent.
    return *lower_bound(c.begin(), c.end(), t); // t is in this subtree, Pick the smallest ch >= t
  }
  // Case 2: s is Tout level.
  if (t < c0 || t > s)  return c0; // t not in subtree, go to root
  return *(upper_bound(c.begin(), c.end(), t) - 1); // last v that <= t
}

// int main(){
//   return 0;
// }
# 결과 실행 시간 메모리 Grader output
1 Correct 653 ms 584 KB Output is correct
2 Correct 607 ms 604 KB Output is correct
3 Correct 945 ms 460 KB Output is correct
4 Correct 833 ms 456 KB Output is correct
5 Correct 661 ms 400 KB Output is correct
6 Correct 593 ms 608 KB Output is correct
7 Correct 511 ms 580 KB Output is correct
8 Correct 2 ms 468 KB Output is correct
9 Correct 3 ms 472 KB Output is correct
10 Correct 1 ms 548 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 477 ms 532 KB Output is correct
2 Correct 600 ms 484 KB Output is correct
3 Correct 1091 ms 400 KB Output is correct
4 Correct 824 ms 400 KB Output is correct
5 Correct 686 ms 400 KB Output is correct
6 Correct 504 ms 524 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 617 ms 524 KB Output is correct
2 Correct 517 ms 592 KB Output is correct
3 Correct 910 ms 400 KB Output is correct
4 Correct 688 ms 400 KB Output is correct
5 Correct 606 ms 404 KB Output is correct
6 Correct 518 ms 600 KB Output is correct
7 Correct 575 ms 592 KB Output is correct
8 Correct 2 ms 476 KB Output is correct
9 Correct 5 ms 476 KB Output is correct
10 Correct 1 ms 464 KB Output is correct
11 Correct 579 ms 476 KB Output is correct
12 Correct 563 ms 668 KB Output is correct
13 Correct 536 ms 580 KB Output is correct
14 Correct 486 ms 456 KB Output is correct
15 Correct 66 ms 460 KB Output is correct
16 Correct 64 ms 400 KB Output is correct
17 Correct 85 ms 656 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 919 ms 452 KB Output is correct
2 Correct 803 ms 476 KB Output is correct
3 Correct 530 ms 400 KB Output is correct
4 Correct 2 ms 476 KB Output is correct
5 Correct 4 ms 464 KB Output is correct
6 Correct 2 ms 468 KB Output is correct
7 Correct 612 ms 456 KB Output is correct
8 Correct 966 ms 412 KB Output is correct
9 Correct 720 ms 404 KB Output is correct
10 Correct 705 ms 400 KB Output is correct
11 Correct 2 ms 476 KB Output is correct
12 Correct 6 ms 528 KB Output is correct
13 Correct 5 ms 468 KB Output is correct
14 Correct 4 ms 464 KB Output is correct
15 Correct 1 ms 468 KB Output is correct
16 Correct 556 ms 400 KB Output is correct
17 Correct 580 ms 400 KB Output is correct
18 Correct 540 ms 480 KB Output is correct
19 Correct 485 ms 400 KB Output is correct
20 Correct 604 ms 400 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 544 ms 600 KB Output is correct
2 Correct 536 ms 632 KB Output is correct
3 Correct 1051 ms 480 KB Output is correct
4 Correct 627 ms 456 KB Output is correct
5 Correct 699 ms 476 KB Output is correct
6 Correct 620 ms 628 KB Output is correct
7 Correct 528 ms 468 KB Output is correct
8 Correct 3 ms 468 KB Output is correct
9 Correct 5 ms 468 KB Output is correct
10 Correct 0 ms 468 KB Output is correct
11 Correct 568 ms 460 KB Output is correct
12 Correct 565 ms 476 KB Output is correct
13 Correct 909 ms 404 KB Output is correct
14 Correct 654 ms 452 KB Output is correct
15 Correct 662 ms 456 KB Output is correct
16 Correct 482 ms 464 KB Output is correct
17 Correct 670 ms 480 KB Output is correct
18 Correct 508 ms 648 KB Output is correct
19 Correct 486 ms 668 KB Output is correct
20 Correct 527 ms 464 KB Output is correct
21 Correct 55 ms 468 KB Output is correct
22 Correct 62 ms 448 KB Output is correct
23 Correct 93 ms 580 KB Output is correct
24 Correct 4 ms 476 KB Output is correct
25 Correct 5 ms 468 KB Output is correct
26 Correct 4 ms 476 KB Output is correct
27 Correct 3 ms 468 KB Output is correct
28 Correct 2 ms 476 KB Output is correct
29 Correct 544 ms 472 KB Output is correct
30 Correct 594 ms 400 KB Output is correct
31 Correct 531 ms 528 KB Output is correct
32 Correct 522 ms 452 KB Output is correct
33 Correct 637 ms 556 KB Output is correct
34 Correct 397 ms 600 KB Output is correct
35 Correct 516 ms 652 KB Output is correct
36 Correct 518 ms 676 KB Output is correct
37 Correct 705 ms 532 KB Output is correct
38 Correct 481 ms 520 KB Output is correct
39 Correct 487 ms 608 KB Output is correct
40 Correct 640 ms 536 KB Output is correct
41 Correct 557 ms 632 KB Output is correct
42 Correct 57 ms 608 KB Output is correct
43 Correct 128 ms 564 KB Output is correct
44 Correct 177 ms 552 KB Output is correct
45 Correct 165 ms 464 KB Output is correct
46 Correct 328 ms 528 KB Output is correct
47 Correct 274 ms 528 KB Output is correct
48 Correct 69 ms 532 KB Output is correct
49 Correct 76 ms 632 KB Output is correct