답안 #391033

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
391033 2021-04-17T15:27:12 Z qwerasdfzxcl 기지국 (IOI20_stations) C++14
100 / 100
1138 ms 784 KB
#include "stations.h"
#include <bits/stdc++.h>

typedef long long ll;
using namespace std;
vector<int> adj[1010], ans;
bool visited[1010];
int cur=0;

void dfs(int s, int dep){
    if (!(dep&1)) ans[s] = cur++;
    visited[s] = 1;
    for (auto &v:adj[s]) if (!visited[v]){
        dfs(v, dep+1);
    }
    if (dep&1) ans[s] = cur++;
}

vector<int> label(int n, int k, vector<int> u, vector<int> v) {
    for (int i=0;i<n;i++){
        adj[i].clear(); visited[i] = 0;
    }
    ans.clear();
    ans.resize(n);
    cur = 0;
    for (int i=0;i<n-1;i++){
        adj[u[i]].push_back(v[i]);
        adj[v[i]].push_back(u[i]);
    }
    dfs(0, 0);
    //for (int i=0;i<n;i++) printf("%d ", ans[i]);
    //printf("\n");
    return ans;
}

int find_next_station(int s, int t, vector<int> c) {
    int l, r;
    if (!s) l = 0, r = c.back();
    else if (c[0]<s){
        r = s;
        if ((int)c.size()<2) l = s;
        else l = c[1];
    }
    else{
        l = s;
        if ((int)c.size()<2) r = s;
        else r = c[c.size()-2];
    }
    if (l<=t && t<=r){
        if (c[0]<s){
            auto iter = upper_bound(c.begin(), c.end(), t);
            return *(--iter);
        }
        else{
            auto iter = lower_bound(c.begin(), c.end(), t);
            return *iter;
        }
    }
    else{
        if (c[0]<s) return c[0];
        else return c.back();
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 516 ms 516 KB Output is correct
2 Correct 467 ms 636 KB Output is correct
3 Correct 1130 ms 400 KB Output is correct
4 Correct 670 ms 512 KB Output is correct
5 Correct 610 ms 524 KB Output is correct
6 Correct 553 ms 528 KB Output is correct
7 Correct 530 ms 520 KB Output is correct
8 Correct 3 ms 452 KB Output is correct
9 Correct 5 ms 480 KB Output is correct
10 Correct 2 ms 480 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 429 ms 512 KB Output is correct
2 Correct 568 ms 532 KB Output is correct
3 Correct 1059 ms 520 KB Output is correct
4 Correct 877 ms 496 KB Output is correct
5 Correct 710 ms 400 KB Output is correct
6 Correct 533 ms 520 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 683 ms 528 KB Output is correct
2 Correct 513 ms 640 KB Output is correct
3 Correct 1057 ms 400 KB Output is correct
4 Correct 730 ms 400 KB Output is correct
5 Correct 760 ms 400 KB Output is correct
6 Correct 530 ms 624 KB Output is correct
7 Correct 567 ms 516 KB Output is correct
8 Correct 3 ms 472 KB Output is correct
9 Correct 6 ms 484 KB Output is correct
10 Correct 2 ms 468 KB Output is correct
11 Correct 729 ms 400 KB Output is correct
12 Correct 434 ms 756 KB Output is correct
13 Correct 545 ms 760 KB Output is correct
14 Correct 519 ms 512 KB Output is correct
15 Correct 83 ms 580 KB Output is correct
16 Correct 84 ms 560 KB Output is correct
17 Correct 120 ms 784 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1057 ms 400 KB Output is correct
2 Correct 806 ms 512 KB Output is correct
3 Correct 761 ms 400 KB Output is correct
4 Correct 3 ms 472 KB Output is correct
5 Correct 6 ms 480 KB Output is correct
6 Correct 2 ms 468 KB Output is correct
7 Correct 660 ms 516 KB Output is correct
8 Correct 929 ms 400 KB Output is correct
9 Correct 656 ms 400 KB Output is correct
10 Correct 661 ms 652 KB Output is correct
11 Correct 7 ms 480 KB Output is correct
12 Correct 4 ms 472 KB Output is correct
13 Correct 5 ms 480 KB Output is correct
14 Correct 3 ms 472 KB Output is correct
15 Correct 2 ms 472 KB Output is correct
16 Correct 490 ms 516 KB Output is correct
17 Correct 572 ms 400 KB Output is correct
18 Correct 626 ms 400 KB Output is correct
19 Correct 624 ms 400 KB Output is correct
20 Correct 500 ms 400 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 601 ms 640 KB Output is correct
2 Correct 475 ms 512 KB Output is correct
3 Correct 991 ms 400 KB Output is correct
4 Correct 919 ms 404 KB Output is correct
5 Correct 559 ms 400 KB Output is correct
6 Correct 546 ms 516 KB Output is correct
7 Correct 501 ms 640 KB Output is correct
8 Correct 3 ms 480 KB Output is correct
9 Correct 5 ms 472 KB Output is correct
10 Correct 2 ms 484 KB Output is correct
11 Correct 587 ms 512 KB Output is correct
12 Correct 630 ms 528 KB Output is correct
13 Correct 1138 ms 400 KB Output is correct
14 Correct 730 ms 404 KB Output is correct
15 Correct 589 ms 512 KB Output is correct
16 Correct 580 ms 520 KB Output is correct
17 Correct 834 ms 404 KB Output is correct
18 Correct 461 ms 640 KB Output is correct
19 Correct 595 ms 492 KB Output is correct
20 Correct 515 ms 536 KB Output is correct
21 Correct 79 ms 596 KB Output is correct
22 Correct 90 ms 532 KB Output is correct
23 Correct 143 ms 656 KB Output is correct
24 Correct 7 ms 600 KB Output is correct
25 Correct 8 ms 468 KB Output is correct
26 Correct 5 ms 600 KB Output is correct
27 Correct 4 ms 476 KB Output is correct
28 Correct 2 ms 472 KB Output is correct
29 Correct 616 ms 400 KB Output is correct
30 Correct 469 ms 516 KB Output is correct
31 Correct 594 ms 512 KB Output is correct
32 Correct 647 ms 512 KB Output is correct
33 Correct 723 ms 528 KB Output is correct
34 Correct 342 ms 528 KB Output is correct
35 Correct 568 ms 632 KB Output is correct
36 Correct 577 ms 548 KB Output is correct
37 Correct 527 ms 616 KB Output is correct
38 Correct 550 ms 512 KB Output is correct
39 Correct 452 ms 528 KB Output is correct
40 Correct 563 ms 768 KB Output is correct
41 Correct 557 ms 528 KB Output is correct
42 Correct 82 ms 596 KB Output is correct
43 Correct 113 ms 532 KB Output is correct
44 Correct 167 ms 528 KB Output is correct
45 Correct 212 ms 528 KB Output is correct
46 Correct 363 ms 544 KB Output is correct
47 Correct 343 ms 532 KB Output is correct
48 Correct 63 ms 708 KB Output is correct
49 Correct 55 ms 700 KB Output is correct