Submission #308264

# Submission time Handle Problem Language Result Execution time Memory
308264 2020-09-30T16:37:46 Z Peti Stations (IOI20_stations) C++14
0 / 100
5 ms 508 KB
#include "stations.h"
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

vector<vector<int>> g;
vector<bool> volt;

int ido = 0;
void Bejar(vector<int> &labels, int akt, int t)
{
    volt[akt] = true;

    if(t%2 == 0)
        labels[akt] = ido;
    ido++;

    for(int x : g[akt])
        if(!volt[x])
            Bejar(labels, x, t+1);

    if(t%2 == 1)
        labels[akt] = ido;
    ido++;
    return;
}

std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {

    g.resize(n);
    volt.resize(n, false);
    for(int i = 0; i < n-1; i++)
    {
        g[u[i]].push_back(v[i]);
        g[v[i]].push_back(u[i]);
    }

	std::vector<int> labels(n);
	for(int i = 0; i < n; i++)
        if(!volt[i])
            Bejar(labels, i, 0);

	return labels;
}

int find_next_station(int s, int t, std::vector<int> c) {

    sort(c.begin(), c.end());

    if(s < c[0])
    {
        if(t < s || t > (*c.rbegin()))
            return (*c.rbegin());
        for(int x : c)
            if(x >= t)
                return x;
    }
    else
    {
        if(t > s || t <= c[0])
            return c[0];
        reverse(c.begin(), c.end());
        for(int x : c)
            if(x <= t)
                return x;
    }

	return -1;
}
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 488 KB Invalid labels (duplicates values). scenario=1, label=0
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 508 KB Invalid labels (values out of range). scenario=0, k=1000, vertex=1, label=1022
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 504 KB Invalid labels (duplicates values). scenario=1, label=0
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 256 KB Invalid labels (duplicates values). scenario=1, label=0
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 508 KB Invalid labels (duplicates values). scenario=1, label=0
2 Halted 0 ms 0 KB -