Submission #306855

# Submission time Handle Problem Language Result Execution time Memory
306855 2020-09-26T11:17:26 Z VEGAnn Stations (IOI20_stations) C++14
0 / 100
857 ms 768 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 - 1;
}

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] + 1000;
    }

	return labels;
}

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

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

        int siz = sz(c);

        if (t <= c[siz - 2]){
            for (int v : c)
                if (t <= v)
                    return v;
        } else return c.back();
    } else {
        if (s < t) return c[0];

        if (t >= c[1]){
            reverse(all(c));

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

Compilation message

stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:72:1: warning: control reaches end of non-void function [-Wreturn-type]
   72 | }
      | ^
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 500 KB Invalid labels (values out of range). scenario=0, k=1000, vertex=1, label=1009
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 384 KB Invalid labels (values out of range). scenario=0, k=1000, vertex=1, label=1511
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 512 KB Invalid labels (duplicates values). scenario=1, label=1863
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 857 ms 768 KB Output is correct
2 Correct 661 ms 768 KB Output is correct
3 Incorrect 1 ms 384 KB Invalid labels (duplicates values). scenario=1, label=1003
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 508 KB Invalid labels (duplicates values). scenario=1, label=1997
2 Halted 0 ms 0 KB -