#include "stations.h"
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pull;
typedef pair<int, int> pii;
typedef pair<ld, ld> pld;
vector<int> g[1009];
vector<int> ans;
int curt = 0;
void dfs(int v, int prt, int depth){
if(depth%2 == 0)
ans[v] = curt++;
for(auto u : g[v])
if(u != prt)
dfs(u, v, depth+1);
if(depth%2 == 1)
ans[v] = curt++;
}
std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
ans = vector<int>(n);
for(int i = 0; i < n; ++i)
g[i].clear();
for(int i = 0; i < n-1; ++i){
g[u[i]].pb(v[i]);
g[v[i]].pb(u[i]);
}
curt = 0;
dfs(0, -1, 0);
return ans;
}
int find_next_station(int s, int t, std::vector<int> c) {
int smaller = 0;
for(auto u : c)
if(u < s)
smaller = 1;
if(smaller == 0){
sort(all(c));
for(auto u : c)
if(t <= u)
return u;
}
else{
sort(all(c), greater<int>());
for(auto u : c)
if(t >= u)
return u;
}
}
Compilation message
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:58:1: warning: control reaches end of non-void function [-Wreturn-type]
58 | }
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
721 ms |
528 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
434 ms |
500 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
790 ms |
636 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
967 ms |
400 KB |
Output is correct |
2 |
Correct |
875 ms |
400 KB |
Output is correct |
3 |
Incorrect |
614 ms |
528 KB |
Wrong query response. |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
744 ms |
520 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |