답안 #1000411

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1000411 2024-06-17T13:05:59 Z kunzaZa183 기지국 (IOI20_stations) C++17
100 / 100
627 ms 1052 KB
#include "stations.h"

#include <bits/stdc++.h>
using namespace std;

const int maxn = 1000;
vector<int> adjlist[maxn];
vector<int> labels;

int ct = 0;
void dfs(int cur, int par, int type) {
  if (type == 0) {  // preorder
    labels[cur] = ct++;
    for (auto a : adjlist[cur])
      if (a != par) dfs(a, cur, 1);
  } else {
    for (auto a : adjlist[cur])
      if (a != par) dfs(a, cur, 0);
    labels[cur] = ct++;
  }
}

vector<int> label(int n, int k, vector<int> u, vector<int> v) {
  ct = 0;
  labels.clear();
  for (int i = 0; i < n; i++) adjlist[i].clear();
  for (int i = 0; i < n - 1; i++)
    adjlist[u[i]].push_back(v[i]), adjlist[v[i]].push_back(u[i]);
  labels.resize(n);
  dfs(0, 0, 0);
  // for (auto a : labels) cout << a << " ";
  // cout << "\n";
  return labels;
}

int find_next_station(int s, int t, vector<int> c) {
  // for (auto a : c) cout << a << ' ';
  // cout << "\n";
  if (c.size() == 1) return c.front();
  sort(c.begin(), c.end());
  if (s > c.front()) {
    if (t > s || t <= c.front()) return c.front();
    return *(upper_bound(c.begin(), c.end(), t) - 1);
  } else {
    if (t < s || t >= c.back()) return c.back();
    return *lower_bound(c.begin(), c.end(), t);
  }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 308 ms 700 KB Output is correct
2 Correct 289 ms 684 KB Output is correct
3 Correct 598 ms 688 KB Output is correct
4 Correct 489 ms 684 KB Output is correct
5 Correct 362 ms 684 KB Output is correct
6 Correct 302 ms 940 KB Output is correct
7 Correct 308 ms 684 KB Output is correct
8 Correct 1 ms 776 KB Output is correct
9 Correct 3 ms 768 KB Output is correct
10 Correct 0 ms 768 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 317 ms 684 KB Output is correct
2 Correct 394 ms 684 KB Output is correct
3 Correct 575 ms 684 KB Output is correct
4 Correct 455 ms 684 KB Output is correct
5 Correct 415 ms 684 KB Output is correct
6 Correct 342 ms 684 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 344 ms 680 KB Output is correct
2 Correct 268 ms 684 KB Output is correct
3 Correct 501 ms 792 KB Output is correct
4 Correct 403 ms 796 KB Output is correct
5 Correct 342 ms 684 KB Output is correct
6 Correct 249 ms 684 KB Output is correct
7 Correct 257 ms 684 KB Output is correct
8 Correct 2 ms 768 KB Output is correct
9 Correct 1 ms 764 KB Output is correct
10 Correct 0 ms 776 KB Output is correct
11 Correct 435 ms 684 KB Output is correct
12 Correct 307 ms 788 KB Output is correct
13 Correct 303 ms 936 KB Output is correct
14 Correct 304 ms 684 KB Output is correct
15 Correct 30 ms 768 KB Output is correct
16 Correct 47 ms 868 KB Output is correct
17 Correct 75 ms 684 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 541 ms 684 KB Output is correct
2 Correct 424 ms 684 KB Output is correct
3 Correct 348 ms 684 KB Output is correct
4 Correct 1 ms 768 KB Output is correct
5 Correct 2 ms 768 KB Output is correct
6 Correct 0 ms 768 KB Output is correct
7 Correct 308 ms 684 KB Output is correct
8 Correct 627 ms 684 KB Output is correct
9 Correct 475 ms 684 KB Output is correct
10 Correct 396 ms 684 KB Output is correct
11 Correct 2 ms 768 KB Output is correct
12 Correct 3 ms 780 KB Output is correct
13 Correct 3 ms 768 KB Output is correct
14 Correct 2 ms 764 KB Output is correct
15 Correct 0 ms 768 KB Output is correct
16 Correct 327 ms 688 KB Output is correct
17 Correct 375 ms 684 KB Output is correct
18 Correct 326 ms 684 KB Output is correct
19 Correct 335 ms 684 KB Output is correct
20 Correct 306 ms 684 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 300 ms 684 KB Output is correct
2 Correct 296 ms 692 KB Output is correct
3 Correct 557 ms 684 KB Output is correct
4 Correct 519 ms 680 KB Output is correct
5 Correct 411 ms 684 KB Output is correct
6 Correct 293 ms 684 KB Output is correct
7 Correct 320 ms 688 KB Output is correct
8 Correct 1 ms 768 KB Output is correct
9 Correct 2 ms 768 KB Output is correct
10 Correct 0 ms 768 KB Output is correct
11 Correct 301 ms 864 KB Output is correct
12 Correct 354 ms 684 KB Output is correct
13 Correct 600 ms 684 KB Output is correct
14 Correct 465 ms 684 KB Output is correct
15 Correct 443 ms 684 KB Output is correct
16 Correct 342 ms 684 KB Output is correct
17 Correct 382 ms 684 KB Output is correct
18 Correct 345 ms 792 KB Output is correct
19 Correct 278 ms 784 KB Output is correct
20 Correct 320 ms 688 KB Output is correct
21 Correct 25 ms 768 KB Output is correct
22 Correct 46 ms 768 KB Output is correct
23 Correct 72 ms 684 KB Output is correct
24 Correct 3 ms 768 KB Output is correct
25 Correct 2 ms 768 KB Output is correct
26 Correct 3 ms 776 KB Output is correct
27 Correct 2 ms 768 KB Output is correct
28 Correct 0 ms 776 KB Output is correct
29 Correct 328 ms 684 KB Output is correct
30 Correct 372 ms 684 KB Output is correct
31 Correct 313 ms 940 KB Output is correct
32 Correct 336 ms 684 KB Output is correct
33 Correct 374 ms 684 KB Output is correct
34 Correct 206 ms 900 KB Output is correct
35 Correct 300 ms 688 KB Output is correct
36 Correct 310 ms 1052 KB Output is correct
37 Correct 297 ms 900 KB Output is correct
38 Correct 335 ms 788 KB Output is correct
39 Correct 275 ms 800 KB Output is correct
40 Correct 295 ms 932 KB Output is correct
41 Correct 338 ms 792 KB Output is correct
42 Correct 31 ms 764 KB Output is correct
43 Correct 64 ms 768 KB Output is correct
44 Correct 83 ms 744 KB Output is correct
45 Correct 109 ms 764 KB Output is correct
46 Correct 223 ms 684 KB Output is correct
47 Correct 225 ms 688 KB Output is correct
48 Correct 34 ms 736 KB Output is correct
49 Correct 27 ms 860 KB Output is correct