#include "stations.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
vector<int> label(int n,int k,vector<int> u,vector<int> v){
vector<int> l(n,-1),deg(n);
vector<vector<int>> AL;
AL.resize(n);
for(int i=0;i<n-1;++i){
++deg[u[i]];
++deg[v[i]];
AL[u[i]].pb(v[i]);
AL[v[i]].pb(u[i]);
}
int mx=0,pos=0;
for(int i=0;i<n;++i){
if(deg[i]>mx){
mx=deg[i];
pos=i;
}
}
l[pos]=0;
for(int i=0;i<mx;++i){
int u=AL[pos][i];
l[u]=i+1;
while(true){
for(int v:AL[u]){
if(l[v]==-1){
l[v]=l[u]+mx;
u=v;break;
}
}
if(AL[u].size()==1)break;
}
}
for(int i:l)printf("%d ",i);
return l;
}
int find_next_station(int s,int t,vector<int> c){
if(s==0){
int mod=c.size();
if(t%mod==0)return c[mod-1];
else return c[t%mod-1];
}
else if(c.size()==1){
return c[0];
}
else{
int mod=c.back()-s;
if(t>s&&t%mod==s%mod)return c[1];
else return c[0];
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
0 ms |
200 KB |
Execution killed with signal 13 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
288 KB |
Execution killed with signal 13 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
0 ms |
200 KB |
Execution killed with signal 13 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
0 ms |
292 KB |
Execution killed with signal 13 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
276 KB |
Execution killed with signal 13 |
2 |
Halted |
0 ms |
0 KB |
- |