답안 #379504

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
379504 2021-03-18T11:09:44 Z rocks03 기지국 (IOI20_stations) C++14
76 / 100
1010 ms 1292 KB
//#pragma GCC target("avx2")
//#pragma GCC optimization("O3")
//#pragma GCC optimization("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ff first
#define ss second
#define pb push_back
#define SZ(x) ((int)(x).size())
#define all(x) x.begin(), x.end()
#define debug(x) cout << #x << ": " << x << " "
#define nl cout << "\n"
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define per(i, a, b) for(int i = (a); i >= (b); i--)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int MAXN = 1e3+100;
vector<int> g[MAXN];

int timer, tin[MAXN], tou[MAXN];
void dfs(int v, int d, vector<int>& labels){
    tin[v] = timer++;
    for(int u : g[v]){
        g[u].erase(find(all(g[u]), v));
        dfs(u, d ^ 1, labels);
    }
    tou[v] = timer++;
    if(d & 1) labels[v] = tou[v];
    else labels[v] = tin[v];
}

vector<int> label(int N, int K, vector<int> u, vector<int> v){
    rep(i, 0, N){
        g[i].clear();
    }
    auto add_edge = [&](int a, int b){
        g[a].pb(b);
        g[b].pb(a);
    };
    rep(i, 0, N - 1){
        add_edge(u[i], v[i]);
    }
    vector<int> labels(N);
    timer = 0;
    dfs(0, 0, labels);
    return labels;
}

int find_next_station(int s, int t, vector<int> c){
    bool tin = true, tou = true;
    for(int x : c){
        tin &= (s < x);
        tou &= (s > x);
    }
    if(tin){
        sort(all(c));
        rep(i, 0, SZ(c) - 1){
            if(s <= t && t <= c[i]){
                return c[i];
            }
        }
        return c.back();
    } else if(tou){
        sort(all(c), greater<int>());
        rep(i, 0, SZ(c) - 1){
            if(c[i] <= t && t <= s){
                return c[i];
            }
        }
        return c.back();
    }
}

Compilation message

stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:75:1: warning: control reaches end of non-void function [-Wreturn-type]
   75 | }
      | ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 492 KB Invalid labels (values out of range). scenario=2, k=1000, vertex=1, label=1990
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 476 KB Invalid labels (values out of range). scenario=0, k=1000, vertex=1, label=1022
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 603 ms 992 KB Output is correct
2 Correct 601 ms 1004 KB Output is correct
3 Correct 911 ms 1064 KB Output is correct
4 Correct 639 ms 1108 KB Output is correct
5 Correct 606 ms 864 KB Output is correct
6 Correct 592 ms 1052 KB Output is correct
7 Correct 490 ms 864 KB Output is correct
8 Correct 3 ms 976 KB Output is correct
9 Correct 4 ms 864 KB Output is correct
10 Correct 2 ms 736 KB Output is correct
11 Correct 622 ms 992 KB Output is correct
12 Correct 573 ms 1292 KB Output is correct
13 Correct 514 ms 1060 KB Output is correct
14 Correct 496 ms 1012 KB Output is correct
15 Correct 67 ms 736 KB Output is correct
16 Correct 76 ms 864 KB Output is correct
17 Correct 140 ms 856 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 937 ms 1024 KB Output is correct
2 Correct 759 ms 736 KB Output is correct
3 Correct 644 ms 1024 KB Output is correct
4 Correct 3 ms 864 KB Output is correct
5 Correct 5 ms 736 KB Output is correct
6 Correct 2 ms 776 KB Output is correct
7 Correct 716 ms 992 KB Output is correct
8 Correct 982 ms 992 KB Output is correct
9 Correct 741 ms 992 KB Output is correct
10 Correct 679 ms 864 KB Output is correct
11 Correct 7 ms 736 KB Output is correct
12 Correct 7 ms 864 KB Output is correct
13 Correct 5 ms 736 KB Output is correct
14 Correct 4 ms 864 KB Output is correct
15 Correct 2 ms 944 KB Output is correct
16 Correct 550 ms 736 KB Output is correct
17 Correct 634 ms 936 KB Output is correct
18 Correct 580 ms 736 KB Output is correct
19 Correct 594 ms 936 KB Output is correct
20 Correct 576 ms 936 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 582 ms 864 KB Partially correct
2 Partially correct 553 ms 1056 KB Partially correct
3 Correct 1010 ms 1108 KB Output is correct
4 Correct 864 ms 936 KB Output is correct
5 Correct 685 ms 864 KB Output is correct
6 Partially correct 500 ms 1004 KB Partially correct
7 Partially correct 545 ms 864 KB Partially correct
8 Correct 3 ms 936 KB Output is correct
9 Correct 5 ms 736 KB Output is correct
10 Correct 2 ms 936 KB Output is correct
11 Partially correct 440 ms 848 KB Partially correct
12 Partially correct 608 ms 880 KB Partially correct
13 Correct 981 ms 1024 KB Output is correct
14 Correct 758 ms 948 KB Output is correct
15 Correct 592 ms 936 KB Output is correct
16 Partially correct 435 ms 816 KB Partially correct
17 Correct 598 ms 864 KB Output is correct
18 Partially correct 466 ms 992 KB Partially correct
19 Partially correct 556 ms 864 KB Partially correct
20 Partially correct 557 ms 884 KB Partially correct
21 Correct 56 ms 940 KB Output is correct
22 Partially correct 87 ms 864 KB Partially correct
23 Partially correct 113 ms 880 KB Partially correct
24 Correct 5 ms 864 KB Output is correct
25 Correct 8 ms 936 KB Output is correct
26 Correct 6 ms 736 KB Output is correct
27 Correct 4 ms 864 KB Output is correct
28 Correct 2 ms 864 KB Output is correct
29 Correct 521 ms 908 KB Output is correct
30 Correct 668 ms 864 KB Output is correct
31 Correct 554 ms 1064 KB Output is correct
32 Correct 488 ms 864 KB Output is correct
33 Correct 530 ms 1064 KB Output is correct
34 Partially correct 427 ms 1044 KB Partially correct
35 Partially correct 521 ms 1004 KB Partially correct
36 Partially correct 601 ms 1288 KB Partially correct
37 Partially correct 473 ms 1188 KB Partially correct
38 Partially correct 519 ms 1052 KB Partially correct
39 Partially correct 469 ms 1072 KB Partially correct
40 Partially correct 547 ms 1112 KB Partially correct
41 Partially correct 618 ms 1084 KB Partially correct
42 Partially correct 67 ms 1012 KB Partially correct
43 Partially correct 142 ms 872 KB Partially correct
44 Partially correct 151 ms 1128 KB Partially correct
45 Partially correct 196 ms 1088 KB Partially correct
46 Partially correct 388 ms 864 KB Partially correct
47 Partially correct 434 ms 1224 KB Partially correct
48 Partially correct 64 ms 1232 KB Partially correct
49 Partially correct 73 ms 864 KB Partially correct