Submission #979307

# Submission time Handle Problem Language Result Execution time Memory
979307 2024-05-10T14:12:45 Z Zicrus Stations (IOI20_stations) C++17
5 / 100
572 ms 1172 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 = vector<vector<int>>(N);
    lbl = vector<int>(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 Correct 389 ms 924 KB Output is correct
2 Correct 288 ms 924 KB Output is correct
3 Correct 567 ms 684 KB Output is correct
4 Correct 443 ms 684 KB Output is correct
5 Correct 364 ms 684 KB Output is correct
6 Correct 310 ms 896 KB Output is correct
7 Correct 320 ms 944 KB Output is correct
8 Correct 1 ms 768 KB Output is correct
9 Correct 2 ms 768 KB Output is correct
10 Correct 0 ms 768 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 560 KB Invalid labels (duplicates values). scenario=0, label=10
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 391 ms 1072 KB Output is correct
2 Correct 287 ms 1172 KB Output is correct
3 Correct 572 ms 684 KB Output is correct
4 Correct 391 ms 684 KB Output is correct
5 Correct 371 ms 684 KB Output is correct
6 Correct 260 ms 896 KB Output is correct
7 Correct 277 ms 684 KB Output is correct
8 Correct 2 ms 764 KB Output is correct
9 Correct 2 ms 764 KB Output is correct
10 Correct 0 ms 768 KB Output is correct
11 Incorrect 1 ms 344 KB Invalid labels (duplicates values). scenario=1, label=2
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 526 ms 684 KB Output is correct
2 Correct 422 ms 684 KB Output is correct
3 Correct 444 ms 688 KB Output is correct
4 Correct 1 ms 768 KB Output is correct
5 Correct 2 ms 768 KB Output is correct
6 Correct 1 ms 768 KB Output is correct
7 Incorrect 0 ms 344 KB Invalid labels (duplicates values). scenario=0, label=2
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 322 ms 916 KB Output is correct
2 Correct 305 ms 924 KB Output is correct
3 Correct 561 ms 684 KB Output is correct
4 Correct 430 ms 684 KB Output is correct
5 Correct 397 ms 684 KB Output is correct
6 Correct 281 ms 896 KB Output is correct
7 Correct 277 ms 684 KB Output is correct
8 Correct 1 ms 764 KB Output is correct
9 Correct 3 ms 768 KB Output is correct
10 Correct 1 ms 768 KB Output is correct
11 Incorrect 3 ms 540 KB Invalid labels (duplicates values). scenario=0, label=10
12 Halted 0 ms 0 KB -