// TODO -> PONER ALGO AQUI
// amigos y no mas
// I'm in the coolest driver high
// += O(logn) ; + = O(n)
#include <bits/stdc++.h>
#include "stations.h"
#include <variant>
#define fastio ios_base::sync_with_stdio(0); cin.tie(0)
#define ones(x) __builtin_popcount(x)
#define loga2(x) __builtin_ctzll(x)
#define pos2(x) __builtin_clzll(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef pair <ii, ii> iiii;
typedef vector <int> vi;
typedef vector <ii> vii;
const int mod = 998244353;
const ll inf = (1LL<<62)-1;
struct HASH{
size_t operator()(const pair<int,int>&x)const{
return hash<long long>()(((long long)x.first)^(((long long)x.second)<<32));
}
};
vector< vector<int> > G;
vector<int> order;
vector<bool> vis;
int N;
int cont = 0;
void dfs(int x){
for(int i=0; i<G[x].size(); i++){
int &y = G[x][i];
if(!vis[y]){
vis[y] = true;
dfs(y);
}
}
order[x] = cont; cont++;
}
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
N = n;
vector<int> labels(n);
G.clear();
order.clear();
vis.clear();
G.resize(n);
order.resize(n);
vis.resize(n,0);
for(int i=0; i<n-1;i++){
G[u[i]].push_back(v[i]);
G[v[i]].push_back(u[i]);
}
vis[0] = true;
dfs(0);
for (int i = 0; i < n; i++) {
labels[i] = order[i];
}
return labels;
}
int find_next_station(int s, int t, std::vector<int> c) {
if(c.size() == 1) return c[0];
if(s < t){
auto it = *upper_bound(c.begin() , c.end() , s);
return it;
}
// else t>s
auto it = lower_bound(c.begin() , c.end() , s); it--;
return *it;
}
Compilation message
stations.cpp: In function 'void dfs(int)':
stations.cpp:39:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
39 | for(int i=0; i<G[x].size(); i++){
| ~^~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
344 KB |
Invalid labels (values out of range). scenario=2, k=1000, vertex=0, label=1010 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
344 KB |
Invalid labels (values out of range). scenario=1, k=1000, vertex=0, label=1989 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
371 ms |
940 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
588 ms |
684 KB |
Output is correct |
2 |
Incorrect |
473 ms |
684 KB |
Wrong query response. |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
384 ms |
940 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |