답안 #310056

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
310056 2020-10-05T11:58:55 Z Lemur95 기지국 (IOI20_stations) C++17
100 / 100
1202 ms 1256 KB
#include <bits/stdc++.h>
#include "stations.h"
#pragma GCC optimize("Ofast")
#define x first
#define y second
#define ld long double
#define ll long long

using namespace std;

vector <int> g[1005];
int nr;

void dfs(int nod, int h, int tata, vector <int> &labels) {
  if(h % 2 == 0)
    labels[nod] = nr++;
  for(auto &fiu : g[nod]) {
    if(fiu != tata)
      dfs(fiu, h + 1, nod, labels);
  }
  if(h % 2)
    labels[nod] = nr++;
}

vector <int> label(int n, int k, vector <int> u, vector <int> v) {
  vector <int> labels(n);
  for(int i = 0; i < n; i++)
    g[i].clear();
  nr = 0;
  for(int i = 0; i < n - 1; i++) {
    g[u[i]].push_back(v[i]);
    g[v[i]].push_back(u[i]);
  }
  dfs(0, 0, -1, labels);
  return labels;
}

int find_next_station(int s, int t, vector <int> c) {
  if(s < c[0]) {
    int tmp = s;
    for(auto &i : c) {
      if(tmp < t && t <= i)
        return i;
      tmp = i;
    }
    return c.back();
  }
  for(int i = 0; i < c.size(); i++) {
    if(c[i] <= t && t < (i != c.size() - 1 ? c[i + 1] : s + 1))
      return c[i];
  }
  return c[0];
}

Compilation message

stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:48:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   48 |   for(int i = 0; i < c.size(); i++) {
      |                  ~~^~~~~~~~~~
stations.cpp:49:28: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   49 |     if(c[i] <= t && t < (i != c.size() - 1 ? c[i + 1] : s + 1))
      |                          ~~^~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 516 ms 1256 KB Output is correct
2 Correct 493 ms 1008 KB Output is correct
3 Correct 853 ms 1000 KB Output is correct
4 Correct 667 ms 768 KB Output is correct
5 Correct 618 ms 884 KB Output is correct
6 Correct 465 ms 1008 KB Output is correct
7 Correct 471 ms 776 KB Output is correct
8 Correct 2 ms 888 KB Output is correct
9 Correct 4 ms 768 KB Output is correct
10 Correct 2 ms 880 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 472 ms 824 KB Output is correct
2 Correct 517 ms 820 KB Output is correct
3 Correct 863 ms 1032 KB Output is correct
4 Correct 646 ms 768 KB Output is correct
5 Correct 579 ms 876 KB Output is correct
6 Correct 485 ms 832 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 560 ms 1024 KB Output is correct
2 Correct 452 ms 1008 KB Output is correct
3 Correct 850 ms 1008 KB Output is correct
4 Correct 679 ms 1048 KB Output is correct
5 Correct 600 ms 880 KB Output is correct
6 Correct 498 ms 1132 KB Output is correct
7 Correct 461 ms 768 KB Output is correct
8 Correct 2 ms 884 KB Output is correct
9 Correct 4 ms 768 KB Output is correct
10 Correct 2 ms 884 KB Output is correct
11 Correct 567 ms 768 KB Output is correct
12 Correct 538 ms 1120 KB Output is correct
13 Correct 595 ms 1008 KB Output is correct
14 Correct 469 ms 832 KB Output is correct
15 Correct 69 ms 868 KB Output is correct
16 Correct 67 ms 768 KB Output is correct
17 Correct 95 ms 768 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 881 ms 880 KB Output is correct
2 Correct 716 ms 768 KB Output is correct
3 Correct 724 ms 884 KB Output is correct
4 Correct 3 ms 876 KB Output is correct
5 Correct 5 ms 876 KB Output is correct
6 Correct 2 ms 768 KB Output is correct
7 Correct 749 ms 768 KB Output is correct
8 Correct 1202 ms 880 KB Output is correct
9 Correct 694 ms 876 KB Output is correct
10 Correct 573 ms 884 KB Output is correct
11 Correct 5 ms 884 KB Output is correct
12 Correct 6 ms 1012 KB Output is correct
13 Correct 5 ms 872 KB Output is correct
14 Correct 4 ms 876 KB Output is correct
15 Correct 2 ms 884 KB Output is correct
16 Correct 669 ms 876 KB Output is correct
17 Correct 605 ms 884 KB Output is correct
18 Correct 617 ms 872 KB Output is correct
19 Correct 503 ms 876 KB Output is correct
20 Correct 548 ms 768 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 526 ms 1024 KB Output is correct
2 Correct 550 ms 1024 KB Output is correct
3 Correct 896 ms 876 KB Output is correct
4 Correct 804 ms 768 KB Output is correct
5 Correct 607 ms 768 KB Output is correct
6 Correct 475 ms 1024 KB Output is correct
7 Correct 445 ms 792 KB Output is correct
8 Correct 3 ms 768 KB Output is correct
9 Correct 5 ms 768 KB Output is correct
10 Correct 2 ms 876 KB Output is correct
11 Correct 463 ms 812 KB Output is correct
12 Correct 623 ms 820 KB Output is correct
13 Correct 990 ms 768 KB Output is correct
14 Correct 791 ms 868 KB Output is correct
15 Correct 605 ms 1004 KB Output is correct
16 Correct 478 ms 840 KB Output is correct
17 Correct 618 ms 876 KB Output is correct
18 Correct 494 ms 888 KB Output is correct
19 Correct 473 ms 1128 KB Output is correct
20 Correct 478 ms 828 KB Output is correct
21 Correct 57 ms 768 KB Output is correct
22 Correct 87 ms 832 KB Output is correct
23 Correct 131 ms 1024 KB Output is correct
24 Correct 7 ms 872 KB Output is correct
25 Correct 5 ms 1012 KB Output is correct
26 Correct 6 ms 884 KB Output is correct
27 Correct 4 ms 880 KB Output is correct
28 Correct 2 ms 888 KB Output is correct
29 Correct 579 ms 1024 KB Output is correct
30 Correct 568 ms 1024 KB Output is correct
31 Correct 487 ms 768 KB Output is correct
32 Correct 508 ms 876 KB Output is correct
33 Correct 590 ms 880 KB Output is correct
34 Correct 354 ms 1024 KB Output is correct
35 Correct 526 ms 1024 KB Output is correct
36 Correct 548 ms 1024 KB Output is correct
37 Correct 514 ms 784 KB Output is correct
38 Correct 543 ms 792 KB Output is correct
39 Correct 527 ms 780 KB Output is correct
40 Correct 465 ms 768 KB Output is correct
41 Correct 450 ms 768 KB Output is correct
42 Correct 65 ms 832 KB Output is correct
43 Correct 114 ms 948 KB Output is correct
44 Correct 128 ms 796 KB Output is correct
45 Correct 167 ms 768 KB Output is correct
46 Correct 304 ms 768 KB Output is correct
47 Correct 304 ms 788 KB Output is correct
48 Correct 67 ms 908 KB Output is correct
49 Correct 62 ms 1024 KB Output is correct