Submission #422036

# Submission time Handle Problem Language Result Execution time Memory
422036 2021-06-09T15:36:22 Z Monchito Stations (IOI20_stations) C++14
0 / 100
7 ms 488 KB
#include "stations.h"
#include <vector>
#include <iostream>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;

int find_leaf(int current_node, int current_node_father, vvi& G){
    vector<int> adjacents;
    for(int v : G[current_node]){
        if(v == current_node_father) continue;
        adjacents.push_back(v);
    }

    if((int)adjacents.size() == 0) return current_node;
    return find_leaf(adjacents[0], current_node, G);
}

void find_order(int& current_id, int current_node, int current_node_father, vvi& G, vi& labels){
    for(int v : G[current_node]){
        if(v == current_node_father) continue;
        labels[v] = current_id;
        current_id++;
        find_order(current_id, v, current_node, G, labels);
    }
}

vector<int> label(int n, int k, vector<int> u, vector<int> v) {
    vi labels(n);
    vvi G(n);
    int id=0, root = 0;

    for(int i=0; i<n-1; i++){
        G[u[i]].push_back(v[i]);
        G[v[i]].push_back(u[i]);
    }

    find_order(id, find_leaf(root, -1, G), -1, G, labels);
    return labels;
}

int find_next_station(int s, int t, vector<int> c) {
    if((int)c.size() == 1) return c[0];
    if(s > t) return c[0];
    return c[1];
}
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 456 KB Invalid labels (duplicates values). scenario=0, label=0
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 284 KB Invalid labels (duplicates values). scenario=0, label=0
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 488 KB Invalid labels (duplicates values). scenario=0, label=0
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 200 KB Invalid labels (duplicates values). scenario=0, label=0
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 404 KB Invalid labels (duplicates values). scenario=0, label=0
2 Halted 0 ms 0 KB -