#include "stations.h"
#include <vector>
#include<bits/stdc++.h>
using namespace std;
int a,b,c,d,e,i,j,ii,jj,zx,xc,tim,lf[1009],rg[1009],dep[1009],pi;
vector <int> v[1009];
pair <int, int> p[1009];
void dfs(int q, int w){
if(w!=-1) dep[q]=dep[w]+1;
tim++;
lf[q]=tim;
for(vector <int>::iterator it=v[q].begin(); it!=v[q].end(); it++){
if((*it)==w) continue;
dfs((*it),q);
}
tim++;
rg[q]=tim;
if(dep[q]%2==0){
pi++;
p[pi].first=lf[q];
p[pi].second=q;
}else{
pi++;
p[pi].first=rg[q];
p[pi].second=q;
}
}
vector<int> label(int n, int kk, vector<int> U, vector<int> V) {
vector<int> labels(n);
/*for (int i = 0; i < n; i++) {
labels[i] = i;
}*/
for(i=0; i<n-1; i++){
v[U[i]].push_back(V[i]);
v[V[i]].push_back(U[i]);
}
//cout<<pi<<" ra "<<endl;
dfs(0,-1);
sort(p+1,p+pi+1);
//cout<<pi<<" kd "<<endl;
for(i=1; i<=pi; i++){
//cout<<p[i].first<<" "<<p[i].second<<endl;
labels[p[i].second]=i-1;
}
return labels;
}
int find_next_station(int s, int t, std::vector<int> C) {
for(i=0; i<C.size(); i++){
if(C[i]==t){
return t;
}
}
e=0;
for(i=0; i<C.size(); i++){
if(C[i]>s){
e=1;
break;
}
}
if(e==0){
sort(C.begin(),C.end());
for(i=1; i<C.size(); i++){
if(t>=C[i-1]&&t<C[i]){
return C[i-1];
}
}
if(t>=C[C.size()-1]&&t<s){
return C[C.size()-1];
}
return C[0];
}else{
sort(C.begin(),C.end());
if(s==0){
for(i=0; i<C.size(); i++){
if(t<=C[i]){
return C[i];
}
}
}else{
if(t<s){
return C[C.size()-1];
}
for(i=0; i<C.size(); i++){
if(i+1>=C.size()) break;
if(t<=C[i]){
return C[i];
}
}
return C[C.size()-1];
}
}
//return C[0];
}
Compilation message
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:49:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
49 | for(i=0; i<C.size(); i++){
| ~^~~~~~~~~
stations.cpp:55:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
55 | for(i=0; i<C.size(); i++){
| ~^~~~~~~~~
stations.cpp:63:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
63 | for(i=1; i<C.size(); i++){
| ~^~~~~~~~~
stations.cpp:75:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
75 | for(i=0; i<C.size(); i++){
| ~^~~~~~~~~
stations.cpp:84:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
84 | for(i=0; i<C.size(); i++){
| ~^~~~~~~~~
stations.cpp:85:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
85 | if(i+1>=C.size()) break;
| ~~~^~~~~~~~~~
stations.cpp:94:1: warning: control reaches end of non-void function [-Wreturn-type]
94 | }
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
748 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
2 ms |
748 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1657 ms |
2097152 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
997 ms |
864 KB |
Output is correct |
2 |
Runtime error |
1248 ms |
2097156 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
2 ms |
748 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |