Submission #432786

# Submission time Handle Problem Language Result Execution time Memory
432786 2021-06-18T13:21:52 Z Rouge_Hugo Stations (IOI20_stations) C++14
0 / 100
902 ms 528 KB
#include<bits/stdc++.h>
#include "stations.h"
#define ll long long
#define fi first
#define se second
#define pb push_back
using namespace std;
const int N=1009;
int la[N];
vector<int>v[N];int re=0;
void dfs(int x,int p)
{
    la[x]=++re;
    for(auto it:v[x])
    {
        if(it==p)continue;
        dfs(it,x);
    }
}
vector<int> label(int n, int k,vector<int> U, vector<int> V) {
	vector<int> l(n);
	for(int  i=0;i<n-1;i++)
    {
        v[U[i]].pb(V[i]);
        v[V[i]].pb(U[i]);
    }
    int root=0;
    for(int i=0;i<n;i++)if(v[i].size()==1)root=i;
    l[root]=0;int r=-1;
    dfs(root,0);
    for(int i=0;i<n;i++)l[i]=la[i];
    memset(la,0,sizeof la);for(int i=0;i<n;i++)v[i].clear();
    return l;
}

int find_next_station(int s, int t, std::vector<int> c) {
	if(s<t)
    {
        return c[1];
    }
    return c[0];
}
/*
1
5 1000000
0 1
1 2
1 3
2 4
2
2 0 1
1 3 3
*/

Compilation message

stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:29:19: warning: unused variable 'r' [-Wunused-variable]
   29 |     l[root]=0;int r=-1;
      |                   ^
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 316 KB Invalid labels (duplicates values). scenario=0, label=0
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 364 KB Invalid labels (values out of range). scenario=1, k=1000, vertex=0, label=1006
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 551 ms 508 KB Wrong query response.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 902 ms 492 KB Wrong query response.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 533 ms 528 KB Wrong query response.
2 Halted 0 ms 0 KB -