QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#718904 | #8546. Min or Max 2 | Zaunese | WA | 606ms | 29484kb | C++14 | 2.0kb | 2024-11-06 21:44:33 | 2024-11-06 21:44:33 |
Judging History
answer
// ? ? ? ? -? ? ? ?? ??!
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<tuple>
#define fi first
#define se second
#define mkp std::make_pair
using ll=long long;
using std::max;
using std::min;
template<class T> void cmax(T&a,T b){a=max(a,b);}
template<class T> void cmin(T&a,T b){a=min(a,b);}
const int NV=5e5;
namespace seg{
const int N=1<<19;
struct SEGN{
int a[3];
} tr[N*2];
const SEGN I[3]={{0,0,1},{0,1,1},{1,1,2}};
SEGN operator+(SEGN u,SEGN v){return {v.a[u.a[0]],v.a[u.a[1]],v.a[u.a[2]]};}
void init(){std::fill(tr,tr+N*2,SEGN{0,1,2});}
void upd(int x,SEGN z){
for(tr[x+=N]=z,x/=2;x;x/=2)
tr[x]=tr[x<<1]+tr[x<<1|1];
}
}
namespace xm{
int N,X,Y,a[NV+5],b[NV+5],pa[NV+5],pb[NV+5],mx[NV+5],\
l[NV+5],r[NV+5],ans[NV+5];
void ins(int x){
if(x>1) seg::upd(x,seg::I[(a[x]>X)+(b[x]<Y)]);
}void slv(){
X=0;
Y=1;
for(int i=1;i<=N;++i) pa[a[i]]=pb[b[i]]=i;
for(int i=2;i<=N;++i) ins(i);
for(X=1;X<=N;++X){
ins(pa[X]);
while(Y<=N&&!seg::tr[1].a[(a[1]>X)+(b[1]<Y)]){
++Y;
ins(pb[Y-1]);
}
mx[X]=Y-1;
}
for(int i=2;i<=N;++i) seg::upd(i,seg::SEGN{0,1,2});
}void _(){
scanf("%d",&N);
std::fill(ans,ans+2*N+1,0);
for(int i=1;i<=N;++i) scanf("%d",a+i);
for(int i=1;i<=N;++i) scanf("%d",b+i);
slv();
for(int i=1;i<=N;++i){
a[i]=N-a[i]+1;
b[i]=N-b[i]+1;
r[i]=mx[i];
}
slv();
for(int i=1;i<=N;++i) l[N-i+1]=N-mx[i]+1;
for(int i=1;i<=N;++i){
++ans[l[i]-i+N];
--ans[r[i]-i+N+1];
}
for(int i=1;i<=N*2;++i) ans[i]+=ans[i-1];
printf("%d ",ans[N]);
for(int i=1;i<N;++i) printf("%d ",ans[N-i]+ans[N+i]);
puts("");
}
}
int main(){
int t;
seg::init();
scanf("%d",&t);
while(t--) xm::_();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 29288kb
input:
4 2 1 2 2 1 5 2 4 1 5 3 2 4 1 5 3 5 1 2 3 4 5 5 4 3 2 1 8 5 8 3 4 2 7 1 6 4 6 3 8 5 1 2 7
output:
2 0 5 0 0 0 0 2 2 2 2 0 5 5 2 2 1 0 0 0
result:
ok 20 numbers
Test #2:
score: 0
Accepted
time: 302ms
memory: 27948kb
input:
66664 7 4 2 6 5 7 1 3 6 5 3 1 4 7 2 10 6 8 10 7 5 1 4 3 9 2 5 10 3 8 6 7 2 9 1 4 9 3 2 4 8 7 6 9 1 5 8 1 2 9 6 7 4 3 5 10 4 3 9 6 7 2 10 1 8 5 3 5 4 1 2 7 10 9 6 8 5 3 4 1 2 5 5 1 3 2 4 5 2 4 3 5 1 2 3 1 4 5 6 2 6 1 3 4 5 6 4 5 1 3 2 10 10 1 2 7 5 8 4 3 9 6 9 4 2 3 6 1 7 8 5 10 5 1 2 4 5 3 4 1 2 5 3...
output:
4 4 2 2 1 0 0 5 6 3 2 2 1 0 0 0 0 5 6 3 2 1 0 0 0 0 4 4 4 3 2 1 0 0 0 0 5 3 0 0 0 2 2 2 2 0 3 3 3 1 0 0 5 7 4 2 1 0 0 0 0 0 5 2 0 0 0 6 3 0 0 0 0 3 3 2 0 0 5 4 2 1 0 0 0 3 2 3 1 0 0 4 6 3 0 0 0 0 3 4 3 2 1 0 0 3 2 2 2 2 2 2 1 0 4 5 3 1 0 0 0 3 4 3 2 3 3 1 0 0 0 8 5 0 0 0 0 0 0 7 8...
result:
ok 499999 numbers
Test #3:
score: 0
Accepted
time: 286ms
memory: 28628kb
input:
6690 72 31 50 47 60 24 33 72 49 5 26 17 65 40 64 8 2 19 51 30 58 71 16 66 56 9 48 21 61 44 59 22 11 15 28 68 29 1 27 37 41 23 6 20 62 43 34 18 4 70 54 13 12 36 35 25 67 45 38 69 53 42 63 55 3 14 7 57 32 52 39 10 46 31 9 7 56 32 64 39 33 62 24 49 54 18 53 43 40 4 28 37 2 61 47 10 26 23 16 22 30 11 60...
output:
7 11 7 5 6 6 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 3 2 2 2 3 4 4 4 4 4 3 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 4 6 6 4 4 3 2 2 2 2 2 2 2 2 2 3 4 4 4 4 4 3 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 4 6 6 7 8 7 6 7 8 8 7 5 4 4 3 2 2 2...
result:
ok 499981 numbers
Test #4:
score: 0
Accepted
time: 289ms
memory: 27932kb
input:
666 775 98 357 198 407 409 200 454 585 319 622 366 264 710 91 765 78 32 528 335 101 469 204 312 382 276 613 231 342 327 324 441 544 413 299 494 393 349 611 211 702 165 297 320 284 401 530 317 567 142 742 447 482 662 126 506 273 362 328 555 416 206 604 589 305 99 114 291 131 386 75 670 280 704 189 43...
output:
11 20 20 20 19 18 18 18 18 18 18 18 18 18 18 18 18 17 16 16 16 16 16 16 16 16 16 16 16 16 16 15 14 14 14 14 13 12 12 12 12 12 12 12 12 11 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 9 8 8 8 8 7 6 6 6 6 6 6 6 6 6 6 6 6 ...
result:
ok 500000 numbers
Test #5:
score: 0
Accepted
time: 295ms
memory: 29484kb
input:
65 9836 5216 2035 5946 2744 9708 9116 1184 2000 4650 569 2428 585 3406 8146 6809 875 9131 9092 5998 2088 8393 9447 7766 4990 3903 7730 3426 6726 2029 4208 1546 4639 997 1428 2357 8630 7552 3531 7241 3530 4548 7310 3205 3508 9764 8929 4781 5702 3777 670 7384 1049 1707 4544 1637 9349 2427 3338 634 596...
output:
8 13 12 11 10 10 10 10 10 11 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 10 8 8 8 8 8 8 8 8 8 7 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6...
result:
ok 500000 numbers
Test #6:
score: 0
Accepted
time: 323ms
memory: 28552kb
input:
10 50000 41908 17741 2708 24703 42556 45152 20315 17143 16957 48829 30280 7534 9806 2455 27752 28698 34180 30641 1976 19099 8271 18233 1745 46600 1241 19569 3867 840 10336 49514 49491 43521 26857 2277 9054 3016 41237 15468 48237 37950 17442 44525 46971 40928 34005 15252 14887 48465 26039 13079 40736...
output:
14 26 24 23 22 20 19 18 18 18 18 18 18 18 18 17 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 ...
result:
ok 500000 numbers
Test #7:
score: 0
Accepted
time: 407ms
memory: 28728kb
input:
5 100000 70435 82297 64478 96762 51480 50092 4607 731 51337 24967 98580 69079 26300 41515 57826 4744 92883 9657 3287 12443 17262 15832 41138 53280 53542 76263 69136 64644 83006 75161 76406 36134 88895 42403 28621 24815 35829 8899 38986 16475 15367 82413 56456 17355 21826 58017 2762 62100 53594 63010...
output:
18 35 35 34 32 30 29 28 28 28 27 26 25 24 24 24 24 24 23 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 ...
result:
ok 500000 numbers
Test #8:
score: -100
Wrong Answer
time: 606ms
memory: 29440kb
input:
1 500000 288678 283027 462112 250066 400523 251310 197889 338696 246896 186409 257754 49529 168322 411341 237155 355566 411724 493312 55378 447538 212152 404975 126509 127651 69151 318513 199941 486793 15909 363053 288273 492124 313983 118718 165238 332535 415290 337782 365660 206063 123709 273038 4...
output:
9 16 18 19 18 18 17 16 16 17 18 19 20 23 26 29 32 37 42 47 52 57 62 67 72 77 82 87 92 97 102 107 112 117 122 127 132 137 142 147 152 157 162 167 172 177 182 187 192 197 202 207 212 217 222 227 232 237 242 247 252 257 262 267 271 275 280 285 290 295 300 305 310 315 320 325 330 335 340 345 350 355 360...
result:
wrong answer 10th numbers differ - expected: '16', found: '17'