Submission #434395

# Submission time Handle Problem Language Result Execution time Memory
434395 2021-06-21T08:00:43 Z radaiosm7 Stations (IOI20_stations) C++17
100 / 100
1105 ms 764 KB
#include "stations.h"
#include <vector>
#include <bits/stdc++.h>
using namespace std;
int timer;
vector<int> labels;
vector<int> adj[1005];

void dfs(int x, int p=-1, int curr=0) {
  if (curr == 0) {
    labels[x] = timer++;
  }

  for (auto y : adj[x]) {
    if (y != p) dfs(y, x, curr^1);
  }

  if (curr == 1) {
    labels[x] = timer++;
  }
}

vector<int> label(int n, int k, vector<int> u, vector<int> v) {
  timer = 0;
  labels.clear();
  labels.resize(n);
  for (int i=0; i < n; ++i) {
    adj[i].clear();
  }

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

  dfs(0);

	return labels;
}

int find_next_station(int s, int t, vector<int> c) {
  if ((int)c.size() == 1) return c[0];

  else if (s > c[0]) {
    if (t <= c[0] || t > s) {
      return c[0];
    }

    else {
      return *--upper_bound(c.begin(), c.end(), t);
    }
  }

  else {
    if (t < s || t >= c.back()) {
      return c.back();
    }

    else {
      return *lower_bound(c.begin(), c.end(), t);
    }
  }
}
# Verdict Execution time Memory Grader output
1 Correct 595 ms 584 KB Output is correct
2 Correct 506 ms 620 KB Output is correct
3 Correct 1059 ms 400 KB Output is correct
4 Correct 547 ms 516 KB Output is correct
5 Correct 758 ms 400 KB Output is correct
6 Correct 573 ms 636 KB Output is correct
7 Correct 554 ms 528 KB Output is correct
8 Correct 3 ms 468 KB Output is correct
9 Correct 6 ms 516 KB Output is correct
10 Correct 2 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 558 ms 500 KB Output is correct
2 Correct 552 ms 528 KB Output is correct
3 Correct 1035 ms 636 KB Output is correct
4 Correct 791 ms 508 KB Output is correct
5 Correct 629 ms 512 KB Output is correct
6 Correct 574 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 596 ms 644 KB Output is correct
2 Correct 486 ms 628 KB Output is correct
3 Correct 1047 ms 412 KB Output is correct
4 Correct 737 ms 508 KB Output is correct
5 Correct 698 ms 552 KB Output is correct
6 Correct 469 ms 528 KB Output is correct
7 Correct 464 ms 640 KB Output is correct
8 Correct 5 ms 468 KB Output is correct
9 Correct 7 ms 468 KB Output is correct
10 Correct 2 ms 476 KB Output is correct
11 Correct 699 ms 508 KB Output is correct
12 Correct 554 ms 760 KB Output is correct
13 Correct 475 ms 752 KB Output is correct
14 Correct 564 ms 532 KB Output is correct
15 Correct 70 ms 556 KB Output is correct
16 Correct 90 ms 528 KB Output is correct
17 Correct 140 ms 528 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 936 ms 416 KB Output is correct
2 Correct 764 ms 508 KB Output is correct
3 Correct 735 ms 512 KB Output is correct
4 Correct 3 ms 472 KB Output is correct
5 Correct 8 ms 468 KB Output is correct
6 Correct 2 ms 476 KB Output is correct
7 Correct 640 ms 528 KB Output is correct
8 Correct 1105 ms 500 KB Output is correct
9 Correct 846 ms 416 KB Output is correct
10 Correct 722 ms 400 KB Output is correct
11 Correct 6 ms 468 KB Output is correct
12 Correct 6 ms 468 KB Output is correct
13 Correct 4 ms 468 KB Output is correct
14 Correct 3 ms 476 KB Output is correct
15 Correct 3 ms 468 KB Output is correct
16 Correct 638 ms 408 KB Output is correct
17 Correct 588 ms 512 KB Output is correct
18 Correct 693 ms 640 KB Output is correct
19 Correct 582 ms 512 KB Output is correct
20 Correct 609 ms 548 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 569 ms 620 KB Output is correct
2 Correct 563 ms 636 KB Output is correct
3 Correct 997 ms 528 KB Output is correct
4 Correct 760 ms 400 KB Output is correct
5 Correct 680 ms 404 KB Output is correct
6 Correct 442 ms 528 KB Output is correct
7 Correct 547 ms 528 KB Output is correct
8 Correct 4 ms 468 KB Output is correct
9 Correct 5 ms 468 KB Output is correct
10 Correct 2 ms 476 KB Output is correct
11 Correct 482 ms 492 KB Output is correct
12 Correct 648 ms 528 KB Output is correct
13 Correct 1011 ms 400 KB Output is correct
14 Correct 786 ms 400 KB Output is correct
15 Correct 749 ms 572 KB Output is correct
16 Correct 551 ms 532 KB Output is correct
17 Correct 607 ms 400 KB Output is correct
18 Correct 524 ms 616 KB Output is correct
19 Correct 615 ms 604 KB Output is correct
20 Correct 551 ms 580 KB Output is correct
21 Correct 68 ms 448 KB Output is correct
22 Correct 97 ms 552 KB Output is correct
23 Correct 111 ms 592 KB Output is correct
24 Correct 7 ms 472 KB Output is correct
25 Correct 7 ms 472 KB Output is correct
26 Correct 8 ms 476 KB Output is correct
27 Correct 3 ms 480 KB Output is correct
28 Correct 2 ms 468 KB Output is correct
29 Correct 514 ms 400 KB Output is correct
30 Correct 571 ms 400 KB Output is correct
31 Correct 507 ms 512 KB Output is correct
32 Correct 546 ms 400 KB Output is correct
33 Correct 609 ms 408 KB Output is correct
34 Correct 379 ms 532 KB Output is correct
35 Correct 457 ms 764 KB Output is correct
36 Correct 459 ms 620 KB Output is correct
37 Correct 471 ms 596 KB Output is correct
38 Correct 522 ms 624 KB Output is correct
39 Correct 490 ms 636 KB Output is correct
40 Correct 580 ms 740 KB Output is correct
41 Correct 556 ms 632 KB Output is correct
42 Correct 77 ms 512 KB Output is correct
43 Correct 125 ms 648 KB Output is correct
44 Correct 143 ms 512 KB Output is correct
45 Correct 163 ms 512 KB Output is correct
46 Correct 342 ms 512 KB Output is correct
47 Correct 279 ms 528 KB Output is correct
48 Correct 78 ms 752 KB Output is correct
49 Correct 69 ms 672 KB Output is correct