#include "stations.h"
#include <vector>
#include <iostream>
using namespace std;
std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
std::vector<int> labels(n);
vector< vector<int> > graph(n,vector<int>());
for(int i=0;i<n-1;i++){
graph[u[i]].push_back(v[i]);
graph[v[i]].push_back(u[i]);
}
int s=0;
for(int i=0;i<n;i++){
if(graph[i].size()==1) {s=i;break;}
}
int b=s;
for(int i=0;i<n;i++){
labels[s]=i;
//printf("%dst: %d, labels[s]:%d\n",i,s,labels[s]);
for(auto j=graph[s].begin(); j!=graph[s].end();j++){
if(*j!=b){
b=s;
s=*j;
break;
}
}
}
//for(int i=0;i<n-1;i++) cout << labels[i] << " ";
return labels;
}
int find_next_station(int s, int t, std::vector<int> c) {
if(c.size()==2){
if(c[0]>c[1]){
int temp=c[0];
c[0]=c[1];
c[1]=temp;
}
return (s<t)?c[1]:c[0];
}
else return c[0];
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
611 ms |
792 KB |
Output is correct |
2 |
Correct |
529 ms |
884 KB |
Output is correct |
3 |
Correct |
1079 ms |
996 KB |
Output is correct |
4 |
Correct |
781 ms |
868 KB |
Output is correct |
5 |
Correct |
672 ms |
884 KB |
Output is correct |
6 |
Correct |
464 ms |
756 KB |
Output is correct |
7 |
Correct |
573 ms |
756 KB |
Output is correct |
8 |
Correct |
3 ms |
868 KB |
Output is correct |
9 |
Correct |
5 ms |
756 KB |
Output is correct |
10 |
Correct |
2 ms |
868 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
6 ms |
372 KB |
Invalid labels (duplicates values). scenario=0, label=0 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
670 ms |
756 KB |
Output is correct |
2 |
Correct |
577 ms |
756 KB |
Output is correct |
3 |
Correct |
1176 ms |
756 KB |
Output is correct |
4 |
Correct |
673 ms |
868 KB |
Output is correct |
5 |
Correct |
628 ms |
996 KB |
Output is correct |
6 |
Correct |
512 ms |
792 KB |
Output is correct |
7 |
Correct |
477 ms |
904 KB |
Output is correct |
8 |
Correct |
3 ms |
756 KB |
Output is correct |
9 |
Correct |
6 ms |
736 KB |
Output is correct |
10 |
Correct |
2 ms |
736 KB |
Output is correct |
11 |
Incorrect |
1 ms |
364 KB |
Invalid labels (duplicates values). scenario=1, label=0 |
12 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1093 ms |
868 KB |
Output is correct |
2 |
Correct |
654 ms |
740 KB |
Output is correct |
3 |
Correct |
667 ms |
756 KB |
Output is correct |
4 |
Correct |
3 ms |
736 KB |
Output is correct |
5 |
Correct |
4 ms |
736 KB |
Output is correct |
6 |
Correct |
2 ms |
876 KB |
Output is correct |
7 |
Incorrect |
1 ms |
492 KB |
Invalid labels (duplicates values). scenario=0, label=0 |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
660 ms |
884 KB |
Output is correct |
2 |
Correct |
555 ms |
756 KB |
Output is correct |
3 |
Correct |
1087 ms |
756 KB |
Output is correct |
4 |
Correct |
703 ms |
868 KB |
Output is correct |
5 |
Correct |
557 ms |
868 KB |
Output is correct |
6 |
Correct |
467 ms |
736 KB |
Output is correct |
7 |
Correct |
473 ms |
924 KB |
Output is correct |
8 |
Correct |
3 ms |
736 KB |
Output is correct |
9 |
Correct |
5 ms |
876 KB |
Output is correct |
10 |
Correct |
2 ms |
736 KB |
Output is correct |
11 |
Incorrect |
5 ms |
364 KB |
Invalid labels (duplicates values). scenario=0, label=0 |
12 |
Halted |
0 ms |
0 KB |
- |