QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#110126 | #6528. Sequence | chenshi | 7 | 838ms | 97060kb | C++ | 2.0kb | 2023-05-31 17:55:32 | 2023-05-31 17:55:34 |
Judging History
answer
#include "sequence.h"
#include<bits/stdc++.h>
using namespace std;
struct segmenttree{
int n,e;function<int(int,int)> op;vector<int> v,flg;
segmenttree(int n_,int e_,function<int(int,int)> op_,int coef):n(n_),e(e_),op(op_),v((n_+1)*4),flg((n_+1)*4){
function<void(int,int,int)> build=[&](int id,int l,int r){
if(l==r){v[id]=coef*l;return;}
int md=l+r>>1;
build(id<<1,l,md);build((id<<1)|1,md+1,r);
v[id]=op(v[id<<1],v[(id<<1)|1]);
};
build(1,0,n);
}
inline void ad(int id,int val){v[id]+=val;flg[id]+=val;}
inline void pushdown(int id){if(flg[id]) ad(id<<1,flg[id]),ad((id<<1)|1,flg[id]),flg[id]=0;}
void modify(int id,int ql,int qr,int val,int l,int r){
if(ql<=l&&r<=qr){ad(id,val);return;}
pushdown(id);
int md=l+r>>1;
if(ql<=md) modify(id<<1,ql,qr,val,l,md);
if(md<qr) modify((id<<1)|1,ql,qr,val,md+1,r);
v[id]=op(v[id<<1],v[(id<<1)|1]);
}
int query(int id,int ql,int qr,int l,int r){
if(ql<=l&&r<=qr) return v[id];
pushdown(id);
int md=l+r>>1;
return op((ql<=md)?query(id<<1,ql,qr,l,md):e,(md<qr)?query((id<<1)|1,ql,qr,md+1,r):e);
}
void modify(int ql,int qr,int val){modify(1,ql,qr,val,0,n);}
int query(int ql,int qr){return query(1,ql,qr,0,n);}
};
const int inf=1e6;
int sequence(int n,vector<int> a){
vector<vector<int>> vec(n+1);int res=1;
for(int i=0;i<n;++i) vec[a[i]].push_back(i+1);
segmenttree T1(n,inf,[](int a,int b){return a<b?a:b;},1),T2(n,inf,[](int a,int b){return a<b?a:b;},-1);
segmenttree T3(n,-1,[](int a,int b){return a>b?a:b;},1),T4(n,-1,[](int a,int b){return a>b?a:b;},-1);
for(int i=1;i<=n;++i){
for(auto p:vec[i]) T2.modify(p,n,2),T4.modify(p,n,2);
auto chk=[&](int l,int r){
return l>r||(T3.query(vec[i][r],n)>=T1.query(0,vec[i][l]-1)&&T4.query(vec[i][r],n)>=T2.query(0,vec[i][l]-1));
};
for(int sz=vec[i].size(),l=0,r=0;l<sz;res=max(res,r-l+1),++l) for(;r+1<sz&&chk(l,r+1);++r);
for(auto p:vec[i]) T1.modify(p,n,-2),T3.modify(p,n,-2);
}
return res;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 11
Accepted
time: 1ms
memory: 3728kb
input:
8wq90di9812978rqwiok0k0o21klklm21oiwi121 98 92 89 9 86 80 6 42 20 84 82 46 56 52 30 44 39 35 82 57 33 18 38 32 63 27 55 33 44 41 39 62 26 46 59 21 85 36 60 7 36 50 22 87 83 71 27 4 3 87 47 17 62 70 24 9 20 81 21 57 50 13 32 68 70 11 95 5 56 64 90 47 42 44 72 71 46 84 72 56 63 37 35 80 78 4 54 74 79 ...
output:
nfp39szm23aa01pcmyosi03slwpeksnfjri3opqp OK 3
result:
ok
Test #2:
score: -11
Wrong Answer
time: 2ms
memory: 3732kb
input:
8wq90di9812978rqwiok0k0o21klklm21oiwi121 96 1 6 1 4 6 2 5 1 1 2 8 2 4 4 1 9 8 9 8 5 3 6 6 4 9 4 2 8 8 8 2 9 1 3 6 6 1 6 5 5 3 7 9 7 1 8 5 6 8 5 1 1 4 9 6 7 2 6 6 7 4 2 2 8 5 6 4 8 2 6 5 8 6 1 6 2 1 3 4 6 3 6 8 2 5 7 8 2 4 1 5 6 2 3 6 6
output:
nfp39szm23aa01pcmyosi03slwpeksnfjri3opqp OK 20
result:
wrong answer 1st lines differ - on the 1st token, expected: '18', found: '20'
Subtask #2:
score: 0
Skipped
Dependency #1:
0%
Subtask #3:
score: 7
Accepted
Test #20:
score: 7
Accepted
time: 651ms
memory: 91248kb
input:
8wq90di9812978rqwiok0k0o21klklm21oiwi121 499996 53 78 81 111 119 124 126 130 164 175 219 227 233 249 282 298 332 341 348 436 437 448 452 455 462 465 495 535 557 558 576 600 620 627 632 642 643 659 695 696 713 730 743 805 816 865 869 872 875 882 883 902 924 937 990 998 1025 1092 1137 1145 1166 1176 1...
output:
nfp39szm23aa01pcmyosi03slwpeksnfjri3opqp OK 8
result:
ok
Test #21:
score: 0
Accepted
time: 681ms
memory: 91188kb
input:
8wq90di9812978rqwiok0k0o21klklm21oiwi121 499996 5 7 11 19 19 19 19 23 23 27 29 31 32 33 34 37 37 40 45 49 53 57 67 69 70 76 79 80 82 82 84 89 91 96 105 109 109 109 110 111 112 113 116 119 120 121 122 129 133 135 136 142 145 147 148 151 155 160 161 162 162 171 174 177 178 179 180 181 185 189 191 192 ...
output:
nfp39szm23aa01pcmyosi03slwpeksnfjri3opqp OK 9
result:
ok
Test #22:
score: 0
Accepted
time: 799ms
memory: 83444kb
input:
8wq90di9812978rqwiok0k0o21klklm21oiwi121 500000 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...
output:
nfp39szm23aa01pcmyosi03slwpeksnfjri3opqp OK 100281
result:
ok
Test #23:
score: 0
Accepted
time: 701ms
memory: 90384kb
input:
8wq90di9812978rqwiok0k0o21klklm21oiwi121 500000 1 7 8 11 15 17 18 19 19 20 22 24 29 33 33 35 37 39 46 47 48 49 49 49 52 54 57 60 60 62 62 63 68 70 71 72 72 78 79 79 85 86 86 92 94 94 97 99 100 100 106 108 110 114 116 118 119 122 125 127 128 133 133 134 136 137 144 144 145 148 152 153 153 153 160 161...
output:
nfp39szm23aa01pcmyosi03slwpeksnfjri3opqp OK 9
result:
ok
Test #24:
score: 0
Accepted
time: 648ms
memory: 90112kb
input:
8wq90di9812978rqwiok0k0o21klklm21oiwi121 499996 18 24 36 39 56 61 85 128 159 164 225 240 252 254 258 263 313 365 387 387 396 439 443 476 481 489 509 526 547 582 583 584 631 635 645 673 679 699 709 724 728 731 741 757 768 785 785 817 827 828 834 836 846 851 858 864 892 900 908 920 920 922 929 962 989...
output:
nfp39szm23aa01pcmyosi03slwpeksnfjri3opqp OK 11
result:
ok
Test #25:
score: 0
Accepted
time: 737ms
memory: 83916kb
input:
8wq90di9812978rqwiok0k0o21klklm21oiwi121 499996 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...
output:
nfp39szm23aa01pcmyosi03slwpeksnfjri3opqp OK 8818
result:
ok
Test #26:
score: 0
Accepted
time: 761ms
memory: 83992kb
input:
8wq90di9812978rqwiok0k0o21klklm21oiwi121 500000 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...
output:
nfp39szm23aa01pcmyosi03slwpeksnfjri3opqp OK 7068
result:
ok
Test #27:
score: 0
Accepted
time: 709ms
memory: 83348kb
input:
8wq90di9812978rqwiok0k0o21klklm21oiwi121 499998 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...
output:
nfp39szm23aa01pcmyosi03slwpeksnfjri3opqp OK 176759
result:
ok
Subtask #4:
score: 0
Wrong Answer
Test #28:
score: 12
Accepted
time: 705ms
memory: 83668kb
input:
8wq90di9812978rqwiok0k0o21klklm21oiwi121 499999 2 1 2 2 2 1 2 3 1 3 1 2 2 1 2 1 1 2 1 1 2 1 1 2 1 2 1 1 1 1 1 2 2 1 1 2 1 1 1 2 1 2 1 1 1 2 3 3 3 3 1 3 1 2 2 1 1 1 3 1 3 1 1 2 1 2 2 2 1 3 2 1 1 1 2 2 1 2 2 3 1 2 2 1 2 2 1 1 2 1 1 2 2 1 2 2 1 1 1 1 2 2 1 1 1 1 1 2 1 1 2 1 1 3 2 1 1 1 3 1 1 2 1 3 1 1 ...
output:
nfp39szm23aa01pcmyosi03slwpeksnfjri3opqp OK 277713
result:
ok
Test #29:
score: -12
Wrong Answer
time: 705ms
memory: 83340kb
input:
8wq90di9812978rqwiok0k0o21klklm21oiwi121 499999 2 3 1 3 3 3 1 2 3 3 3 2 2 1 1 3 1 2 1 3 3 3 2 2 2 2 3 3 2 2 2 1 1 2 3 3 1 3 1 1 2 3 3 1 1 1 2 1 1 1 2 3 2 2 1 2 1 1 3 1 1 1 3 1 1 2 1 3 2 3 1 3 1 3 3 2 1 3 1 2 1 3 2 1 1 2 3 1 2 1 3 3 1 2 1 3 3 3 2 3 2 1 1 2 1 2 3 1 1 2 2 1 3 2 3 2 3 2 2 1 3 2 3 1 3 3 ...
output:
nfp39szm23aa01pcmyosi03slwpeksnfjri3opqp OK 167381
result:
wrong answer 1st lines differ - on the 1st token, expected: '166105', found: '167381'
Subtask #5:
score: 0
Wrong Answer
Test #33:
score: 0
Wrong Answer
time: 838ms
memory: 97060kb
input:
8wq90di9812978rqwiok0k0o21klklm21oiwi121 499999 490225 471440 499001 369862 494577 479599 486292 476071 471988 486939 482356 482290 497141 488452 495446 494292 404798 493826 482595 481107 447196 477441 418064 495941 448927 483365 418585 489220 443224 482574 487957 467944 493253 472016 475543 442250 ...
output:
nfp39szm23aa01pcmyosi03slwpeksnfjri3opqp OK 2
result:
wrong answer 1st lines differ - on the 1st token, expected: '1', found: '2'
Subtask #6:
score: 0
Skipped
Dependency #2:
0%
Subtask #7:
score: 0
Skipped
Dependency #1:
0%