#include<bits/stdc++.h>
#include "stations.h"
using namespace std;
vector<int> adj[1005];
int dtime;
/// in-stvis unda vicode out-ebi , out-stvis in-ebi
void dfs(int u , int h , vector<int> &R ,int p ){
if(!h) R[u]= dtime++;
for(int v : adj[u])if(v != p)dfs(v ,h^1 , R , u);
if(h) R[u] = dtime++;
}
vector<int> label(int n , int k ,vector<int> u , vector<int> v){
for(int i = 0; i < n; ++i) adj[i].clear();
for(int i = 0; i < n-1; ++i) adj[u[i]].emplace_back(v[i]) , adj[v[i]].emplace_back(u[i]);
vector<int> R(n);
dtime =0;
dfs(0 , 0 , R ,-1);
return R;
}
/// (in1 , out1) in = out0 + 1
/// (in0 , out0) out0 = in1 - 1;
int find_next_station(int s , int t , vector<int> c){
/// s-in
if(s < c[0]){
int cur = s;
for(int x: c){
if(cur < t && t <= x) return x;
cur = x;
}
return c.back(); /// parent
} else {
/// s out
for(int i = 0; i < c.size(); ++i){
if(i == c.size() - 1) {if(c[i] <= t && t <= s) return i; continue;}
if(c[i] <= t && t < c[i + 1]) return c[i];
}
/// parent
return c[0];
}
}
/*
int main (){
cin >> n;
for(int i =1; i < n; ++i){
int u , v; cin >> u>> v;
adj[u].emplace_back(v); adj[v].emplace_back(u);
}
vector<int> k = label(n , 1 , {3} , {3});
cout << find_next_station(1 , 3 , {3 , 2 ,0}) << endl;
}
*/
//int main (){}
Compilation message
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:33:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
33 | for(int i = 0; i < c.size(); ++i){
| ~~^~~~~~~~~~
stations.cpp:34:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
34 | if(i == c.size() - 1) {if(c[i] <= t && t <= s) return i; continue;}
| ~~^~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
533 ms |
1248 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
462 ms |
888 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
539 ms |
992 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
915 ms |
844 KB |
Output is correct |
2 |
Correct |
636 ms |
864 KB |
Output is correct |
3 |
Incorrect |
578 ms |
736 KB |
Wrong query response. |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
622 ms |
1068 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |