Submission #391532

# Submission time Handle Problem Language Result Execution time Memory
391532 2021-04-19T08:55:47 Z ljuba Stations (IOI20_stations) C++17
0 / 100
951 ms 672 KB
#include "stations.h"
#include <vector>
#include <bits/stdc++.h>

using namespace std; 

const int mxN = 1100;
vector<int> adj[mxN];

std::vector<int> labels;
int timer = 0;

void dfs(int s, int p, int pa) {
    if(pa^1)
        labels[s] = timer++;
    for(auto e : adj[s]) {
        if(e == p) continue;
        dfs(e, s, pa^1);
    }
    if(pa)
        labels[s] = timer++;
}

std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
    for(int i = 0; i < n; ++i) {
        adj[i].clear();
    }
    for(int i = 0; i < n-1; ++i) {
        adj[u[i]].push_back(v[i]);
        adj[v[i]].push_back(u[i]);
    }
    labels.resize(n);
    dfs(0, -1, 0);
    return labels;
}

int find_next_station(int s, int t, std::vector<int> c) {
    sort(c.begin(), c.end());
    if(s < c[0]) {
        //in ostali out
        for(auto e : c) {
            if(e >= s && e <= t)
                return e;
        }

        return c.back();
    } else {
        reverse(c.begin(), c.end());
        for(auto e : c) {
            if(e <= s && e >= t)
                return e;
        }
        return c[0];
    }
}
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 456 KB Invalid labels (values out of range). scenario=2, k=1000, vertex=1, label=1008
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 312 KB Invalid labels (values out of range). scenario=1, k=1000, vertex=1, label=1507
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 697 ms 656 KB Wrong query response.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 951 ms 400 KB Output is correct
2 Incorrect 742 ms 400 KB Wrong query response.
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 546 ms 672 KB Wrong query response.
2 Halted 0 ms 0 KB -