#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;
}
}
void dfs2(int q, int w){
tim++;
p[q].first=tim;
for(vector <int>::iterator it=v[q].begin(); it!=v[q].end(); it++){
if((*it)==w) continue;
dfs2((*it),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;
dfs2(0,-1);
/*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;
labels[i]=p[i].first;
}
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;
}
}*/
if(t>s){
if(C[0]>s){
return C[0];
}else{
return C[1];
}
}else{
if(C[0]<s){
return C[0];
}else{
return C[1];
}
}
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:78:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
78 | for(i=0; i<C.size(); i++){
| ~^~~~~~~~~
stations.cpp:86:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
86 | for(i=1; i<C.size(); i++){
| ~^~~~~~~~~
stations.cpp:98:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
98 | for(i=0; i<C.size(); i++){
| ~^~~~~~~~~
stations.cpp:107:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
107 | for(i=0; i<C.size(); i++){
| ~^~~~~~~~~
stations.cpp:108:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
108 | if(i+1>=C.size()) break;
| ~~~^~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1652 ms |
2097152 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
3007 ms |
620 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1649 ms |
2097156 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
400 KB |
Invalid labels (duplicates values). scenario=0, label=0 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
2751 ms |
2097156 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |