#include "stations.h"
#include <vector>
#include <math.h>
#include <iostream>
#include <stdio.h>
using namespace std;
vector < int > Next[1005];
vector < int > how;
int con[1005]={0};
int ans[1005]={0};
int sz[1005]={0};
bool use[1005]={0};
int st;
void F(int here)
{
//printf("%d %d\n",here,con);
int now=0;
use[here]=1;
sz[here]=1;
how.push_back(here);
for(auto i:Next[here])
{
if(!use[i])
{
F(i);
sz[here]+=i;
}
}
}
vector<int> label(int n, int k, vector<int> u, vector<int> v)
{
vector<int> labels;
how.clear();
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]);
}
F(0);
for(i=0;i<n;i++) labels[how[i]]=1000*i+(sz[how[i]]-1);
return labels;
}
int find_next_station(int s, int t, vector<int> c)
{
/*int x,n=c.size(),i;
if(n==1) return c[0];
if(t/1000>=s/1000+1&&t/1000<=s/1000+s%1000)
{
for(i=0;i<n;i++)
{
if(c[i]/1000>s/1000)
{
if(t/1000>=c[i]/1000&&t/1000<=c[i]/1000+c[i]%1000) return c[i];
}
}
}
else*/ return c[0];
}
Compilation message
stations.cpp: In function 'void F(int)':
stations.cpp:17:9: warning: unused variable 'now' [-Wunused-variable]
17 | int now=0;
| ^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
512 KB |
Invalid labels (values out of range). scenario=0, k=1000, vertex=1, label=6008 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
384 KB |
Invalid labels (values out of range). scenario=0, k=1000, vertex=1, label=1007 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
555 ms |
1024 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
879 ms |
1024 KB |
Output is correct |
2 |
Incorrect |
678 ms |
876 KB |
Wrong query response. |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
556 ms |
1024 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |