#include "stations.h"
#include <bits/stdc++.h>
using namespace std;
#define what_is(a) cout << #a << " is " << a << "\n"
#define checker(a) cout <"checker reached " << a << "\n"
vector<vector<int>> adj(1000,vector<int>());
vector<int> lbl;
void dfs(int u,int p,int d){
lbl[u]=d++;
for(int v:adj[u])
if(v!=p)
dfs(v,u,d);
}
std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
lbl = vector<int>(n);
for(int i=0;i<n;i++)
adj[i] = vector<int>();
for(int i=0;i<n-1;i++){
adj[u[i]].push_back(v[i]);
adj[v[i]].push_back(u[i]);
}
int src = -1;
for(int i=0;i<n;i++)
if(adj[i].size()>2)src = i;
if(src==-1)
for(int i=0;i<n;i++)
if(adj[i].size()==1)src = i;
lbl[src]=0;
int d = 1;
for(int a:adj[src]){
dfs(a,src,d);
d+=1000;
}
return lbl;
}
int find_next_station(int s, int t, std::vector<int> c) {
if(t==0)return s-1;
if(s==0)return (t/1000)*1000 + 1;
if(s/1000==t/1000){
if(s<t)return s++;
else return s-1;
}else{
return s-1;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
643 ms |
504 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
376 KB |
Invalid labels (duplicates values). scenario=0, label=10 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
717 ms |
528 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1117 ms |
520 KB |
Output is correct |
2 |
Incorrect |
868 ms |
400 KB |
Wrong query response. |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
576 ms |
528 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |