Submission #598277

# Submission time Handle Problem Language Result Execution time Memory
598277 2022-07-17T22:08:18 Z stevancv Stations (IOI20_stations) C++14
100 / 100
935 ms 748 KB
#include <bits/stdc++.h>
#include "stations.h"
#define ll long long
#define ld long double
#define sp ' '
#define en '\n'
#define smin(a, b) a = min(a, b)
#define smax(a, b) a = max(a, b)
using namespace std;
const int N = 5e5 + 2;
const int mod = 1e9 + 7;
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
    vector<vector<int>> g(n);
    for (int i = 0; i < n - 1; i++) {
        g[u[i]].push_back(v[i]);
        g[v[i]].push_back(u[i]);
    }
    vector<int> ans(n);
    int t = 0;
    function<void(int, int, int)> Dfs = [&] (int s, int e, int d) {
        if (d % 2 == 0) ans[s] = t++;
        for (int u : g[s]) if (u != e) Dfs(u, s, d + 1);
        if (d % 2 == 1) ans[s] = t++;
    };
  	Dfs(0, 0, 0);
    return ans;
}
int find_next_station(int s, int t, vector<int> c) {
    int o = c.size();
    if (o == 1) return c[0];
    for (int i = 0; i < o; i++) if (c[i] == t) return c[i];
    if (s < c[0]) {
        if (s < t && t < c[0]) return c[0];
        for (int i = 1; i < o - 1; i++) {
            if (c[i - 1] < t && t < c[i]) return c[i];
        }
        return c.back();
    }
    if (c.back() < t && t < s) return c.back();
    for (int i = o - 2; i >= 1; i--) {
        if (c[i] < t && t < c[i + 1]) return c[i];
    }
    return c[0];
}
# Verdict Execution time Memory Grader output
1 Correct 494 ms 672 KB Output is correct
2 Correct 443 ms 636 KB Output is correct
3 Correct 768 ms 420 KB Output is correct
4 Correct 663 ms 508 KB Output is correct
5 Correct 575 ms 416 KB Output is correct
6 Correct 433 ms 676 KB Output is correct
7 Correct 421 ms 628 KB Output is correct
8 Correct 2 ms 500 KB Output is correct
9 Correct 4 ms 492 KB Output is correct
10 Correct 1 ms 492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 433 ms 500 KB Output is correct
2 Correct 377 ms 508 KB Output is correct
3 Correct 753 ms 416 KB Output is correct
4 Correct 669 ms 416 KB Output is correct
5 Correct 577 ms 420 KB Output is correct
6 Correct 427 ms 500 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 504 ms 676 KB Output is correct
2 Correct 467 ms 664 KB Output is correct
3 Correct 865 ms 420 KB Output is correct
4 Correct 688 ms 416 KB Output is correct
5 Correct 588 ms 504 KB Output is correct
6 Correct 377 ms 636 KB Output is correct
7 Correct 429 ms 544 KB Output is correct
8 Correct 1 ms 492 KB Output is correct
9 Correct 3 ms 492 KB Output is correct
10 Correct 0 ms 492 KB Output is correct
11 Correct 563 ms 420 KB Output is correct
12 Correct 472 ms 748 KB Output is correct
13 Correct 425 ms 744 KB Output is correct
14 Correct 430 ms 548 KB Output is correct
15 Correct 53 ms 472 KB Output is correct
16 Correct 71 ms 572 KB Output is correct
17 Correct 97 ms 544 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 935 ms 416 KB Output is correct
2 Correct 685 ms 508 KB Output is correct
3 Correct 576 ms 416 KB Output is correct
4 Correct 1 ms 488 KB Output is correct
5 Correct 3 ms 492 KB Output is correct
6 Correct 1 ms 500 KB Output is correct
7 Correct 603 ms 444 KB Output is correct
8 Correct 888 ms 420 KB Output is correct
9 Correct 585 ms 420 KB Output is correct
10 Correct 600 ms 420 KB Output is correct
11 Correct 5 ms 492 KB Output is correct
12 Correct 5 ms 500 KB Output is correct
13 Correct 3 ms 500 KB Output is correct
14 Correct 3 ms 500 KB Output is correct
15 Correct 1 ms 504 KB Output is correct
16 Correct 567 ms 504 KB Output is correct
17 Correct 501 ms 416 KB Output is correct
18 Correct 378 ms 504 KB Output is correct
19 Correct 417 ms 416 KB Output is correct
20 Correct 476 ms 416 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 467 ms 676 KB Output is correct
2 Correct 434 ms 676 KB Output is correct
3 Correct 803 ms 512 KB Output is correct
4 Correct 639 ms 416 KB Output is correct
5 Correct 581 ms 420 KB Output is correct
6 Correct 396 ms 632 KB Output is correct
7 Correct 448 ms 544 KB Output is correct
8 Correct 2 ms 500 KB Output is correct
9 Correct 3 ms 492 KB Output is correct
10 Correct 0 ms 492 KB Output is correct
11 Correct 427 ms 508 KB Output is correct
12 Correct 465 ms 500 KB Output is correct
13 Correct 730 ms 504 KB Output is correct
14 Correct 708 ms 416 KB Output is correct
15 Correct 500 ms 420 KB Output is correct
16 Correct 432 ms 500 KB Output is correct
17 Correct 531 ms 420 KB Output is correct
18 Correct 473 ms 548 KB Output is correct
19 Correct 477 ms 704 KB Output is correct
20 Correct 454 ms 544 KB Output is correct
21 Correct 48 ms 492 KB Output is correct
22 Correct 69 ms 572 KB Output is correct
23 Correct 84 ms 544 KB Output is correct
24 Correct 4 ms 500 KB Output is correct
25 Correct 5 ms 500 KB Output is correct
26 Correct 4 ms 500 KB Output is correct
27 Correct 3 ms 492 KB Output is correct
28 Correct 1 ms 492 KB Output is correct
29 Correct 482 ms 532 KB Output is correct
30 Correct 502 ms 504 KB Output is correct
31 Correct 468 ms 416 KB Output is correct
32 Correct 498 ms 484 KB Output is correct
33 Correct 418 ms 416 KB Output is correct
34 Correct 264 ms 636 KB Output is correct
35 Correct 375 ms 712 KB Output is correct
36 Correct 370 ms 700 KB Output is correct
37 Correct 340 ms 624 KB Output is correct
38 Correct 446 ms 508 KB Output is correct
39 Correct 417 ms 600 KB Output is correct
40 Correct 397 ms 636 KB Output is correct
41 Correct 407 ms 584 KB Output is correct
42 Correct 58 ms 532 KB Output is correct
43 Correct 99 ms 700 KB Output is correct
44 Correct 108 ms 556 KB Output is correct
45 Correct 149 ms 584 KB Output is correct
46 Correct 315 ms 548 KB Output is correct
47 Correct 299 ms 632 KB Output is correct
48 Correct 62 ms 600 KB Output is correct
49 Correct 45 ms 604 KB Output is correct