Submission #934112

# Submission time Handle Problem Language Result Execution time Memory
934112 2024-02-26T19:31:10 Z EJIC_B_KEDAX Stations (IOI20_stations) C++17
100 / 100
548 ms 1416 KB
#include <bits/stdc++.h>

using ll = long long;

using namespace std;

vector<vector<int>> g;
vector<int> res;

void dfs(int s, int p = -1, int d = 0) {
    if (~d & 1) {
        res.push_back(s);
    }
    for (int i : g[s]) {
        if (i != p) {
            dfs(i, s, d + 1);
        }
    }
    if (d & 1) {
        res.push_back(s);
    }
}

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

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

Compilation message

stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:47:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |         for (int i = 0; i < c.size(); i++) {
      |                         ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 356 ms 936 KB Output is correct
2 Correct 230 ms 920 KB Output is correct
3 Correct 517 ms 684 KB Output is correct
4 Correct 436 ms 684 KB Output is correct
5 Correct 397 ms 684 KB Output is correct
6 Correct 254 ms 948 KB Output is correct
7 Correct 232 ms 684 KB Output is correct
8 Correct 1 ms 768 KB Output is correct
9 Correct 3 ms 768 KB Output is correct
10 Correct 0 ms 764 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 246 ms 864 KB Output is correct
2 Correct 313 ms 788 KB Output is correct
3 Correct 500 ms 684 KB Output is correct
4 Correct 353 ms 684 KB Output is correct
5 Correct 323 ms 684 KB Output is correct
6 Correct 266 ms 684 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 320 ms 936 KB Output is correct
2 Correct 257 ms 924 KB Output is correct
3 Correct 512 ms 684 KB Output is correct
4 Correct 388 ms 684 KB Output is correct
5 Correct 343 ms 684 KB Output is correct
6 Correct 252 ms 1060 KB Output is correct
7 Correct 237 ms 940 KB Output is correct
8 Correct 1 ms 764 KB Output is correct
9 Correct 2 ms 768 KB Output is correct
10 Correct 1 ms 768 KB Output is correct
11 Correct 339 ms 684 KB Output is correct
12 Correct 306 ms 1104 KB Output is correct
13 Correct 284 ms 1248 KB Output is correct
14 Correct 229 ms 888 KB Output is correct
15 Correct 36 ms 768 KB Output is correct
16 Correct 35 ms 916 KB Output is correct
17 Correct 57 ms 1148 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 495 ms 684 KB Output is correct
2 Correct 382 ms 684 KB Output is correct
3 Correct 334 ms 924 KB Output is correct
4 Correct 1 ms 768 KB Output is correct
5 Correct 2 ms 768 KB Output is correct
6 Correct 1 ms 768 KB Output is correct
7 Correct 393 ms 684 KB Output is correct
8 Correct 503 ms 684 KB Output is correct
9 Correct 491 ms 684 KB Output is correct
10 Correct 340 ms 684 KB Output is correct
11 Correct 3 ms 764 KB Output is correct
12 Correct 4 ms 768 KB Output is correct
13 Correct 3 ms 768 KB Output is correct
14 Correct 2 ms 764 KB Output is correct
15 Correct 1 ms 764 KB Output is correct
16 Correct 294 ms 684 KB Output is correct
17 Correct 332 ms 684 KB Output is correct
18 Correct 357 ms 684 KB Output is correct
19 Correct 379 ms 684 KB Output is correct
20 Correct 344 ms 684 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 409 ms 932 KB Output is correct
2 Correct 294 ms 936 KB Output is correct
3 Correct 548 ms 684 KB Output is correct
4 Correct 403 ms 684 KB Output is correct
5 Correct 435 ms 684 KB Output is correct
6 Correct 297 ms 924 KB Output is correct
7 Correct 266 ms 684 KB Output is correct
8 Correct 1 ms 764 KB Output is correct
9 Correct 1 ms 768 KB Output is correct
10 Correct 1 ms 764 KB Output is correct
11 Correct 266 ms 860 KB Output is correct
12 Correct 360 ms 820 KB Output is correct
13 Correct 544 ms 684 KB Output is correct
14 Correct 421 ms 684 KB Output is correct
15 Correct 374 ms 684 KB Output is correct
16 Correct 277 ms 684 KB Output is correct
17 Correct 349 ms 684 KB Output is correct
18 Correct 274 ms 1144 KB Output is correct
19 Correct 275 ms 1260 KB Output is correct
20 Correct 294 ms 940 KB Output is correct
21 Correct 28 ms 1016 KB Output is correct
22 Correct 39 ms 872 KB Output is correct
23 Correct 57 ms 1152 KB Output is correct
24 Correct 3 ms 768 KB Output is correct
25 Correct 2 ms 768 KB Output is correct
26 Correct 2 ms 768 KB Output is correct
27 Correct 3 ms 768 KB Output is correct
28 Correct 1 ms 768 KB Output is correct
29 Correct 366 ms 688 KB Output is correct
30 Correct 310 ms 684 KB Output is correct
31 Correct 319 ms 932 KB Output is correct
32 Correct 278 ms 684 KB Output is correct
33 Correct 355 ms 684 KB Output is correct
34 Correct 168 ms 916 KB Output is correct
35 Correct 265 ms 1216 KB Output is correct
36 Correct 310 ms 904 KB Output is correct
37 Correct 278 ms 1156 KB Output is correct
38 Correct 300 ms 972 KB Output is correct
39 Correct 299 ms 1140 KB Output is correct
40 Correct 263 ms 1144 KB Output is correct
41 Correct 273 ms 980 KB Output is correct
42 Correct 38 ms 848 KB Output is correct
43 Correct 60 ms 1116 KB Output is correct
44 Correct 70 ms 892 KB Output is correct
45 Correct 118 ms 884 KB Output is correct
46 Correct 189 ms 852 KB Output is correct
47 Correct 179 ms 884 KB Output is correct
48 Correct 35 ms 1416 KB Output is correct
49 Correct 28 ms 1176 KB Output is correct