#include "stations.h"
#include <bits/stdc++.h>
using namespace std;
const int N=1e3+10;
int tmpcase1,cnt=0;
bool case1;
vector<int> adj[N],lb;
void labelcase1(int u,int p){
lb[u]=cnt++;
for(int i=0;i<adj[u].size();i++){
if(adj[u][i]!=p) labelcase1(adj[u][i],u);
}
}
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
lb.resize(n);
cnt=0;
case1=true;
for(int i=0;i<n-1;i++){
adj[u[i]].push_back(v[i]);
adj[v[i]].push_back(u[i]);
}
for(int i=0;i<n;i++){
if(adj[i].size()>2) case1=false;
if(adj[i].size()==1) tmpcase1=i;
}
if(case1){
labelcase1(tmpcase1,-1);
}
/*for(int i=0;i<lb.size();i++) cout<<lb[i] <<" ";
cout<<"\n\n\n";*/
return lb;
}
int find_next_station(int s, int t, vector<int> c) {
if(c.size()==1) return c[0];
if(s<t) return max(c[0],c[1]);
return min(c[0],c[1]);
}
Compilation message
stations.cpp: In function 'void labelcase1(int, int)':
stations.cpp:10:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
10 | for(int i=0;i<adj[u].size();i++){
| ~^~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
600 KB |
Invalid labels (duplicates values). scenario=2, label=0 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
600 KB |
Invalid labels (duplicates values). scenario=0, label=0 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
600 KB |
Invalid labels (duplicates values). scenario=1, label=0 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
579 ms |
684 KB |
Output is correct |
2 |
Incorrect |
458 ms |
684 KB |
Wrong query response. |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
596 KB |
Invalid labels (duplicates values). scenario=1, label=0 |
2 |
Halted |
0 ms |
0 KB |
- |