답안 #306864

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
306864 2020-09-26T11:45:55 Z VEGAnn 기지국 (IOI20_stations) C++14
73.3608 / 100
951 ms 1280 KB
#include "stations.h"
#include <bits/stdc++.h>
#define PB push_back
#define sz(x) ((int)x.size())
#define all(x) x.begin(),x.end()
using namespace std;
vector<int> g[1000];
int tin[1000], tout[1000], tt = 0, ht[1000];

void dfs(int v, int p, bool tp){
    tin[v] = tt++;
    ht[v] = tp;

    for (int u : g[v]){
        if (u == p) continue;
        dfs(u, v, tp ^ 1);
    }

    tout[v] = tt++;
}

std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
    for (int i = 0; i < n; i++)
        g[i].clear();

    tt = 0;

    for (int i = 0; i < sz(u); i++){
        g[u[i]].PB(v[i]);
        g[v[i]].PB(u[i]);
    }

    dfs(0, -1, 0);

    vector<int> labels;

    labels.resize(n);

    for (int i = 0; i < n; i++) {
        if (ht[i] == 0)
            labels[i] = tin[i];
        else labels[i] = tout[i] + 2000;
    }

	return labels;
}

int find_next_station(int s, int t, std::vector<int> c) {
    int N = 2000;

    int ss = s;

    if (s >= N) ss -= N;

    int tt = t;

    if (t >= N) tt -= N;

    if (s < N){
        if (ss > tt) return c.back();

        int siz = sz(c);

        int lst = c.back() - N;

        if (s > 0) {
            if (sz(c) > 1)
                lst = c[siz - 2] - N;
            else lst = -1;
        }

        if (tt <= lst){
            for (int v : c)
                if (tt <= v - N)
                    return v;
        } else return c.back();
    } else {
        if (ss < tt) return c[0];

        if (sz(c) > 1 && tt >= c[1]){
            reverse(all(c));

            for (int v : c)
                if (tt >= v)
                    return v;
        } else return c[0];
    }
}

Compilation message

stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:88:1: warning: control reaches end of non-void function [-Wreturn-type]
   88 | }
      | ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 512 KB Invalid labels (values out of range). scenario=0, k=1000, vertex=1, label=2014
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 504 KB Invalid labels (values out of range). scenario=0, k=1000, vertex=1, label=3022
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 526 ms 1280 KB Output is correct
2 Correct 451 ms 1024 KB Output is correct
3 Correct 862 ms 768 KB Output is correct
4 Correct 642 ms 872 KB Output is correct
5 Correct 594 ms 868 KB Output is correct
6 Correct 457 ms 1024 KB Output is correct
7 Correct 467 ms 768 KB Output is correct
8 Correct 3 ms 876 KB Output is correct
9 Correct 4 ms 876 KB Output is correct
10 Correct 1 ms 868 KB Output is correct
11 Correct 574 ms 868 KB Output is correct
12 Correct 454 ms 1024 KB Output is correct
13 Correct 493 ms 1024 KB Output is correct
14 Correct 492 ms 768 KB Output is correct
15 Correct 59 ms 768 KB Output is correct
16 Correct 70 ms 1120 KB Output is correct
17 Correct 118 ms 768 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 927 ms 1008 KB Output is correct
2 Correct 664 ms 1024 KB Output is correct
3 Correct 603 ms 768 KB Output is correct
4 Correct 3 ms 884 KB Output is correct
5 Correct 5 ms 768 KB Output is correct
6 Correct 2 ms 1024 KB Output is correct
7 Correct 589 ms 864 KB Output is correct
8 Correct 864 ms 768 KB Output is correct
9 Correct 678 ms 768 KB Output is correct
10 Correct 564 ms 868 KB Output is correct
11 Correct 5 ms 872 KB Output is correct
12 Correct 5 ms 768 KB Output is correct
13 Correct 4 ms 768 KB Output is correct
14 Correct 3 ms 768 KB Output is correct
15 Correct 2 ms 868 KB Output is correct
16 Correct 639 ms 1040 KB Output is correct
17 Correct 527 ms 864 KB Output is correct
18 Correct 512 ms 872 KB Output is correct
19 Correct 482 ms 1024 KB Output is correct
20 Correct 489 ms 1040 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 599 ms 1008 KB Partially correct
2 Partially correct 473 ms 1024 KB Partially correct
3 Partially correct 951 ms 768 KB Partially correct
4 Partially correct 639 ms 864 KB Partially correct
5 Partially correct 693 ms 896 KB Partially correct
6 Partially correct 441 ms 1016 KB Partially correct
7 Partially correct 458 ms 916 KB Partially correct
8 Partially correct 2 ms 876 KB Partially correct
9 Partially correct 5 ms 768 KB Partially correct
10 Partially correct 2 ms 1024 KB Partially correct
11 Partially correct 553 ms 816 KB Partially correct
12 Partially correct 592 ms 820 KB Partially correct
13 Partially correct 950 ms 868 KB Partially correct
14 Partially correct 719 ms 992 KB Partially correct
15 Partially correct 637 ms 768 KB Partially correct
16 Partially correct 453 ms 768 KB Partially correct
17 Partially correct 612 ms 876 KB Partially correct
18 Partially correct 482 ms 768 KB Partially correct
19 Partially correct 642 ms 1208 KB Partially correct
20 Partially correct 561 ms 768 KB Partially correct
21 Partially correct 60 ms 856 KB Partially correct
22 Partially correct 75 ms 768 KB Partially correct
23 Partially correct 101 ms 800 KB Partially correct
24 Partially correct 5 ms 996 KB Partially correct
25 Partially correct 7 ms 880 KB Partially correct
26 Partially correct 5 ms 876 KB Partially correct
27 Partially correct 2 ms 768 KB Partially correct
28 Partially correct 1 ms 872 KB Partially correct
29 Partially correct 588 ms 880 KB Partially correct
30 Partially correct 553 ms 1040 KB Partially correct
31 Partially correct 545 ms 868 KB Partially correct
32 Partially correct 520 ms 880 KB Partially correct
33 Partially correct 544 ms 872 KB Partially correct
34 Partially correct 348 ms 1000 KB Partially correct
35 Partially correct 450 ms 1024 KB Partially correct
36 Partially correct 449 ms 1116 KB Partially correct
37 Partially correct 453 ms 1016 KB Partially correct
38 Partially correct 468 ms 776 KB Partially correct
39 Partially correct 447 ms 772 KB Partially correct
40 Partially correct 464 ms 780 KB Partially correct
41 Partially correct 452 ms 784 KB Partially correct
42 Partially correct 61 ms 828 KB Partially correct
43 Partially correct 100 ms 804 KB Partially correct
44 Partially correct 137 ms 776 KB Partially correct
45 Partially correct 165 ms 768 KB Partially correct
46 Partially correct 323 ms 828 KB Partially correct
47 Partially correct 346 ms 784 KB Partially correct
48 Partially correct 68 ms 984 KB Partially correct
49 Partially correct 66 ms 1016 KB Partially correct