답안 #309360

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
309360 2020-10-03T10:01:42 Z xt0r3 기지국 (IOI20_stations) C++14
100 / 100
1188 ms 1104 KB
#include<bits/stdc++.h>
using namespace std;

int timer;
vector<bool> f;
vector<int> l, d;
vector<vector<int> > g;

void dfs(int id, bool flag = 1){
    d[id] = timer++;
    f[id] = flag;
    for(int v : g[id]) if(d[v] == -1) dfs(v, !flag);
    l[id] = timer++;
}

vector<int> label(int n, int k, vector<int> u, vector<int> v){
    f.resize(n);
    l.assign(n, -1);
    d.assign(n, -1);
    g.assign(n, {});
    for(int i = 0; i < n - 1; i++){
        g[u[i]].push_back(v[i]);
        g[v[i]].push_back(u[i]);
    }
    timer = 0;
    dfs(0);
    vector<int> ret(n);
    for(int i = 0; i < n; i++){
        ret[i] = (f[i] ? d[i] / 2 : l[i] / 2);
    }
    return ret;
}

int find_next_station(int s, int t, vector<int> c){
    if(s < c[0]){
        //c has leaving times
        if(t < s || t > c.back()) return c.back();
        return c[(int)(lower_bound(c.begin(), c.end(), t) - c.begin())];
    }
    else{
        //c has discovery times
        if(t < c.front() || t > s) return c.front();
        return c[(int)(upper_bound(c.begin(), c.end(), t) - c.begin()) - 1];
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 564 ms 776 KB Output is correct
2 Correct 482 ms 1024 KB Output is correct
3 Correct 1188 ms 648 KB Output is correct
4 Correct 846 ms 648 KB Output is correct
5 Correct 628 ms 644 KB Output is correct
6 Correct 612 ms 768 KB Output is correct
7 Correct 556 ms 796 KB Output is correct
8 Correct 3 ms 648 KB Output is correct
9 Correct 5 ms 640 KB Output is correct
10 Correct 2 ms 640 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 474 ms 1024 KB Output is correct
2 Correct 536 ms 816 KB Output is correct
3 Correct 841 ms 640 KB Output is correct
4 Correct 660 ms 756 KB Output is correct
5 Correct 668 ms 640 KB Output is correct
6 Correct 515 ms 768 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 482 ms 1024 KB Output is correct
2 Correct 489 ms 992 KB Output is correct
3 Correct 973 ms 644 KB Output is correct
4 Correct 788 ms 640 KB Output is correct
5 Correct 645 ms 760 KB Output is correct
6 Correct 472 ms 984 KB Output is correct
7 Correct 644 ms 760 KB Output is correct
8 Correct 3 ms 640 KB Output is correct
9 Correct 5 ms 752 KB Output is correct
10 Correct 1 ms 640 KB Output is correct
11 Correct 559 ms 640 KB Output is correct
12 Correct 485 ms 1024 KB Output is correct
13 Correct 508 ms 992 KB Output is correct
14 Correct 443 ms 784 KB Output is correct
15 Correct 60 ms 768 KB Output is correct
16 Correct 75 ms 768 KB Output is correct
17 Correct 106 ms 768 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 908 ms 748 KB Output is correct
2 Correct 709 ms 644 KB Output is correct
3 Correct 589 ms 640 KB Output is correct
4 Correct 3 ms 652 KB Output is correct
5 Correct 4 ms 644 KB Output is correct
6 Correct 1 ms 640 KB Output is correct
7 Correct 651 ms 768 KB Output is correct
8 Correct 977 ms 640 KB Output is correct
9 Correct 668 ms 640 KB Output is correct
10 Correct 576 ms 640 KB Output is correct
11 Correct 6 ms 644 KB Output is correct
12 Correct 6 ms 640 KB Output is correct
13 Correct 5 ms 644 KB Output is correct
14 Correct 4 ms 640 KB Output is correct
15 Correct 1 ms 652 KB Output is correct
16 Correct 530 ms 640 KB Output is correct
17 Correct 551 ms 644 KB Output is correct
18 Correct 504 ms 648 KB Output is correct
19 Correct 519 ms 640 KB Output is correct
20 Correct 574 ms 648 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 617 ms 1024 KB Output is correct
2 Correct 481 ms 1024 KB Output is correct
3 Correct 888 ms 640 KB Output is correct
4 Correct 656 ms 652 KB Output is correct
5 Correct 700 ms 644 KB Output is correct
6 Correct 527 ms 760 KB Output is correct
7 Correct 550 ms 800 KB Output is correct
8 Correct 3 ms 640 KB Output is correct
9 Correct 5 ms 640 KB Output is correct
10 Correct 2 ms 648 KB Output is correct
11 Correct 476 ms 768 KB Output is correct
12 Correct 551 ms 816 KB Output is correct
13 Correct 839 ms 648 KB Output is correct
14 Correct 644 ms 648 KB Output is correct
15 Correct 733 ms 640 KB Output is correct
16 Correct 448 ms 756 KB Output is correct
17 Correct 675 ms 648 KB Output is correct
18 Correct 539 ms 904 KB Output is correct
19 Correct 551 ms 868 KB Output is correct
20 Correct 566 ms 1024 KB Output is correct
21 Correct 84 ms 644 KB Output is correct
22 Correct 99 ms 856 KB Output is correct
23 Correct 112 ms 928 KB Output is correct
24 Correct 5 ms 640 KB Output is correct
25 Correct 6 ms 640 KB Output is correct
26 Correct 6 ms 640 KB Output is correct
27 Correct 5 ms 640 KB Output is correct
28 Correct 3 ms 776 KB Output is correct
29 Correct 580 ms 644 KB Output is correct
30 Correct 601 ms 640 KB Output is correct
31 Correct 591 ms 640 KB Output is correct
32 Correct 589 ms 648 KB Output is correct
33 Correct 501 ms 644 KB Output is correct
34 Correct 323 ms 1024 KB Output is correct
35 Correct 510 ms 1012 KB Output is correct
36 Correct 531 ms 1104 KB Output is correct
37 Correct 483 ms 1024 KB Output is correct
38 Correct 461 ms 1024 KB Output is correct
39 Correct 475 ms 1024 KB Output is correct
40 Correct 433 ms 1024 KB Output is correct
41 Correct 440 ms 788 KB Output is correct
42 Correct 60 ms 768 KB Output is correct
43 Correct 116 ms 808 KB Output is correct
44 Correct 144 ms 768 KB Output is correct
45 Correct 168 ms 1024 KB Output is correct
46 Correct 336 ms 968 KB Output is correct
47 Correct 301 ms 744 KB Output is correct
48 Correct 64 ms 780 KB Output is correct
49 Correct 71 ms 1024 KB Output is correct