#include "stations.h"
#include <vector>
#include <bits/stdc++.h>
#define MAX 1000000000
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> ii;
vector<int> labels;
vector<vi> G;
int in[1010],out[1010];
int it=0;
void dfs(int u){
it++;
in[u]=it;
for(auto &v:G[u]){
if(!in[v]){
dfs(v);
}
}
it++;
out[u]=it;
}
std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
labels.assign(n,-1);
G.clear();
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);
}
memset(in,0,sizeof in);
memset(out,0,sizeof out);
dfs(0);
for(int i=0;i<n;i++){
int la=in[i]*1000;
la+=out[i];
// cout<<in[i]<<" "<<out[i]<<" "<<la<<endl;
labels[i]=la;
}
return labels;
}
int find_next_station(int s, int t, std::vector<int> c) {
return -1;
int ro=-1,rp=-1;
int si,ti,so,to;
si=s/1000; so=s%1000;
ti=t/1000; to=t%1000;
bool sub=0;
int ia,oa;
for(int i=0;i<c.size();i++){
if(t==c[i]) return c[i];
ia=c[i]/1000; oa=c[i]%1000;
if(si<ia && so>oa){
if(ia<ti && oa>to){
rp=c[i];
}
}
else{
ro=c[i];
}
}
if(si<ti && so>to){
//cout<<"hijo "<<rp<<endl;
return rp;
}
else{
//cout<<"padre "<<ro<<endl;
return ro;
}
}
Compilation message
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:53:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
53 | for(int i=0;i<c.size();i++){
| ~^~~~~~~~~
stations.cpp:51:8: warning: unused variable 'sub' [-Wunused-variable]
51 | bool sub=0;
| ^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
376 KB |
Invalid labels (values out of range). scenario=0, k=1000, vertex=0, label=1020 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
6 ms |
384 KB |
Invalid labels (values out of range). scenario=0, k=1000, vertex=0, label=2992 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
384 KB |
Invalid labels (values out of range). scenario=1, k=1000000, vertex=12, label=1755975 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
913 ms |
768 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
543 ms |
768 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |