#include "stations.h"
#include <cstdio>
#include <cassert>
#include <map>
#include <vector>
#include <algorithm>
////////
///////////////////
#include "stations.h"
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
typedef vector<pii> vii;
typedef vector<vii> vvii;
typedef vector<bool> vb;
int tiempo;
vvi conexiones;
vi labeles;
void bfs(int ac, int ant, bool entrada){
tiempo++;
//cerr << ac << ' ' << tiempo << '\n';
if (entrada) labeles[ac]=tiempo;
for (int x:conexiones[ac]){
if (x!=ant){
bfs(x,ac,not entrada);
tiempo++;
}
}
//cerr << ac << ' ' << tiempo << '\n';
if (not entrada) labeles[ac]=tiempo+2000;
}
std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
//cerr<<"h";
tiempo=-1;
conexiones=vvi(n);
for (int i=0;i<n-1;i++){
conexiones[u[i]].push_back(v[i]);
conexiones[v[i]].push_back(u[i]);
}
labeles=vi(n);
bfs(0,-1, 1);
//for (int x:labeles) cerr << x << ' ';
//cerr<<'\n';
return labeles;
}
int find_next_station(int ac, int obj, std::vector<int> vecinos) {
obj%=2000;
bool entrada=(ac<2000);
ac%=2000;
sort(vecinos.begin(),vecinos.end());
if (vecinos.size()==1) return vecinos[0]; //arriba
if (entrada){
int izq=ac;
if (obj<izq) return vecinos[vecinos.size()-1]; //arriba
for (int x:vecinos){
if (x%2000>=obj) return x; //abajo
}
return vecinos[vecinos.size()-1]; //arriba
}
else{
int der=ac;
if (obj>der) return vecinos[vecinos.size()-1]; //arriba
for (int i=vecinos.size()-1;i>=0;i--){
int x=vecinos[i];
if (x%2000<=obj) return x; //abajo
}
return vecinos[vecinos.size()-1]; //arriba
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
452 KB |
Invalid labels (values out of range). scenario=0, k=1000, vertex=1, label=2013 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
420 KB |
Invalid labels (values out of range). scenario=0, k=1000, vertex=1, label=3021 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
520 ms |
612 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
951 ms |
456 KB |
Output is correct |
2 |
Correct |
686 ms |
476 KB |
Output is correct |
3 |
Incorrect |
629 ms |
472 KB |
Wrong query response. |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
550 ms |
612 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |