답안 #412513

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
412513 2021-05-27T03:08:28 Z two_sides 기지국 (IOI20_stations) C++17
100 / 100
1188 ms 776 KB
#include "stations.h"
#include <bits/stdc++.h>

using namespace std;

void dfs(int u, int p, bool d, int &cnt, const vector <vector <int>> &adj, vector <int> &label) {
    if (!d) label[u] = cnt++;
    for (int v : adj[u])
        if (v != p) dfs(v, u, !d, cnt, adj, label);
    if (d) label[u] = cnt++; 
}

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

int find_next_station(int s, int t, vector <int> c) {
    if (s < c[0]) {
        int lo = s, hi = c.size() > 1 ? c[c.size() - 2] : s;
        if (lo <= t && t <= hi) {
            for (int u : c)
                if (u >= t) return u;
        }
        return c[c.size() - 1];
    } else {
        int hi = s, lo = c.size() > 1 ? c[1] : s;
        if (lo <= t && t <= hi) {
            reverse(c.begin(), c.end());
            for (int u : c)
                if (u <= t) return u;
        }
        return c[0];
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 579 ms 528 KB Output is correct
2 Correct 537 ms 656 KB Output is correct
3 Correct 1097 ms 400 KB Output is correct
4 Correct 794 ms 584 KB Output is correct
5 Correct 743 ms 492 KB Output is correct
6 Correct 544 ms 664 KB Output is correct
7 Correct 465 ms 612 KB Output is correct
8 Correct 3 ms 468 KB Output is correct
9 Correct 5 ms 480 KB Output is correct
10 Correct 2 ms 468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 546 ms 520 KB Output is correct
2 Correct 687 ms 528 KB Output is correct
3 Correct 909 ms 488 KB Output is correct
4 Correct 856 ms 400 KB Output is correct
5 Correct 648 ms 480 KB Output is correct
6 Correct 509 ms 528 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 611 ms 692 KB Output is correct
2 Correct 513 ms 528 KB Output is correct
3 Correct 1095 ms 468 KB Output is correct
4 Correct 734 ms 400 KB Output is correct
5 Correct 687 ms 400 KB Output is correct
6 Correct 582 ms 528 KB Output is correct
7 Correct 475 ms 608 KB Output is correct
8 Correct 3 ms 468 KB Output is correct
9 Correct 5 ms 468 KB Output is correct
10 Correct 2 ms 468 KB Output is correct
11 Correct 796 ms 400 KB Output is correct
12 Correct 504 ms 700 KB Output is correct
13 Correct 511 ms 684 KB Output is correct
14 Correct 557 ms 492 KB Output is correct
15 Correct 60 ms 404 KB Output is correct
16 Correct 82 ms 592 KB Output is correct
17 Correct 120 ms 488 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1150 ms 400 KB Output is correct
2 Correct 826 ms 400 KB Output is correct
3 Correct 860 ms 484 KB Output is correct
4 Correct 3 ms 468 KB Output is correct
5 Correct 6 ms 468 KB Output is correct
6 Correct 2 ms 468 KB Output is correct
7 Correct 785 ms 520 KB Output is correct
8 Correct 887 ms 400 KB Output is correct
9 Correct 973 ms 400 KB Output is correct
10 Correct 651 ms 484 KB Output is correct
11 Correct 6 ms 468 KB Output is correct
12 Correct 7 ms 416 KB Output is correct
13 Correct 5 ms 468 KB Output is correct
14 Correct 5 ms 468 KB Output is correct
15 Correct 3 ms 468 KB Output is correct
16 Correct 652 ms 484 KB Output is correct
17 Correct 570 ms 400 KB Output is correct
18 Correct 567 ms 400 KB Output is correct
19 Correct 508 ms 484 KB Output is correct
20 Correct 471 ms 400 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 714 ms 640 KB Output is correct
2 Correct 574 ms 640 KB Output is correct
3 Correct 1188 ms 488 KB Output is correct
4 Correct 818 ms 476 KB Output is correct
5 Correct 610 ms 488 KB Output is correct
6 Correct 579 ms 660 KB Output is correct
7 Correct 501 ms 484 KB Output is correct
8 Correct 4 ms 468 KB Output is correct
9 Correct 4 ms 468 KB Output is correct
10 Correct 2 ms 464 KB Output is correct
11 Correct 506 ms 528 KB Output is correct
12 Correct 638 ms 488 KB Output is correct
13 Correct 1007 ms 400 KB Output is correct
14 Correct 746 ms 484 KB Output is correct
15 Correct 695 ms 492 KB Output is correct
16 Correct 622 ms 492 KB Output is correct
17 Correct 611 ms 400 KB Output is correct
18 Correct 478 ms 572 KB Output is correct
19 Correct 535 ms 700 KB Output is correct
20 Correct 547 ms 512 KB Output is correct
21 Correct 55 ms 468 KB Output is correct
22 Correct 68 ms 540 KB Output is correct
23 Correct 130 ms 576 KB Output is correct
24 Correct 7 ms 468 KB Output is correct
25 Correct 5 ms 448 KB Output is correct
26 Correct 4 ms 468 KB Output is correct
27 Correct 4 ms 468 KB Output is correct
28 Correct 3 ms 468 KB Output is correct
29 Correct 579 ms 484 KB Output is correct
30 Correct 665 ms 488 KB Output is correct
31 Correct 580 ms 400 KB Output is correct
32 Correct 550 ms 492 KB Output is correct
33 Correct 522 ms 400 KB Output is correct
34 Correct 400 ms 612 KB Output is correct
35 Correct 516 ms 776 KB Output is correct
36 Correct 469 ms 604 KB Output is correct
37 Correct 538 ms 576 KB Output is correct
38 Correct 594 ms 648 KB Output is correct
39 Correct 577 ms 568 KB Output is correct
40 Correct 481 ms 568 KB Output is correct
41 Correct 545 ms 712 KB Output is correct
42 Correct 60 ms 548 KB Output is correct
43 Correct 112 ms 484 KB Output is correct
44 Correct 125 ms 532 KB Output is correct
45 Correct 221 ms 492 KB Output is correct
46 Correct 325 ms 656 KB Output is correct
47 Correct 344 ms 620 KB Output is correct
48 Correct 62 ms 572 KB Output is correct
49 Correct 71 ms 640 KB Output is correct