#include "stations.h"
#include<bits/stdc++.h>
#define fi first
#define se second
using namespace std;
typedef vector<int> vi;
const int N=1e3+10;
vi graf[N];
int val[N],li,kol[N];
void dfs(int v,int o){
li++;
if(!kol[v]) val[v]=li;
for(auto u:graf[v]){
if(u==o) continue;
kol[u]=kol[v]^1;
dfs(u,v);
}
li++;
if(kol[v]) val[v]=li;
}
vi label(int n, int k, vi u,vi v) {
for(int i=0;i<n;i++) graf[i].clear(),kol[i]=0,val[i]=0;
li=0;
for(int i=0;i<n-1;i++)
graf[u[i]].push_back(v[i]),graf[v[i]].push_back(u[i]);
dfs(0,0);
vector<pair<int,int>> pom;
for(int i=0;i<n;i++) pom.push_back({val[i],i});
sort(pom.begin(),pom.end());
vi labels(n);
for(int i=0;i<n;i++) labels[pom[i].se]=i;
return labels;
}
int find_next_station(int s,int t,vi c) {
if(c.size()==1) return c[0];
if(c[0]>s){
// pre
if(s==0){
for(auto u:c){
if(u>=t) return u;
}
return 0;
}
if(t>=s and t<=c[c.size()-2]){
for(auto u:c){
if(u>=t) return u;
}
return 0;
}return c[c.size()-1];
}else{
if(t>c[0] and t<=s){
int ost=0;
for(int i=1;i<(int)c.size();i++){
if(t>=c[i]) ost=c[i];
}
return ost;
}else return c[0];
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
377 ms |
684 KB |
Output is correct |
2 |
Correct |
300 ms |
684 KB |
Output is correct |
3 |
Correct |
616 ms |
684 KB |
Output is correct |
4 |
Correct |
401 ms |
684 KB |
Output is correct |
5 |
Correct |
390 ms |
684 KB |
Output is correct |
6 |
Correct |
316 ms |
684 KB |
Output is correct |
7 |
Correct |
296 ms |
684 KB |
Output is correct |
8 |
Correct |
2 ms |
768 KB |
Output is correct |
9 |
Correct |
1 ms |
764 KB |
Output is correct |
10 |
Correct |
0 ms |
776 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
321 ms |
684 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
373 ms |
684 KB |
Output is correct |
2 |
Correct |
306 ms |
684 KB |
Output is correct |
3 |
Correct |
616 ms |
684 KB |
Output is correct |
4 |
Correct |
446 ms |
684 KB |
Output is correct |
5 |
Correct |
407 ms |
684 KB |
Output is correct |
6 |
Correct |
297 ms |
684 KB |
Output is correct |
7 |
Correct |
311 ms |
684 KB |
Output is correct |
8 |
Correct |
1 ms |
768 KB |
Output is correct |
9 |
Correct |
1 ms |
768 KB |
Output is correct |
10 |
Correct |
0 ms |
764 KB |
Output is correct |
11 |
Correct |
413 ms |
820 KB |
Output is correct |
12 |
Incorrect |
320 ms |
784 KB |
Wrong query response. |
13 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
600 ms |
684 KB |
Output is correct |
2 |
Correct |
432 ms |
684 KB |
Output is correct |
3 |
Correct |
402 ms |
684 KB |
Output is correct |
4 |
Correct |
1 ms |
768 KB |
Output is correct |
5 |
Correct |
1 ms |
772 KB |
Output is correct |
6 |
Correct |
1 ms |
768 KB |
Output is correct |
7 |
Correct |
391 ms |
684 KB |
Output is correct |
8 |
Correct |
620 ms |
684 KB |
Output is correct |
9 |
Correct |
421 ms |
684 KB |
Output is correct |
10 |
Correct |
383 ms |
684 KB |
Output is correct |
11 |
Correct |
4 ms |
768 KB |
Output is correct |
12 |
Correct |
3 ms |
776 KB |
Output is correct |
13 |
Correct |
2 ms |
768 KB |
Output is correct |
14 |
Correct |
2 ms |
768 KB |
Output is correct |
15 |
Correct |
1 ms |
768 KB |
Output is correct |
16 |
Correct |
336 ms |
684 KB |
Output is correct |
17 |
Correct |
318 ms |
684 KB |
Output is correct |
18 |
Correct |
297 ms |
800 KB |
Output is correct |
19 |
Correct |
297 ms |
684 KB |
Output is correct |
20 |
Correct |
300 ms |
804 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
376 ms |
684 KB |
Output is correct |
2 |
Correct |
309 ms |
684 KB |
Output is correct |
3 |
Correct |
606 ms |
684 KB |
Output is correct |
4 |
Correct |
415 ms |
684 KB |
Output is correct |
5 |
Correct |
408 ms |
684 KB |
Output is correct |
6 |
Correct |
309 ms |
684 KB |
Output is correct |
7 |
Correct |
277 ms |
684 KB |
Output is correct |
8 |
Correct |
1 ms |
776 KB |
Output is correct |
9 |
Correct |
1 ms |
768 KB |
Output is correct |
10 |
Correct |
0 ms |
776 KB |
Output is correct |
11 |
Incorrect |
328 ms |
688 KB |
Wrong query response. |
12 |
Halted |
0 ms |
0 KB |
- |