Submission #1072869

# Submission time Handle Problem Language Result Execution time Memory
1072869 2024-08-24T06:08:15 Z Ignut Stations (IOI20_stations) C++17
0 / 100
607 ms 684 KB
// Ignut

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

const int N = 1111;

vector<int> tree[N];

vector<int> euler;

int root;

void dfs(int v, int par) {
    euler.push_back(v);
    for (int to : tree[v]) {
        if (to != par) {
            dfs(to, v);
            if (v == root)
                euler.push_back(v);
        }
    }
}

vector<int> label(int n, int k, vector<int> u, vector<int> v) {
    euler.clear();
    for (int i = 0; i < n; i ++) {
        tree[i].clear();
    }

    for (int i = 0; i < n - 1; i ++) {
        tree[u[i]].push_back(v[i]);
        tree[v[i]].push_back(u[i]);
    }
    root = 0;
    for (int i = 0; i < n; i ++)
        if (tree[i].size() > 2)
            root = i;
    dfs(root, -1);

    vector<int> lbl(n);
    lbl[root] = 0;
    int number = 1;
    for (int v : euler) {
        if (v == root) {
            number = number / 1000 * 1000;
            number ++;
            continue;
        }
        lbl[v] = number ++;
    }
    return lbl;
}



int find_next_station(int s, int t, vector<int> c) {
    if (c.size() > 2) {
        for (int v : c) {
            if (v / 1000 == t / 1000)
                return v;
        }
        return t;
    }
    if (c.size() == 1)
        return c[0];

    int mn = min(c[0], c[1]);
    int mx = max(c[0], c[1]);

    if (mx / 1000 == s / 1000)
        return mn;
    
    return mx;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Invalid labels (duplicates values). scenario=0, label=1
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 600 KB Invalid labels (duplicates values). scenario=0, label=1
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 344 KB Invalid labels (duplicates values). scenario=1, label=22
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 607 ms 684 KB Output is correct
2 Incorrect 0 ms 344 KB Invalid labels (duplicates values). scenario=1, label=1
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 344 KB Invalid labels (duplicates values). scenario=1, label=182
2 Halted 0 ms 0 KB -