답안 #306508

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
306508 2020-09-25T18:17:28 Z smax 기지국 (IOI20_stations) C++17
100 / 100
1022 ms 1132 KB
#include "stations.h"
#include <vector>
using namespace std;

int ti;
vector<int> adj[1005];

void dfs(int u, int p, int d, vector<int> &labels) {
    if (d % 2 == 0)
        labels[u] = ti++;
    for (int v : adj[u])
        if (v != p)
            dfs(v, u, d + 1, labels);
    if (d % 2 == 1)
        labels[u] = ti++;
}

std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
	std::vector<int> labels(n);

	ti = 0;
	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, -1, 0, labels);

	return labels;
}

int find_next_station(int s, int t, std::vector<int> c) {
    if (c.back() < s) {
        // odd depth
        if (t > s || t < c[0])
            return c[0];
        for (int i=0; i<(int)c.size()-1; i++)
            if (t >= c[i] && t < c[i+1])
                return c[i];
        return c.back();
    } else {
        // even depth
        if (t < s || t > c.back())
            return c.back();
        for (int i=(int)c.size()-1; i>0; i--)
            if (t <= c[i] && t > c[i-1])
                return c[i];
        return c[0];
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 554 ms 1024 KB Output is correct
2 Correct 459 ms 1008 KB Output is correct
3 Correct 869 ms 640 KB Output is correct
4 Correct 718 ms 776 KB Output is correct
5 Correct 779 ms 1008 KB Output is correct
6 Correct 471 ms 768 KB Output is correct
7 Correct 554 ms 788 KB Output is correct
8 Correct 2 ms 768 KB Output is correct
9 Correct 3 ms 768 KB Output is correct
10 Correct 1 ms 768 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 486 ms 828 KB Output is correct
2 Correct 559 ms 832 KB Output is correct
3 Correct 904 ms 884 KB Output is correct
4 Correct 690 ms 1024 KB Output is correct
5 Correct 641 ms 884 KB Output is correct
6 Correct 472 ms 768 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 734 ms 1008 KB Output is correct
2 Correct 477 ms 1008 KB Output is correct
3 Correct 979 ms 760 KB Output is correct
4 Correct 645 ms 880 KB Output is correct
5 Correct 714 ms 896 KB Output is correct
6 Correct 472 ms 1012 KB Output is correct
7 Correct 439 ms 788 KB Output is correct
8 Correct 3 ms 892 KB Output is correct
9 Correct 4 ms 768 KB Output is correct
10 Correct 1 ms 768 KB Output is correct
11 Correct 589 ms 888 KB Output is correct
12 Correct 508 ms 1024 KB Output is correct
13 Correct 475 ms 1020 KB Output is correct
14 Correct 451 ms 768 KB Output is correct
15 Correct 50 ms 768 KB Output is correct
16 Correct 63 ms 852 KB Output is correct
17 Correct 103 ms 828 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 877 ms 760 KB Output is correct
2 Correct 786 ms 784 KB Output is correct
3 Correct 752 ms 760 KB Output is correct
4 Correct 2 ms 888 KB Output is correct
5 Correct 3 ms 768 KB Output is correct
6 Correct 0 ms 768 KB Output is correct
7 Correct 728 ms 888 KB Output is correct
8 Correct 1022 ms 1024 KB Output is correct
9 Correct 727 ms 888 KB Output is correct
10 Correct 631 ms 768 KB Output is correct
11 Correct 4 ms 884 KB Output is correct
12 Correct 4 ms 768 KB Output is correct
13 Correct 3 ms 884 KB Output is correct
14 Correct 3 ms 768 KB Output is correct
15 Correct 1 ms 768 KB Output is correct
16 Correct 634 ms 768 KB Output is correct
17 Correct 498 ms 768 KB Output is correct
18 Correct 622 ms 768 KB Output is correct
19 Correct 495 ms 760 KB Output is correct
20 Correct 496 ms 768 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 577 ms 1024 KB Output is correct
2 Correct 485 ms 1008 KB Output is correct
3 Correct 815 ms 888 KB Output is correct
4 Correct 677 ms 884 KB Output is correct
5 Correct 580 ms 760 KB Output is correct
6 Correct 430 ms 1024 KB Output is correct
7 Correct 460 ms 796 KB Output is correct
8 Correct 2 ms 768 KB Output is correct
9 Correct 3 ms 768 KB Output is correct
10 Correct 0 ms 768 KB Output is correct
11 Correct 472 ms 768 KB Output is correct
12 Correct 582 ms 836 KB Output is correct
13 Correct 948 ms 768 KB Output is correct
14 Correct 868 ms 888 KB Output is correct
15 Correct 649 ms 888 KB Output is correct
16 Correct 585 ms 848 KB Output is correct
17 Correct 707 ms 880 KB Output is correct
18 Correct 438 ms 896 KB Output is correct
19 Correct 614 ms 1132 KB Output is correct
20 Correct 600 ms 852 KB Output is correct
21 Correct 76 ms 888 KB Output is correct
22 Correct 68 ms 860 KB Output is correct
23 Correct 115 ms 1080 KB Output is correct
24 Correct 6 ms 896 KB Output is correct
25 Correct 5 ms 768 KB Output is correct
26 Correct 4 ms 1024 KB Output is correct
27 Correct 4 ms 784 KB Output is correct
28 Correct 2 ms 892 KB Output is correct
29 Correct 498 ms 884 KB Output is correct
30 Correct 555 ms 888 KB Output is correct
31 Correct 493 ms 892 KB Output is correct
32 Correct 508 ms 892 KB Output is correct
33 Correct 503 ms 888 KB Output is correct
34 Correct 335 ms 780 KB Output is correct
35 Correct 434 ms 1024 KB Output is correct
36 Correct 608 ms 1048 KB Output is correct
37 Correct 476 ms 912 KB Output is correct
38 Correct 639 ms 796 KB Output is correct
39 Correct 519 ms 780 KB Output is correct
40 Correct 431 ms 768 KB Output is correct
41 Correct 535 ms 796 KB Output is correct
42 Correct 81 ms 848 KB Output is correct
43 Correct 104 ms 824 KB Output is correct
44 Correct 125 ms 812 KB Output is correct
45 Correct 160 ms 768 KB Output is correct
46 Correct 324 ms 832 KB Output is correct
47 Correct 342 ms 796 KB Output is correct
48 Correct 78 ms 792 KB Output is correct
49 Correct 74 ms 776 KB Output is correct