답안 #863343

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
863343 2023-10-20T05:07:36 Z NeroZein 기지국 (IOI20_stations) C++17
100 / 100
523 ms 1544 KB
#include "stations.h"
#include "bits/stdc++.h"

using namespace std; 

vector<int> label(int n, int k, vector<int> ui, vector<int> vi) {
  vector<int> labels(n);
  vector<vector<int>> g(n);
  for (int i = 0; i < n - 1; ++i) {
    g[ui[i]].push_back(vi[i]);
    g[vi[i]].push_back(ui[i]);
  }
  int cu = 0;
  function<void(int, int, bool)> Dfs = [&](int v, int p, bool uin) {
    if (uin) {
      labels[v] = cu++; 
    }
    for (int u : g[v]) {
      if (u != p) {
        Dfs(u, v, uin ^ 1); 
      }
    }
    if (!uin) {
      labels[v] = cu++; 
    }
  };
  Dfs(0, 0, 1);
  return labels;
}

int find_next_station(int s, int t, vector<int> c) {
  sort(c.begin(), c.end()); 
  if (c.size() == 1) {
    return c[0]; 
  }
  if (c[0] < s) {//I have my tin 
    int l = c[1], r = s; 
    if (t >= l && t <= r) {
      for (int i = (int) c.size() - 1; i >= 0; --i) {
        if (c[i] <= t) {
          return c[i]; 
        }
      }
    } else {
      return c[0]; 
    }
  } else {
    int l = s, r = c[c.size() - 2];
    if (t >= l && t <= r) {
      for (int i = 0; i < (int) c.size(); ++i) {
        if (c[i] >= t) {
          return c[i]; 
        }
      }
    } else {
      return c.back(); 
    }
  }
}

Compilation message

stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:59:1: warning: control reaches end of non-void function [-Wreturn-type]
   59 | }
      | ^
# 결과 실행 시간 메모리 Grader output
1 Correct 343 ms 944 KB Output is correct
2 Correct 252 ms 956 KB Output is correct
3 Correct 517 ms 688 KB Output is correct
4 Correct 438 ms 684 KB Output is correct
5 Correct 412 ms 684 KB Output is correct
6 Correct 303 ms 928 KB Output is correct
7 Correct 261 ms 684 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 852 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 316 ms 852 KB Output is correct
2 Correct 309 ms 788 KB Output is correct
3 Correct 523 ms 684 KB Output is correct
4 Correct 400 ms 684 KB Output is correct
5 Correct 336 ms 684 KB Output is correct
6 Correct 300 ms 684 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 303 ms 948 KB Output is correct
2 Correct 265 ms 936 KB Output is correct
3 Correct 513 ms 940 KB Output is correct
4 Correct 452 ms 684 KB Output is correct
5 Correct 354 ms 684 KB Output is correct
6 Correct 256 ms 928 KB Output is correct
7 Correct 256 ms 684 KB Output is correct
8 Correct 2 ms 772 KB Output is correct
9 Correct 3 ms 768 KB Output is correct
10 Correct 0 ms 768 KB Output is correct
11 Correct 345 ms 940 KB Output is correct
12 Correct 255 ms 1368 KB Output is correct
13 Correct 273 ms 1292 KB Output is correct
14 Correct 255 ms 684 KB Output is correct
15 Correct 28 ms 764 KB Output is correct
16 Correct 37 ms 880 KB Output is correct
17 Correct 67 ms 852 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 516 ms 684 KB Output is correct
2 Correct 351 ms 684 KB Output is correct
3 Correct 304 ms 684 KB Output is correct
4 Correct 1 ms 768 KB Output is correct
5 Correct 1 ms 768 KB Output is correct
6 Correct 0 ms 768 KB Output is correct
7 Correct 344 ms 936 KB Output is correct
8 Correct 522 ms 936 KB Output is correct
9 Correct 389 ms 684 KB Output is correct
10 Correct 333 ms 940 KB Output is correct
11 Correct 2 ms 768 KB Output is correct
12 Correct 3 ms 764 KB Output is correct
13 Correct 3 ms 768 KB Output is correct
14 Correct 2 ms 768 KB Output is correct
15 Correct 0 ms 764 KB Output is correct
16 Correct 280 ms 684 KB Output is correct
17 Correct 299 ms 684 KB Output is correct
18 Correct 280 ms 684 KB Output is correct
19 Correct 308 ms 684 KB Output is correct
20 Correct 293 ms 684 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 303 ms 944 KB Output is correct
2 Correct 248 ms 936 KB Output is correct
3 Correct 504 ms 684 KB Output is correct
4 Correct 403 ms 684 KB Output is correct
5 Correct 327 ms 684 KB Output is correct
6 Correct 253 ms 956 KB Output is correct
7 Correct 260 ms 684 KB Output is correct
8 Correct 1 ms 768 KB Output is correct
9 Correct 2 ms 1016 KB Output is correct
10 Correct 0 ms 1136 KB Output is correct
11 Correct 277 ms 856 KB Output is correct
12 Correct 315 ms 992 KB Output is correct
13 Correct 521 ms 684 KB Output is correct
14 Correct 387 ms 684 KB Output is correct
15 Correct 357 ms 684 KB Output is correct
16 Correct 257 ms 684 KB Output is correct
17 Correct 344 ms 684 KB Output is correct
18 Correct 256 ms 1352 KB Output is correct
19 Correct 262 ms 1544 KB Output is correct
20 Correct 263 ms 684 KB Output is correct
21 Correct 32 ms 768 KB Output is correct
22 Correct 36 ms 860 KB Output is correct
23 Correct 56 ms 1376 KB Output is correct
24 Correct 2 ms 768 KB Output is correct
25 Correct 4 ms 768 KB Output is correct
26 Correct 2 ms 768 KB Output is correct
27 Correct 1 ms 768 KB Output is correct
28 Correct 1 ms 768 KB Output is correct
29 Correct 273 ms 684 KB Output is correct
30 Correct 283 ms 684 KB Output is correct
31 Correct 299 ms 684 KB Output is correct
32 Correct 301 ms 684 KB Output is correct
33 Correct 285 ms 684 KB Output is correct
34 Correct 199 ms 912 KB Output is correct
35 Correct 264 ms 1220 KB Output is correct
36 Correct 277 ms 1024 KB Output is correct
37 Correct 269 ms 1140 KB Output is correct
38 Correct 272 ms 1132 KB Output is correct
39 Correct 268 ms 1216 KB Output is correct
40 Correct 255 ms 976 KB Output is correct
41 Correct 255 ms 1136 KB Output is correct
42 Correct 38 ms 912 KB Output is correct
43 Correct 56 ms 852 KB Output is correct
44 Correct 85 ms 856 KB Output is correct
45 Correct 82 ms 1116 KB Output is correct
46 Correct 178 ms 864 KB Output is correct
47 Correct 187 ms 896 KB Output is correct
48 Correct 37 ms 1116 KB Output is correct
49 Correct 40 ms 1380 KB Output is correct