#include <bits/stdc++.h>
#include "stations.h"
#define pii pair<int,int>
#define in first
#define out second
#define mp make_pair
using namespace std;
vector<int> label(int n ,int k , vector<int> u , vector<int> v){
vector<int> ans(n) ;
vector<int> adj[n] ;
for(int i=0;i<n-1;i++) {
adj[u[i]].push_back(v[i]) ;
adj[v[i]].push_back(u[i]) ;
}
int tim =0 ;
function<void(int,int)> dfs = [&](int a, int p){
ans[a]=tim++;
for(int&x:adj[a]){
if(x!=p) dfs(x,a) ;
}
};
for(int i=0;i<n;i++){
if(adj[i].size()==1){
dfs(i,i) ;
break ;
}
}
return ans ;
}
pii get(int x){
return mp(x%(1<<11),(x>>11)) ;
}
bool ancestor(pii s, pii b){
return (s.in<=b.in&&b.out<=s.out);
}
int find_next_station(int s ,int t, vector<int> ne){
if(s<t) return s+1 ;
return s-1 ;
}
/*int main(){
vector<int> u= {0,1,2} , v = {1,2,3} ;
vector<int> res = label(4,1000000,u,v) ;
for(int x : res) cout << x <<" " ;
cout << endl ;
for(int i=0;i<4;i++){
for(int j=0;j<4;j++){
if(i!=j){
cout << res[i]<< " "<< res[j] << ": " << find_next_station(res[i],res[j],adj[i]) << endl ;
}
}
}
return 0 ;
}*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
701 ms |
620 KB |
Output is correct |
2 |
Correct |
598 ms |
528 KB |
Output is correct |
3 |
Correct |
1077 ms |
488 KB |
Output is correct |
4 |
Correct |
756 ms |
528 KB |
Output is correct |
5 |
Correct |
826 ms |
400 KB |
Output is correct |
6 |
Correct |
634 ms |
620 KB |
Output is correct |
7 |
Correct |
558 ms |
528 KB |
Output is correct |
8 |
Correct |
3 ms |
492 KB |
Output is correct |
9 |
Correct |
5 ms |
556 KB |
Output is correct |
10 |
Correct |
2 ms |
484 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
515 ms |
528 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
651 ms |
528 KB |
Output is correct |
2 |
Correct |
444 ms |
624 KB |
Output is correct |
3 |
Correct |
969 ms |
520 KB |
Output is correct |
4 |
Correct |
907 ms |
488 KB |
Output is correct |
5 |
Correct |
601 ms |
576 KB |
Output is correct |
6 |
Correct |
518 ms |
520 KB |
Output is correct |
7 |
Correct |
469 ms |
528 KB |
Output is correct |
8 |
Correct |
3 ms |
472 KB |
Output is correct |
9 |
Correct |
4 ms |
472 KB |
Output is correct |
10 |
Correct |
2 ms |
480 KB |
Output is correct |
11 |
Incorrect |
791 ms |
532 KB |
Wrong query response. |
12 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1033 ms |
400 KB |
Output is correct |
2 |
Correct |
861 ms |
400 KB |
Output is correct |
3 |
Correct |
743 ms |
496 KB |
Output is correct |
4 |
Correct |
2 ms |
472 KB |
Output is correct |
5 |
Correct |
4 ms |
480 KB |
Output is correct |
6 |
Correct |
2 ms |
472 KB |
Output is correct |
7 |
Incorrect |
749 ms |
400 KB |
Wrong query response. |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
583 ms |
576 KB |
Output is correct |
2 |
Correct |
595 ms |
620 KB |
Output is correct |
3 |
Correct |
923 ms |
400 KB |
Output is correct |
4 |
Correct |
818 ms |
456 KB |
Output is correct |
5 |
Correct |
722 ms |
484 KB |
Output is correct |
6 |
Correct |
570 ms |
696 KB |
Output is correct |
7 |
Correct |
494 ms |
656 KB |
Output is correct |
8 |
Correct |
3 ms |
472 KB |
Output is correct |
9 |
Correct |
5 ms |
472 KB |
Output is correct |
10 |
Correct |
2 ms |
476 KB |
Output is correct |
11 |
Incorrect |
462 ms |
664 KB |
Wrong query response. |
12 |
Halted |
0 ms |
0 KB |
- |