#include "stations.h"
#include <vector>
#include <bits/stdc++.h>
using namespace std;
const int N = 2e3;
int cnt = 0;
int dfs(int i,int pre,vector<int> &ret,vector<int> adj[]){
int mx = cnt;
ret[i] = cnt++;
for(int j=0;j<adj[i].size();j++){
int v = adj[i][j];
if(v==pre)continue;
mx = max(mx,dfs(v,i,ret,adj));
}
//ret[i] += mx*1000;
return mx;
}
std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
cnt = 0;
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]);
}
vector<int> ret = vector<int>(n,0);
for(int i=0;i<n;i++)
if(adj[i].size()==1){
dfs(i,i,ret,adj);
break;
}
return ret;
}
int get_val(int x,int l,int r){
int ret = 0;
return x%1000;
for(int i=l;i<=r;i++)
ret |= (1<<(i-l))*(((1<<i)&x)>0);
return ret;
}
bool cmp(int x,int y){
return get_val(x,0,9)<get_val(y,0,9);
}
int find_next_station(int s, int t, std::vector<int> c) {
if(s<t)
return s+1;
else
return s-1;
}
Compilation message
stations.cpp: In function 'int dfs(int, int, std::vector<int>&, std::vector<int>*)':
stations.cpp:15:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
15 | for(int j=0;j<adj[i].size();j++){
| ~^~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
560 ms |
616 KB |
Output is correct |
2 |
Correct |
439 ms |
784 KB |
Output is correct |
3 |
Correct |
839 ms |
524 KB |
Output is correct |
4 |
Correct |
691 ms |
532 KB |
Output is correct |
5 |
Correct |
590 ms |
528 KB |
Output is correct |
6 |
Correct |
584 ms |
648 KB |
Output is correct |
7 |
Correct |
472 ms |
612 KB |
Output is correct |
8 |
Correct |
3 ms |
592 KB |
Output is correct |
9 |
Correct |
4 ms |
596 KB |
Output is correct |
10 |
Correct |
2 ms |
596 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
485 ms |
484 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
588 ms |
608 KB |
Output is correct |
2 |
Correct |
517 ms |
616 KB |
Output is correct |
3 |
Correct |
984 ms |
536 KB |
Output is correct |
4 |
Correct |
734 ms |
548 KB |
Output is correct |
5 |
Correct |
671 ms |
484 KB |
Output is correct |
6 |
Correct |
446 ms |
644 KB |
Output is correct |
7 |
Correct |
500 ms |
612 KB |
Output is correct |
8 |
Correct |
4 ms |
596 KB |
Output is correct |
9 |
Correct |
5 ms |
596 KB |
Output is correct |
10 |
Correct |
2 ms |
596 KB |
Output is correct |
11 |
Incorrect |
662 ms |
576 KB |
Wrong query response. |
12 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
971 ms |
484 KB |
Output is correct |
2 |
Correct |
736 ms |
492 KB |
Output is correct |
3 |
Correct |
655 ms |
488 KB |
Output is correct |
4 |
Correct |
2 ms |
608 KB |
Output is correct |
5 |
Correct |
5 ms |
596 KB |
Output is correct |
6 |
Correct |
2 ms |
604 KB |
Output is correct |
7 |
Incorrect |
577 ms |
548 KB |
Wrong query response. |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
655 ms |
604 KB |
Output is correct |
2 |
Correct |
429 ms |
644 KB |
Output is correct |
3 |
Correct |
888 ms |
528 KB |
Output is correct |
4 |
Correct |
724 ms |
472 KB |
Output is correct |
5 |
Correct |
601 ms |
572 KB |
Output is correct |
6 |
Correct |
478 ms |
656 KB |
Output is correct |
7 |
Correct |
503 ms |
692 KB |
Output is correct |
8 |
Correct |
3 ms |
596 KB |
Output is correct |
9 |
Correct |
5 ms |
596 KB |
Output is correct |
10 |
Correct |
2 ms |
640 KB |
Output is correct |
11 |
Incorrect |
528 ms |
652 KB |
Wrong query response. |
12 |
Halted |
0 ms |
0 KB |
- |