#include "stations.h"
#include <vector>
#include <math.h>
#include <iostream>
#include <stdio.h>
using namespace std;
vector < int > Next[1005];
int con[1005]={0};
int ans[1005]={0};
bool use[1005]={0};
int st;
void F(int here,int con,int t)
{
//printf("%d %d\n",here,con);
int now=0;
ans[here]=con;
use[here]=1;
for(auto i:Next[here])
{
if(!use[i])
{
now++;
if(st==here) F(i,now,t);
else F(i,con+t,t);
}
}
}
vector<int> label(int n, int k, vector<int> u, vector<int> v)
{
//printf("aa\n");
vector<int> labels;
int i;
for(i=0;i<n;i++)
{
labels.push_back(0);
Next[i].clear();
con[i]=0;
use[i]=0;
}
for(int i=0;i<n-1;i++)
{
con[u[i]]++;
con[v[i]]++;
Next[u[i]].push_back(v[i]);
Next[v[i]].push_back(u[i]);
}
for(i=0;i<n;i++)
{
if(con[i]>2)
{
st=i;
F(i,0,con[i]);
break;
}
}
if(i==n)
{
st=0;
F(0,0,con[0]);
}
for(i=0;i<n;i++) labels[i]=ans[i];
return labels;
}
int find_next_station(int s, int t, vector<int> c)
{
int x;
if(t==0) return 0;
if(s==0)
{
if(t%c.size()==0) return c.size();
return t%c.size();
}
if(c.size()==1) return c[0];
x=abs(s-c[1]);
if(s%x==t%x)
{
if(s<t) return s+x;
else return s-x;
}
else return s-x;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
500 KB |
Invalid labels (values out of range). scenario=2, k=1000, vertex=5, label=1196 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
384 KB |
Invalid labels (duplicates values). scenario=0, label=7 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
572 ms |
1024 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
877 ms |
768 KB |
Output is correct |
2 |
Incorrect |
734 ms |
872 KB |
Wrong query response. |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
572 ms |
1016 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |