QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#113958 | #1139. Stations | CharlieVinnie | 0 | 0ms | 0kb | C++17 | 1.3kb | 2023-06-20 11:11:54 | 2023-06-20 11:11:55 |
Judging History
stations
#include<bits/stdc++.h>
#include "stations.h"
using namespace std;
const int N=5005;
struct edge{
int to,nxt;
}e[N<<1];
int hd[N],ct,dt,dfn[N],d[N];
inline void add(int u,int v){
e[++ct]=(edge){v,hd[u]};hd[u]=ct;
e[++ct]=(edge){u,hd[v]};hd[v]=ct;
}
void ch(int u,int fa){
d[u]=d[fa]+1;
if(d[u]&1) dfn[u]=++dt;
for(int i=hd[u],v;i;i=e[i].nxt){
v=e[i].to;
if(v==fa) continue;
ch(v,u);
}
if(!(d[u]&1)) dfn[u]=++dt;
}
vector<int> label(int n,int k,vector<int> U,vector<int> V){
vector<int> labels(n);
ct=dt=0;memset(hd,0,(n+1)<<2);
for(int i=0;i<n-1;i++) add(U[i],V[i]);
ch(0,0);
for(int i=0;i<n;i++) labels[i]=dfn[i]-1;
return labels;
}
inline int max(vector<int> c){
return *max_element(c.begin(),c.end());
}
inline int min(vector<int> c){
return *min_element(c.begin(),c.end());
}
int find_next_station(int s,int t,vector<int> c){
if(s>max(c)){
int mi=s?min(c):-1;
vector<int> o;
for(int u:c) if(u!=mi) o.push_back(u);
if(t>s||t<min(o)) return mi;
sort(o.begin(),o.end());
return *prev(upper_bound(o.begin(),o.end(),t));
}
else{
int mx=s?max(c):1e9;
vector<int> o;
for(int u:c) if(u!=mx) o.push_back(u);
if(t<s||t>max(o)) return mx;
sort(o.begin(),o.end());
return *lower_bound(o.begin(),o.end(),t);
}
}
详细
Subtask #1:
score: 0
Stage 2: Program stations Runtime Error
Test #1:
score: 0
Stage 2: Program stations Runtime Error
input:
10 10 1000 4 5 9 0 2 6 5 2 8 3 1 4 8 1 6 0 3 7 5575 4 6 5 7 3 3 6 0 0 8 5 1 7 1 3 0 4 6 0 5 6 0 8 6 1 6 4 4 5 5 4 8 1 4 3 1 8 9 1 4 8 1 2 7 5 4 6 5 6 9 0 6 9 0 8 0 1 7 2 3 1 0 4 1 8 8 7 2 3 6 8 2 6 8 2 9 6 0 6 0 0 0 9 9 2 5 5 9 6 0 2 0 6 0 9 9 2 9 6 3 6 8 2 0 6 0 1 6 5 8 4 1 2 4 1 6 4 3 6 8 6 4 2 0 ...
output:
10 0 6 1 5 2 7 8 4 3 9 3 2 0 1 998 0 777 971 894 145 299 706 704 822 831 724 624 848 495 195 855 665 26 231 629 457 599 108 545 92 534 250 372 300 51 992 469 488 538 379 719 118 942 314 435 761 885 735 900 48 407 11 941 702 130 595 958 434 177 183 437 886 820 756 125 789 330 949 767 809 868 850 970 ...
input:
output:
result:
Subtask #2:
score: 0
Stage 2: Program stations Runtime Error
Test #11:
score: 0
Stage 2: Program stations Runtime Error
input:
10 996 1000 0 1 2 0 1 3 4 1 5 2 6 2 7 3 3 8 4 9 10 4 11 5 12 5 6 13 14 6 7 15 7 16 17 8 18 8 19 9 9 20 21 10 10 22 23 11 24 11 12 25 26 12 27 13 13 28 14 29 30 14 15 31 15 32 16 33 34 16 35 17 17 36 18 37 38 18 39 19 40 19 41 20 42 20 43 21 44 21 45 22 46 22 23 47 48 23 49 24 24 50 25 51 52 25 26 53...
output:
996 0 995 484 740 485 229 1 994 867 739 612 483 356 228 101 931 868 804 741 676 613 549 486 420 357 293 230 165 102 38 2 993 962 930 899 866 835 803 772 738 707 675 644 611 580 548 517 482 451 419 388 355 324 292 261 227 196 164 133 100 69 37 17 978 963 947 932 915 900 884 869 851 836 820 805 788 77...
input:
output:
result:
Subtask #3:
score: 0
Stage 2: Program stations Runtime Error
Test #17:
score: 0
Stage 2: Program stations Runtime Error
input:
10 2 1000000 1 0 10000 1 0 0 1 0 0 0 1 1 1 0 0 0 1 1 0 1 1 1 0 0 0 1 1 1 0 0 1 0 0 0 1 1 0 1 1 0 1 1 1 0 0 1 0 0 0 1 1 1 0 0 1 0 0 0 1 1 1 0 0 0 1 1 1 0 0 0 1 1 0 1 1 1 0 0 0 1 1 0 1 1 1 0 0 1 0 0 1 0 0 0 1 1 1 0 0 1 0 0 1 0 0 0 1 1 1 0 0 1 0 0 0 1 1 0 1 1 1 0 0 0 1 1 1 0 0 1 0 0 0 1 1 1 0 0 0 1 1 1...
output:
2 0 1 997 996 258 346 707 168 846 395 278 806 978 462 939 11 681 754 768 36 8 155 91 213 375 905 351 910 53 661 602 686 332 119 985 170 826 435 320 798 883 955 643 43 211 694 250 202 702 536 517 385 918 860 940 847 631 845 629 41 597 437 490 703 712 690 564 139 100 308 73 596 450 995 710 975 565 991...
input:
output:
result:
Subtask #4:
score: 0
Stage 2: Program stations Runtime Error
Test #34:
score: 0
Stage 2: Program stations Runtime Error
input:
10 2 1000000000 0 1 10000 0 1 1 1 0 0 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 1 0 0 0 1 1 0 1 1 1 0 0 1 0 0 0 1 1 1 0 0 0 1 1 1 0 0 1 0 0 0 1 1 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 0 1 1 1 0 0 0 1 1 1 0 0 1 0 0 1 0 0 0 1 1 0 1 1 0 1 1 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 0 1 1 1 0 0 0 1 1 1 0 0 1 0 0 0 1 ...
output:
2 0 1 2 1 0 2 0 1 2 1 0 2 0 1 2 1 0 2 0 1 2 1 0 2 0 1 2 1 0
input:
output:
result:
Subtask #5:
score: 0
Stage 2: Program stations Runtime Error
Test #54:
score: 0
Stage 2: Program stations Runtime Error
input:
10 3 1000000000 1 0 2 1 7507 1 2 2 2 0 1 1 2 2 1 2 2 1 2 2 0 2 1 0 2 1 2 1 1 2 1 1 0 2 1 1 0 0 1 0 0 1 0 0 2 0 1 1 0 0 0 1 1 0 1 1 0 2 1 2 0 1 2 0 1 2 0 1 0 2 1 2 0 1 1 0 0 2 0 1 0 1 1 2 0 1 1 2 2 2 0 1 0 2 1 0 2 1 0 2 1 0 2 1 2 0 1 0 1 1 2 0 1 0 1 1 0 2 1 0 2 1 2 0 1 2 0 1 1 2 2 0 2 1 2 0 1 2 0 1 2...
output:
3 0 2 1 998 997 728 56 255 358 927 213 429 6 632 906 553 16 538 580 338 910 933 435 971 703 838 272 178 185 966 886 372 80 215 27 371 208 306 627 767 676 536 296 39 991 646 415 328 169 618 426 504 768 839 757 959 682 970 792 748 509 165 818 798 86 568 669 549 721 960 211 491 616 303 989 807 376 340 ...