#include "stations.h"
#include <vector>
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
vector<int> labels;
labels.assign(n,-1);
vector<vi>G;
G.resize(n+1);
int t=u.size();
for(int i=0;i<t;i++){
int x=u[i],y=v[i];
G[x].push_back(y);
G[y].push_back(x);
}
int no=0,id=-1;
for(int i=0;i<n;i++){
if(G[i].size()==1){
id=i;
break;
}
}
queue<int> q;
q.push(id);
while(!q.empty()){
int x=q.front();
q.pop();
labels[x]=no;
no++;
for(auto &v:G[x]){
if(labels[v]==-1){
q.push(v);
}
}
}
return labels;
}
int find_next_station(int s, int t, std::vector<int> c) {
if(s>t)
return s-1;
return s+1;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
609 ms |
764 KB |
Output is correct |
2 |
Correct |
485 ms |
828 KB |
Output is correct |
3 |
Correct |
1017 ms |
876 KB |
Output is correct |
4 |
Correct |
756 ms |
652 KB |
Output is correct |
5 |
Correct |
595 ms |
648 KB |
Output is correct |
6 |
Correct |
546 ms |
768 KB |
Output is correct |
7 |
Correct |
457 ms |
828 KB |
Output is correct |
8 |
Correct |
3 ms |
640 KB |
Output is correct |
9 |
Correct |
3 ms |
640 KB |
Output is correct |
10 |
Correct |
2 ms |
644 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
575 ms |
768 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
578 ms |
820 KB |
Output is correct |
2 |
Correct |
552 ms |
768 KB |
Output is correct |
3 |
Correct |
915 ms |
648 KB |
Output is correct |
4 |
Correct |
655 ms |
648 KB |
Output is correct |
5 |
Correct |
648 ms |
640 KB |
Output is correct |
6 |
Correct |
452 ms |
824 KB |
Output is correct |
7 |
Correct |
447 ms |
828 KB |
Output is correct |
8 |
Correct |
3 ms |
648 KB |
Output is correct |
9 |
Correct |
5 ms |
640 KB |
Output is correct |
10 |
Correct |
1 ms |
644 KB |
Output is correct |
11 |
Incorrect |
599 ms |
640 KB |
Wrong query response. |
12 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1033 ms |
640 KB |
Output is correct |
2 |
Correct |
646 ms |
640 KB |
Output is correct |
3 |
Correct |
654 ms |
640 KB |
Output is correct |
4 |
Correct |
3 ms |
660 KB |
Output is correct |
5 |
Correct |
6 ms |
640 KB |
Output is correct |
6 |
Correct |
1 ms |
640 KB |
Output is correct |
7 |
Incorrect |
682 ms |
644 KB |
Wrong query response. |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
553 ms |
824 KB |
Output is correct |
2 |
Correct |
513 ms |
768 KB |
Output is correct |
3 |
Correct |
1057 ms |
648 KB |
Output is correct |
4 |
Correct |
742 ms |
768 KB |
Output is correct |
5 |
Correct |
639 ms |
768 KB |
Output is correct |
6 |
Correct |
533 ms |
768 KB |
Output is correct |
7 |
Correct |
567 ms |
828 KB |
Output is correct |
8 |
Correct |
3 ms |
652 KB |
Output is correct |
9 |
Correct |
5 ms |
656 KB |
Output is correct |
10 |
Correct |
1 ms |
648 KB |
Output is correct |
11 |
Incorrect |
580 ms |
752 KB |
Wrong query response. |
12 |
Halted |
0 ms |
0 KB |
- |