Submission #308631

# Submission time Handle Problem Language Result Execution time Memory
308631 2020-10-01T15:21:33 Z szekelymilan Stations (IOI20_stations) C++14
52.3206 / 100
1045 ms 1288 KB
#include "stations.h"
#include <vector>

const int P = 1000;

std::vector<std::vector<int>> G;
std::vector<int> labels;
int inTime, outTime;

void DFS(int node = 0) {
  labels[node] = (inTime++) * P;

  for (int v : G[node])
    if (labels[v] == -1)
      DFS(v);
  
  labels[node] += outTime++;
}

std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
  G.assign(n, std::vector<int>());
  labels.assign(n, -1);
  inTime = 0, outTime = 0;

  for (int i = 0; i < n - 1; i++) {
    G[u[i]].push_back(v[i]);
    G[v[i]].push_back(u[i]);
  }

  DFS();

  return labels;
}

inline bool inside(int a, int b) {
  return a / P <= b / P && b % P <= a % P;
}

int find_next_station(int s, int t, std::vector<int> c) {
  int parent = -1;

  for (int node : c)
    if (inside(node, s))
      parent = node;
  
  for (int node : c)
    if (node != parent && inside(node, t))
      return node;
  
  return parent;
}
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 384 KB Invalid labels (values out of range). scenario=0, k=1000, vertex=1, label=6004
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB Invalid labels (values out of range). scenario=0, k=1000, vertex=1, label=1510
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 543 ms 768 KB Output is correct
2 Correct 457 ms 784 KB Output is correct
3 Correct 933 ms 640 KB Output is correct
4 Correct 706 ms 640 KB Output is correct
5 Correct 587 ms 664 KB Output is correct
6 Correct 508 ms 804 KB Output is correct
7 Correct 469 ms 744 KB Output is correct
8 Correct 3 ms 640 KB Output is correct
9 Correct 4 ms 640 KB Output is correct
10 Correct 0 ms 640 KB Output is correct
11 Correct 692 ms 980 KB Output is correct
12 Correct 623 ms 804 KB Output is correct
13 Correct 570 ms 768 KB Output is correct
14 Correct 510 ms 836 KB Output is correct
15 Correct 62 ms 880 KB Output is correct
16 Correct 68 ms 860 KB Output is correct
17 Correct 117 ms 828 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1045 ms 664 KB Output is correct
2 Correct 762 ms 640 KB Output is correct
3 Correct 665 ms 640 KB Output is correct
4 Correct 2 ms 640 KB Output is correct
5 Correct 3 ms 640 KB Output is correct
6 Correct 1 ms 652 KB Output is correct
7 Correct 663 ms 640 KB Output is correct
8 Correct 933 ms 640 KB Output is correct
9 Correct 730 ms 660 KB Output is correct
10 Correct 619 ms 656 KB Output is correct
11 Correct 7 ms 640 KB Output is correct
12 Correct 6 ms 656 KB Output is correct
13 Correct 3 ms 640 KB Output is correct
14 Correct 3 ms 652 KB Output is correct
15 Correct 1 ms 640 KB Output is correct
16 Correct 556 ms 656 KB Output is correct
17 Correct 483 ms 660 KB Output is correct
18 Correct 504 ms 640 KB Output is correct
19 Correct 565 ms 656 KB Output is correct
20 Correct 543 ms 640 KB Output is correct
# Verdict Execution time Memory Grader output
1 Partially correct 681 ms 1024 KB Partially correct
2 Partially correct 463 ms 768 KB Partially correct
3 Correct 980 ms 640 KB Output is correct
4 Partially correct 794 ms 768 KB Partially correct
5 Partially correct 661 ms 640 KB Partially correct
6 Partially correct 606 ms 1024 KB Partially correct
7 Partially correct 510 ms 820 KB Partially correct
8 Partially correct 3 ms 640 KB Partially correct
9 Partially correct 4 ms 664 KB Partially correct
10 Partially correct 1 ms 640 KB Partially correct
11 Partially correct 489 ms 928 KB Partially correct
12 Partially correct 576 ms 752 KB Partially correct
13 Correct 1021 ms 640 KB Output is correct
14 Partially correct 771 ms 780 KB Partially correct
15 Partially correct 614 ms 640 KB Partially correct
16 Partially correct 552 ms 844 KB Partially correct
17 Partially correct 717 ms 640 KB Partially correct
18 Partially correct 534 ms 888 KB Partially correct
19 Partially correct 480 ms 888 KB Partially correct
20 Partially correct 501 ms 768 KB Partially correct
21 Partially correct 58 ms 768 KB Partially correct
22 Partially correct 77 ms 768 KB Partially correct
23 Partially correct 141 ms 768 KB Partially correct
24 Partially correct 6 ms 800 KB Partially correct
25 Partially correct 5 ms 640 KB Partially correct
26 Partially correct 3 ms 640 KB Partially correct
27 Partially correct 5 ms 640 KB Partially correct
28 Partially correct 1 ms 668 KB Partially correct
29 Partially correct 565 ms 776 KB Partially correct
30 Partially correct 565 ms 640 KB Partially correct
31 Partially correct 552 ms 656 KB Partially correct
32 Partially correct 644 ms 640 KB Partially correct
33 Partially correct 545 ms 640 KB Partially correct
34 Partially correct 410 ms 1288 KB Partially correct
35 Partially correct 499 ms 816 KB Partially correct
36 Partially correct 489 ms 836 KB Partially correct
37 Partially correct 503 ms 788 KB Partially correct
38 Partially correct 625 ms 784 KB Partially correct
39 Partially correct 545 ms 928 KB Partially correct
40 Partially correct 479 ms 736 KB Partially correct
41 Partially correct 559 ms 896 KB Partially correct
42 Partially correct 58 ms 980 KB Partially correct
43 Partially correct 145 ms 824 KB Partially correct
44 Partially correct 165 ms 768 KB Partially correct
45 Partially correct 207 ms 768 KB Partially correct
46 Partially correct 410 ms 1024 KB Partially correct
47 Partially correct 373 ms 768 KB Partially correct
48 Partially correct 72 ms 992 KB Partially correct
49 Partially correct 73 ms 768 KB Partially correct