#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 c[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 c[1];
else return c[0];
}
else return c[0];
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
508 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 |
5 ms |
384 KB |
Invalid labels (duplicates values). scenario=0, label=7 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
614 ms |
1296 KB |
Output is correct |
2 |
Correct |
460 ms |
1016 KB |
Output is correct |
3 |
Correct |
955 ms |
1008 KB |
Output is correct |
4 |
Correct |
779 ms |
868 KB |
Output is correct |
5 |
Correct |
642 ms |
864 KB |
Output is correct |
6 |
Correct |
458 ms |
1016 KB |
Output is correct |
7 |
Correct |
613 ms |
768 KB |
Output is correct |
8 |
Correct |
3 ms |
864 KB |
Output is correct |
9 |
Correct |
5 ms |
868 KB |
Output is correct |
10 |
Correct |
1 ms |
768 KB |
Output is correct |
11 |
Correct |
596 ms |
768 KB |
Output is correct |
12 |
Correct |
470 ms |
1124 KB |
Output is correct |
13 |
Correct |
507 ms |
1024 KB |
Output is correct |
14 |
Correct |
481 ms |
768 KB |
Output is correct |
15 |
Correct |
57 ms |
876 KB |
Output is correct |
16 |
Correct |
68 ms |
828 KB |
Output is correct |
17 |
Correct |
109 ms |
804 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1021 ms |
896 KB |
Output is correct |
2 |
Correct |
683 ms |
864 KB |
Output is correct |
3 |
Correct |
627 ms |
768 KB |
Output is correct |
4 |
Correct |
3 ms |
864 KB |
Output is correct |
5 |
Correct |
5 ms |
868 KB |
Output is correct |
6 |
Correct |
2 ms |
896 KB |
Output is correct |
7 |
Correct |
525 ms |
780 KB |
Output is correct |
8 |
Correct |
991 ms |
768 KB |
Output is correct |
9 |
Correct |
779 ms |
868 KB |
Output is correct |
10 |
Correct |
693 ms |
1032 KB |
Output is correct |
11 |
Incorrect |
1 ms |
384 KB |
Invalid labels (duplicates values). scenario=5, label=5 |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
547 ms |
1016 KB |
Partially correct |
2 |
Partially correct |
545 ms |
1008 KB |
Partially correct |
3 |
Correct |
972 ms |
876 KB |
Output is correct |
4 |
Correct |
662 ms |
864 KB |
Output is correct |
5 |
Correct |
738 ms |
868 KB |
Output is correct |
6 |
Partially correct |
607 ms |
1008 KB |
Partially correct |
7 |
Partially correct |
553 ms |
768 KB |
Partially correct |
8 |
Correct |
2 ms |
864 KB |
Output is correct |
9 |
Correct |
5 ms |
864 KB |
Output is correct |
10 |
Correct |
2 ms |
872 KB |
Output is correct |
11 |
Incorrect |
5 ms |
384 KB |
Invalid labels (duplicates values). scenario=0, label=7 |
12 |
Halted |
0 ms |
0 KB |
- |