답안 #448257

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
448257 2021-07-29T12:43:06 Z JovanB 기지국 (IOI20_stations) C++17
100 / 100
1130 ms 5600 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 548 ms 5400 KB Output is correct
2 Correct 537 ms 5412 KB Output is correct
3 Correct 973 ms 5276 KB Output is correct
4 Correct 776 ms 5392 KB Output is correct
5 Correct 721 ms 5264 KB Output is correct
6 Correct 519 ms 5396 KB Output is correct
7 Correct 501 ms 5392 KB Output is correct
8 Correct 5 ms 5348 KB Output is correct
9 Correct 6 ms 5344 KB Output is correct
10 Correct 4 ms 5336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 447 ms 5512 KB Output is correct
2 Correct 595 ms 5392 KB Output is correct
3 Correct 1048 ms 5268 KB Output is correct
4 Correct 703 ms 5276 KB Output is correct
5 Correct 698 ms 5264 KB Output is correct
6 Correct 479 ms 5392 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 641 ms 5600 KB Output is correct
2 Correct 513 ms 5384 KB Output is correct
3 Correct 1059 ms 5264 KB Output is correct
4 Correct 694 ms 5276 KB Output is correct
5 Correct 665 ms 5264 KB Output is correct
6 Correct 602 ms 5396 KB Output is correct
7 Correct 588 ms 5520 KB Output is correct
8 Correct 5 ms 5340 KB Output is correct
9 Correct 6 ms 5340 KB Output is correct
10 Correct 4 ms 5340 KB Output is correct
11 Correct 745 ms 5280 KB Output is correct
12 Correct 550 ms 5536 KB Output is correct
13 Correct 598 ms 5392 KB Output is correct
14 Correct 501 ms 5280 KB Output is correct
15 Correct 57 ms 5340 KB Output is correct
16 Correct 64 ms 5264 KB Output is correct
17 Correct 135 ms 5392 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 997 ms 5320 KB Output is correct
2 Correct 752 ms 5284 KB Output is correct
3 Correct 706 ms 5264 KB Output is correct
4 Correct 5 ms 5340 KB Output is correct
5 Correct 6 ms 5340 KB Output is correct
6 Correct 4 ms 5352 KB Output is correct
7 Correct 732 ms 5264 KB Output is correct
8 Correct 1100 ms 5264 KB Output is correct
9 Correct 724 ms 5264 KB Output is correct
10 Correct 669 ms 5264 KB Output is correct
11 Correct 8 ms 5340 KB Output is correct
12 Correct 7 ms 5340 KB Output is correct
13 Correct 7 ms 5340 KB Output is correct
14 Correct 6 ms 5340 KB Output is correct
15 Correct 4 ms 5340 KB Output is correct
16 Correct 652 ms 5264 KB Output is correct
17 Correct 562 ms 5280 KB Output is correct
18 Correct 603 ms 5264 KB Output is correct
19 Correct 693 ms 5292 KB Output is correct
20 Correct 634 ms 5280 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 622 ms 5384 KB Output is correct
2 Correct 501 ms 5384 KB Output is correct
3 Correct 1130 ms 5264 KB Output is correct
4 Correct 793 ms 5276 KB Output is correct
5 Correct 665 ms 5280 KB Output is correct
6 Correct 516 ms 5392 KB Output is correct
7 Correct 468 ms 5412 KB Output is correct
8 Correct 5 ms 5340 KB Output is correct
9 Correct 7 ms 5348 KB Output is correct
10 Correct 4 ms 5340 KB Output is correct
11 Correct 495 ms 5388 KB Output is correct
12 Correct 643 ms 5424 KB Output is correct
13 Correct 1000 ms 5264 KB Output is correct
14 Correct 772 ms 5264 KB Output is correct
15 Correct 705 ms 5264 KB Output is correct
16 Correct 576 ms 5384 KB Output is correct
17 Correct 704 ms 5284 KB Output is correct
18 Correct 439 ms 5508 KB Output is correct
19 Correct 531 ms 5568 KB Output is correct
20 Correct 558 ms 5268 KB Output is correct
21 Correct 75 ms 5288 KB Output is correct
22 Correct 91 ms 5272 KB Output is correct
23 Correct 131 ms 5520 KB Output is correct
24 Correct 9 ms 5348 KB Output is correct
25 Correct 9 ms 5336 KB Output is correct
26 Correct 7 ms 5336 KB Output is correct
27 Correct 7 ms 5336 KB Output is correct
28 Correct 4 ms 5340 KB Output is correct
29 Correct 548 ms 5280 KB Output is correct
30 Correct 620 ms 5264 KB Output is correct
31 Correct 568 ms 5264 KB Output is correct
32 Correct 510 ms 5392 KB Output is correct
33 Correct 612 ms 5264 KB Output is correct
34 Correct 359 ms 5436 KB Output is correct
35 Correct 447 ms 5588 KB Output is correct
36 Correct 533 ms 5392 KB Output is correct
37 Correct 533 ms 5392 KB Output is correct
38 Correct 522 ms 5524 KB Output is correct
39 Correct 492 ms 5508 KB Output is correct
40 Correct 416 ms 5396 KB Output is correct
41 Correct 527 ms 5412 KB Output is correct
42 Correct 84 ms 5264 KB Output is correct
43 Correct 110 ms 5416 KB Output is correct
44 Correct 178 ms 5392 KB Output is correct
45 Correct 170 ms 5392 KB Output is correct
46 Correct 367 ms 5408 KB Output is correct
47 Correct 282 ms 5392 KB Output is correct
48 Correct 57 ms 5468 KB Output is correct
49 Correct 55 ms 5404 KB Output is correct