답안 #373961

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
373961 2021-03-06T09:51:37 Z Jarif_Rahman 기지국 (IOI20_stations) C++17
100 / 100
1079 ms 1092 KB
#include "stations.h"
#include <bits/stdc++.h>
#define pb push_back
#define f first
#define sc second
using namespace std;
typedef long long int ll;
typedef string str;
vector<vector<int>> v;
vector<int> lb, sz;
int in = 0;
void dfs(int nd, int ss, int d){
    if(d%2 == 0) lb[nd] = in++;
    for(int x: v[nd]) if(x != ss) dfs(x, nd, d+1);
    if(d%2 == 1) lb[nd] = in++;
}
vector<int> label(int n, int k, vector<int> aa, vector<int> bb){
    in = 0;
    v.assign(n, {});
    lb.assign(n, -1);
    for(int i = 0; i < n-1; i++){
        v[aa[i]].pb(bb[i]);
        v[bb[i]].pb(aa[i]);
    }
    dfs(0, -1, 0);
    return lb;
}
int find_next_station(int s, int t, vector<int> c){
    sort(c.begin(), c.end());
    if(s > c[0]){
        c.pb(s);
        for(int i = 1; i < (int)c.size() - 1; i++){
            if(t >= c[i] && t < c[i+1]) return c[i];
        }
        return c[0];
    }
    else{
        reverse(c.begin(), c.end());
        c.pb(s);
        for(int i = (s==0); i < (int)c.size()-1; i++){
            if(t <= c[i] && t > c[i+1]) return c[i];
        }
        return c[0];
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 623 ms 864 KB Output is correct
2 Correct 504 ms 920 KB Output is correct
3 Correct 1003 ms 736 KB Output is correct
4 Correct 981 ms 868 KB Output is correct
5 Correct 640 ms 756 KB Output is correct
6 Correct 456 ms 980 KB Output is correct
7 Correct 514 ms 884 KB Output is correct
8 Correct 3 ms 756 KB Output is correct
9 Correct 5 ms 756 KB Output is correct
10 Correct 2 ms 756 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 549 ms 884 KB Output is correct
2 Correct 710 ms 784 KB Output is correct
3 Correct 1031 ms 868 KB Output is correct
4 Correct 690 ms 736 KB Output is correct
5 Correct 736 ms 756 KB Output is correct
6 Correct 562 ms 736 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 606 ms 936 KB Output is correct
2 Correct 538 ms 1012 KB Output is correct
3 Correct 1079 ms 868 KB Output is correct
4 Correct 716 ms 868 KB Output is correct
5 Correct 661 ms 864 KB Output is correct
6 Correct 445 ms 864 KB Output is correct
7 Correct 546 ms 992 KB Output is correct
8 Correct 3 ms 868 KB Output is correct
9 Correct 5 ms 736 KB Output is correct
10 Correct 2 ms 736 KB Output is correct
11 Correct 686 ms 1060 KB Output is correct
12 Correct 598 ms 964 KB Output is correct
13 Correct 507 ms 1080 KB Output is correct
14 Correct 587 ms 792 KB Output is correct
15 Correct 68 ms 756 KB Output is correct
16 Correct 69 ms 820 KB Output is correct
17 Correct 119 ms 896 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 911 ms 736 KB Output is correct
2 Correct 735 ms 736 KB Output is correct
3 Correct 676 ms 736 KB Output is correct
4 Correct 3 ms 756 KB Output is correct
5 Correct 5 ms 908 KB Output is correct
6 Correct 2 ms 756 KB Output is correct
7 Correct 630 ms 756 KB Output is correct
8 Correct 1067 ms 736 KB Output is correct
9 Correct 788 ms 756 KB Output is correct
10 Correct 591 ms 884 KB Output is correct
11 Correct 7 ms 876 KB Output is correct
12 Correct 6 ms 756 KB Output is correct
13 Correct 5 ms 756 KB Output is correct
14 Correct 4 ms 756 KB Output is correct
15 Correct 2 ms 876 KB Output is correct
16 Correct 512 ms 736 KB Output is correct
17 Correct 660 ms 868 KB Output is correct
18 Correct 575 ms 756 KB Output is correct
19 Correct 546 ms 884 KB Output is correct
20 Correct 603 ms 756 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 649 ms 884 KB Output is correct
2 Correct 561 ms 864 KB Output is correct
3 Correct 970 ms 884 KB Output is correct
4 Correct 769 ms 868 KB Output is correct
5 Correct 704 ms 864 KB Output is correct
6 Correct 435 ms 884 KB Output is correct
7 Correct 540 ms 1008 KB Output is correct
8 Correct 3 ms 876 KB Output is correct
9 Correct 4 ms 868 KB Output is correct
10 Correct 1 ms 756 KB Output is correct
11 Correct 431 ms 864 KB Output is correct
12 Correct 582 ms 736 KB Output is correct
13 Correct 844 ms 868 KB Output is correct
14 Correct 677 ms 868 KB Output is correct
15 Correct 613 ms 996 KB Output is correct
16 Correct 407 ms 756 KB Output is correct
17 Correct 606 ms 756 KB Output is correct
18 Correct 544 ms 992 KB Output is correct
19 Correct 515 ms 992 KB Output is correct
20 Correct 444 ms 792 KB Output is correct
21 Correct 67 ms 860 KB Output is correct
22 Correct 89 ms 736 KB Output is correct
23 Correct 123 ms 756 KB Output is correct
24 Correct 4 ms 916 KB Output is correct
25 Correct 7 ms 756 KB Output is correct
26 Correct 5 ms 736 KB Output is correct
27 Correct 3 ms 756 KB Output is correct
28 Correct 2 ms 756 KB Output is correct
29 Correct 614 ms 736 KB Output is correct
30 Correct 592 ms 864 KB Output is correct
31 Correct 630 ms 868 KB Output is correct
32 Correct 567 ms 868 KB Output is correct
33 Correct 508 ms 1060 KB Output is correct
34 Correct 326 ms 1068 KB Output is correct
35 Correct 498 ms 996 KB Output is correct
36 Correct 506 ms 1056 KB Output is correct
37 Correct 554 ms 1092 KB Output is correct
38 Correct 522 ms 1092 KB Output is correct
39 Correct 488 ms 1080 KB Output is correct
40 Correct 538 ms 972 KB Output is correct
41 Correct 569 ms 1012 KB Output is correct
42 Correct 56 ms 796 KB Output is correct
43 Correct 106 ms 736 KB Output is correct
44 Correct 142 ms 764 KB Output is correct
45 Correct 165 ms 756 KB Output is correct
46 Correct 398 ms 792 KB Output is correct
47 Correct 390 ms 764 KB Output is correct
48 Correct 78 ms 864 KB Output is correct
49 Correct 63 ms 864 KB Output is correct