Submission #979301

# Submission time Handle Problem Language Result Execution time Memory
979301 2024-05-10T14:04:35 Z Zicrus Stations (IOI20_stations) C++17
0 / 100
3000 ms 2097152 KB
#include <bits/stdc++.h>
#include "stations.h"
using namespace std;

vector<int> lbl;
vector<vector<int>> adj;

void DFS(int index, int last, int id)
{
    lbl[index] = id;
    for (auto node : adj[index])
    {
        if (node == last) continue;
        DFS(node, index, id + 1);
    }
}

vector<int> label(int N, int K, vector<int> U, vector<int> V)
{
    adj.resize(N);
    lbl.resize(N);

    for (int i = 0; i < N - 1; i++)
    {
        adj[U[i]].push_back(V[i]);
        adj[V[i]].push_back(U[i]);
    }

    for (int i = 0; i < N; i++)
    {
        if (adj[i].size() == 1)
        {
            DFS(i, -1, 0);
            break;
        }
    }
    return lbl;
}

int find_next_station(int S, int T, vector<int> C)
{
    if (T > S)
    {
        return S + 1;
    }

    return S - 1;
}
# Verdict Execution time Memory Grader output
1 Runtime error 2831 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3030 ms 792 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1370 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 582 ms 684 KB Output is correct
2 Incorrect 487 ms 684 KB Wrong query response.
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2195 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -