답안 #524949

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
524949 2022-02-10T11:27:42 Z Turkhuu 기지국 (IOI20_stations) C++17
100 / 100
997 ms 736 KB
#include "stations.h"
#include <bits/stdc++.h>

using namespace std;

vector<int> label(int n, int K, vector<int> U, vector<int> V){
  vector<vector<int>> g(n);
  for(int i = 0; i < n - 1; i++){
    g[U[i]].push_back(V[i]);
    g[V[i]].push_back(U[i]);
  }
  vector<int> a(n);
  int k = 1;
  function<void(int, int)> dfs = [&](int u, int anc){
    for(int v : g[u]){
      if(v == anc){
        continue;
      }
      a[v] = k++;
      for(int w : g[v]){
        if(w != u){
          dfs(w, v);
        }
      }
    }
    a[u] = k++;
  };
  a[0] = 0;
  for(int v : g[0]){
    dfs(v, 0);
  }
  return a;
}

int find_next_station(int s, int t, vector<int> c){
  int m = (int)c.size();
  if(s > c.back()){
    for(int i = 1; i < m; i++){
      int l = c[i];
      int r = i == m - 1 ? s - 1 : c[i + 1] - 1;
      if(t >= l && t <= r){
        return c[i];
      }
    }
    return c[0];
  } else{
    for(int i = 0; i < m - 1; i++){
      int l = i == 0 ? s + 1 : c[i - 1] + 1;
      int r = c[i];
      if(t >= l && t <= r){
        return c[i];
      }
    }
    return c.back();
  }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 528 ms 616 KB Output is correct
2 Correct 495 ms 604 KB Output is correct
3 Correct 910 ms 464 KB Output is correct
4 Correct 625 ms 404 KB Output is correct
5 Correct 554 ms 404 KB Output is correct
6 Correct 481 ms 488 KB Output is correct
7 Correct 379 ms 476 KB Output is correct
8 Correct 2 ms 468 KB Output is correct
9 Correct 4 ms 476 KB Output is correct
10 Correct 1 ms 468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 439 ms 528 KB Output is correct
2 Correct 481 ms 476 KB Output is correct
3 Correct 825 ms 480 KB Output is correct
4 Correct 627 ms 404 KB Output is correct
5 Correct 520 ms 400 KB Output is correct
6 Correct 388 ms 528 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 399 ms 656 KB Output is correct
2 Correct 432 ms 484 KB Output is correct
3 Correct 731 ms 400 KB Output is correct
4 Correct 633 ms 496 KB Output is correct
5 Correct 587 ms 400 KB Output is correct
6 Correct 359 ms 528 KB Output is correct
7 Correct 357 ms 532 KB Output is correct
8 Correct 3 ms 468 KB Output is correct
9 Correct 3 ms 468 KB Output is correct
10 Correct 2 ms 468 KB Output is correct
11 Correct 485 ms 400 KB Output is correct
12 Correct 521 ms 600 KB Output is correct
13 Correct 426 ms 684 KB Output is correct
14 Correct 425 ms 468 KB Output is correct
15 Correct 62 ms 468 KB Output is correct
16 Correct 79 ms 488 KB Output is correct
17 Correct 95 ms 532 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 898 ms 400 KB Output is correct
2 Correct 620 ms 528 KB Output is correct
3 Correct 641 ms 404 KB Output is correct
4 Correct 2 ms 476 KB Output is correct
5 Correct 4 ms 476 KB Output is correct
6 Correct 0 ms 468 KB Output is correct
7 Correct 533 ms 492 KB Output is correct
8 Correct 701 ms 400 KB Output is correct
9 Correct 627 ms 400 KB Output is correct
10 Correct 542 ms 404 KB Output is correct
11 Correct 6 ms 468 KB Output is correct
12 Correct 5 ms 564 KB Output is correct
13 Correct 5 ms 476 KB Output is correct
14 Correct 2 ms 476 KB Output is correct
15 Correct 0 ms 468 KB Output is correct
16 Correct 503 ms 400 KB Output is correct
17 Correct 400 ms 488 KB Output is correct
18 Correct 525 ms 400 KB Output is correct
19 Correct 487 ms 400 KB Output is correct
20 Correct 342 ms 404 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 509 ms 532 KB Output is correct
2 Correct 478 ms 528 KB Output is correct
3 Correct 709 ms 400 KB Output is correct
4 Correct 610 ms 400 KB Output is correct
5 Correct 528 ms 548 KB Output is correct
6 Correct 461 ms 532 KB Output is correct
7 Correct 526 ms 492 KB Output is correct
8 Correct 3 ms 452 KB Output is correct
9 Correct 6 ms 468 KB Output is correct
10 Correct 2 ms 468 KB Output is correct
11 Correct 502 ms 476 KB Output is correct
12 Correct 533 ms 512 KB Output is correct
13 Correct 997 ms 468 KB Output is correct
14 Correct 646 ms 484 KB Output is correct
15 Correct 586 ms 400 KB Output is correct
16 Correct 418 ms 528 KB Output is correct
17 Correct 474 ms 404 KB Output is correct
18 Correct 368 ms 520 KB Output is correct
19 Correct 435 ms 596 KB Output is correct
20 Correct 450 ms 488 KB Output is correct
21 Correct 56 ms 468 KB Output is correct
22 Correct 76 ms 576 KB Output is correct
23 Correct 109 ms 528 KB Output is correct
24 Correct 5 ms 476 KB Output is correct
25 Correct 4 ms 468 KB Output is correct
26 Correct 5 ms 468 KB Output is correct
27 Correct 4 ms 476 KB Output is correct
28 Correct 2 ms 468 KB Output is correct
29 Correct 465 ms 492 KB Output is correct
30 Correct 518 ms 404 KB Output is correct
31 Correct 509 ms 484 KB Output is correct
32 Correct 533 ms 400 KB Output is correct
33 Correct 521 ms 488 KB Output is correct
34 Correct 333 ms 532 KB Output is correct
35 Correct 393 ms 736 KB Output is correct
36 Correct 418 ms 488 KB Output is correct
37 Correct 411 ms 604 KB Output is correct
38 Correct 576 ms 556 KB Output is correct
39 Correct 430 ms 552 KB Output is correct
40 Correct 458 ms 548 KB Output is correct
41 Correct 339 ms 532 KB Output is correct
42 Correct 65 ms 596 KB Output is correct
43 Correct 110 ms 580 KB Output is correct
44 Correct 144 ms 564 KB Output is correct
45 Correct 162 ms 528 KB Output is correct
46 Correct 282 ms 600 KB Output is correct
47 Correct 255 ms 532 KB Output is correct
48 Correct 53 ms 536 KB Output is correct
49 Correct 56 ms 644 KB Output is correct