답안 #305648

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
305648 2020-09-23T18:02:04 Z jovan_b 기지국 (IOI20_stations) C++17
100 / 100
1161 ms 6008 KB
#include "stations.h"
#include <bits/stdc++.h>

using namespace std;

vector <int> graf[100005];
vector <int> labels;
int in[100005];
int out[100005];

int tajm;

void dfs(int v, int depth, int par){
    in[v] = ++tajm;
    for(auto c : graf[v]){
        if(c != par){
            dfs(c, depth+1, v);
        }
    }
    out[v] = ++tajm;
    if(depth%2){
        labels[v] = out[v];
    }
    else labels[v] = in[v];
}

map <int, int> koji;

std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
	labels.clear();
	labels.resize(n);
	for(int i=0; i<n; i++){
        graf[i].clear();
        in[i] = 0;
        out[i] = 0;
	}
	for(int i=0; i<n-1; i++){
        graf[u[i]].push_back(v[i]);
        graf[v[i]].push_back(u[i]);
	}
	dfs(0, 0, -1);
    int tr = -1;
    vector <int> vec;
    for(auto c : labels) vec.push_back(c);
    sort(vec.begin(), vec.end());
    koji.clear();
    for(auto c : vec){
        koji[c] = ++tr;
    }
    for(int i=0; i<n; i++) labels[i] = koji[labels[i]];
	return labels;
}

int find_next_station(int s, int t, std::vector<int> c) {
    if(s < c[0]){
        ///in
        if(s == 0){
            for(auto g : c) if(g >= t) return g;
        }
        int aut = c[c.size()-2];
        if(s <= t && t <= aut){
            for(auto g : c) if(g >= t) return g;
        }
        return c.back();
    }
    /// out
    int iin = c[1];
    if(iin <= t && t <= s){
        for(int j=c.size()-1; j>=1; j--){
            if(c[j] <= t) return c[j];
        }
    }
    return c[0];
}
# 결과 실행 시간 메모리 Grader output
1 Correct 600 ms 5652 KB Output is correct
2 Correct 551 ms 5624 KB Output is correct
3 Correct 1043 ms 5584 KB Output is correct
4 Correct 660 ms 5540 KB Output is correct
5 Correct 743 ms 5592 KB Output is correct
6 Correct 597 ms 5664 KB Output is correct
7 Correct 566 ms 5680 KB Output is correct
8 Correct 6 ms 5456 KB Output is correct
9 Correct 7 ms 5596 KB Output is correct
10 Correct 4 ms 5588 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 531 ms 5632 KB Output is correct
2 Correct 618 ms 5736 KB Output is correct
3 Correct 904 ms 5512 KB Output is correct
4 Correct 760 ms 5588 KB Output is correct
5 Correct 704 ms 5584 KB Output is correct
6 Correct 501 ms 5548 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 634 ms 6008 KB Output is correct
2 Correct 446 ms 5640 KB Output is correct
3 Correct 986 ms 5504 KB Output is correct
4 Correct 761 ms 5588 KB Output is correct
5 Correct 703 ms 5852 KB Output is correct
6 Correct 477 ms 5660 KB Output is correct
7 Correct 564 ms 5680 KB Output is correct
8 Correct 6 ms 5592 KB Output is correct
9 Correct 9 ms 5504 KB Output is correct
10 Correct 5 ms 5632 KB Output is correct
11 Correct 626 ms 5588 KB Output is correct
12 Correct 603 ms 5632 KB Output is correct
13 Correct 549 ms 5652 KB Output is correct
14 Correct 479 ms 5728 KB Output is correct
15 Correct 56 ms 5504 KB Output is correct
16 Correct 72 ms 5504 KB Output is correct
17 Correct 136 ms 5712 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 913 ms 5584 KB Output is correct
2 Correct 724 ms 5632 KB Output is correct
3 Correct 616 ms 5504 KB Output is correct
4 Correct 5 ms 5592 KB Output is correct
5 Correct 7 ms 5584 KB Output is correct
6 Correct 4 ms 5584 KB Output is correct
7 Correct 594 ms 5504 KB Output is correct
8 Correct 909 ms 5720 KB Output is correct
9 Correct 800 ms 5516 KB Output is correct
10 Correct 664 ms 5616 KB Output is correct
11 Correct 9 ms 5584 KB Output is correct
12 Correct 9 ms 5376 KB Output is correct
13 Correct 8 ms 5584 KB Output is correct
14 Correct 8 ms 5376 KB Output is correct
15 Correct 5 ms 5504 KB Output is correct
16 Correct 510 ms 5584 KB Output is correct
17 Correct 498 ms 5632 KB Output is correct
18 Correct 523 ms 5584 KB Output is correct
19 Correct 486 ms 5504 KB Output is correct
20 Correct 530 ms 5376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 621 ms 5644 KB Output is correct
2 Correct 513 ms 5660 KB Output is correct
3 Correct 1087 ms 5504 KB Output is correct
4 Correct 762 ms 5760 KB Output is correct
5 Correct 647 ms 5724 KB Output is correct
6 Correct 472 ms 5648 KB Output is correct
7 Correct 553 ms 5632 KB Output is correct
8 Correct 5 ms 5588 KB Output is correct
9 Correct 8 ms 5376 KB Output is correct
10 Correct 4 ms 5588 KB Output is correct
11 Correct 521 ms 5624 KB Output is correct
12 Correct 535 ms 5632 KB Output is correct
13 Correct 1161 ms 5584 KB Output is correct
14 Correct 732 ms 5584 KB Output is correct
15 Correct 829 ms 5632 KB Output is correct
16 Correct 495 ms 5732 KB Output is correct
17 Correct 673 ms 5588 KB Output is correct
18 Correct 525 ms 5624 KB Output is correct
19 Correct 509 ms 5764 KB Output is correct
20 Correct 475 ms 5736 KB Output is correct
21 Correct 74 ms 5572 KB Output is correct
22 Correct 94 ms 5516 KB Output is correct
23 Correct 154 ms 5716 KB Output is correct
24 Correct 8 ms 5504 KB Output is correct
25 Correct 8 ms 5588 KB Output is correct
26 Correct 7 ms 5504 KB Output is correct
27 Correct 8 ms 5536 KB Output is correct
28 Correct 5 ms 5536 KB Output is correct
29 Correct 632 ms 5504 KB Output is correct
30 Correct 568 ms 5584 KB Output is correct
31 Correct 542 ms 5504 KB Output is correct
32 Correct 533 ms 5580 KB Output is correct
33 Correct 591 ms 5712 KB Output is correct
34 Correct 334 ms 5668 KB Output is correct
35 Correct 508 ms 5624 KB Output is correct
36 Correct 559 ms 5772 KB Output is correct
37 Correct 528 ms 5680 KB Output is correct
38 Correct 539 ms 5684 KB Output is correct
39 Correct 473 ms 5632 KB Output is correct
40 Correct 524 ms 5960 KB Output is correct
41 Correct 562 ms 5816 KB Output is correct
42 Correct 70 ms 5752 KB Output is correct
43 Correct 130 ms 5720 KB Output is correct
44 Correct 148 ms 5700 KB Output is correct
45 Correct 171 ms 5632 KB Output is correct
46 Correct 350 ms 5736 KB Output is correct
47 Correct 350 ms 5692 KB Output is correct
48 Correct 78 ms 5632 KB Output is correct
49 Correct 71 ms 5632 KB Output is correct