QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#308233 | #5425. Proposition Composition | huzhaoyang | AC ✓ | 348ms | 27332kb | C++14 | 3.1kb | 2024-01-19 19:27:13 | 2024-01-19 19:27:13 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define L (k<<1)
#define R (L|1)
#define mid (l+r>>1)
typedef long long ll;
typedef pair<int,int> pii;
const int N=250005;
int t,n,m,s,x,y,id[N],pre[N],nex[N],sz[N],fl[N<<2],fr[N<<2];
ll ans;
vector<int>vl,vr;
set<int>S0,S1;
set<int>::iterator it;
bool cmp(int x,int y){
return id[x]<id[y];
}
ll C(int n){
return (ll)n*(n-1)/2;
}
void update(int k,int l,int r,int x){
if (l==r){
fl[k]=pre[x],fr[k]=nex[x];
return;
}
if (x<=mid)update(L,l,mid,x);
else update(R,mid+1,r,x);
fl[k]=min(fl[L],fl[R]),fr[k]=max(fr[L],fr[R]);
}
void query(int k,int l,int r,int x,int y){
if ((l>y)||(x>r)||(fl[k]>=x)&&(fr[k]<=y))return;
if (l==r){
if (fl[k]<x)vl.push_back(l),fl[k]=n;
if (fr[k]>y)vr.push_back(l),fr[k]=0;
return;
}
query(L,l,mid,x,y),query(R,mid+1,r,x,y);
fl[k]=min(fl[L],fl[R]),fr[k]=max(fr[L],fr[R]);
}
void split(int x){
int k=id[x],y=nex[x];
nex[x]=0,pre[y]=n;
update(1,1,n-1,x),update(1,1,n-1,y);
int a=x,b=y;
while ((a<n)&&(b))a=pre[a],b=nex[b];
sz[++s]=0;
if (a==n){
for(int i=x;i<n;i=pre[i])id[i]=s,sz[s]++;
}
else{
for(int i=y;i;i=nex[i])id[i]=s,sz[s]++;
}
ans-=C(sz[k]),sz[k]-=sz[s],ans+=C(sz[k])+C(sz[s]);
}
void split(int x,int y){
int k=id[x],l=pre[x],r=nex[y];
nex[l]=r,pre[r]=l,pre[x]=n,nex[y]=0;
update(1,1,n-1,l),update(1,1,n-1,r);
int a=l,b=x,c=r;
while ((a<n)&&(b))a=pre[a],b=nex[b];
while ((b)&&(c))b=nex[b],c=nex[c];
sz[++s]=0;
if (!b){
for(int i=x;i;i=nex[i])id[i]=s,sz[s]++;
}
else{
for(int i=l;i<n;i=pre[i])id[i]=s,sz[s]++;
for(int i=r;i;i=nex[i])id[i]=s,sz[s]++;
}
ans-=C(sz[k]),sz[k]-=sz[s],ans+=C(sz[k])+C(sz[s]);
}
int main(){
scanf("%d",&t);
while (t--){
scanf("%d%d",&n,&m);
s=0,S0.clear(),S1.clear();
for(int i=1;i<n;i++)S0.insert(i);
for(int i=1;i<n;i++){
id[i]=0;
pre[i]=(i==1 ? n : i-1);
nex[i]=(i==n-1 ? 0 : i+1);
}
sz[0]=n-1,ans=C(n-1);
for(int i=1;i<n;i++)update(1,1,n-1,i);
for(int i=1;i<=m;i++){
scanf("%d%d",&x,&y);
if (x>y)swap(x,y);
for(it=S1.lower_bound(x);(it!=S1.end())&&((*it)<y);)it=S1.erase(it);
for(it=S0.lower_bound(x);(it!=S0.end())&&((*it)<y);){
S1.insert(*it);
it=S0.erase(it);
}
vl.clear(),vr.clear();
query(1,1,n-1,x,y-1);
sort(vl.begin(),vl.end(),cmp);
sort(vr.begin(),vr.end(),cmp);
for(int x=0,y=0;(x<vl.size())||(y<vr.size());){
if ((x<vl.size())&&(y<vr.size())&&(id[vl[x]]==id[vr[y]]))split(vl[x++],vr[y++]);
else{
if ((x<vl.size())&&((y==vr.size())||(id[vl[x]]<id[vr[y]])))split(pre[vl[x++]]);
else split(vr[y++]);
}
}
printf("%lld\n",(ll)S0.size()*(n+i-S0.size()-1)+S1.size()+ans);
}
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 7980kb
input:
3 4 3 2 4 4 2 3 3 7 3 3 4 1 2 1 7 6 4 1 3 4 6 2 5 3 4
output:
6 5 6 21 24 10 15 12 3 2
result:
ok 10 numbers
Test #2:
score: 0
Accepted
time: 64ms
memory: 9936kb
input:
45540 10 9 10 1 1 10 10 1 1 10 1 10 10 1 1 10 3 3 10 1 10 4 1 2 1 10 3 4 1 10 7 6 7 1 5 6 1 7 6 6 7 1 6 7 9 7 3 3 7 7 5 4 1 1 9 1 9 1 6 5 8 7 1 8 4 4 5 6 1 1 1 8 6 6 4 5 3 3 3 2 3 1 3 3 3 9 3 1 3 3 2 2 3 3 3 1 2 2 1 1 2 3 3 1 10 1 2 1 7 1 1 7 3 8 1 3 1 3 3 3 1 3 2 2 1 3 1 3 3 3 3 6 3 1 1 3 1 3 1 3 1...
output:
45 36 36 36 36 36 36 36 36 45 36 28 21 21 15 10 10 10 6 36 44 50 57 28 21 15 28 28 21 21 15 15 10 3 1 1 3 3 3 3 1 1 1 0 0 45 21 3 1 1 1 1 1 1 1 3 1 1 1 1 1 45 36 36 36 36 36 36 36 3 3 1 0 0 0 0 0 0 3 1 0 0 15 10 10 0 0 0 0 0 0 0 0 28 34 21 6 6 6 6 1 0 0 21 15 15 0 0 0 0 0 0 0 45 53 0 0 0 0 0 0 0 0 1...
result:
ok 249586 numbers
Test #3:
score: 0
Accepted
time: 83ms
memory: 7968kb
input:
2507 86 4 41 41 36 36 31 30 86 1 110 22 1 110 110 1 11 11 110 1 110 1 110 1 1 110 107 106 72 72 106 106 74 74 1 110 110 1 58 58 110 1 110 1 1 110 101 100 110 1 100 100 110 1 8 7 114 180 114 1 114 1 114 1 1 114 1 114 114 1 37 38 49 48 105 106 1 114 90 90 1 114 9 9 114 1 67 68 20 20 114 1 1 114 54 55 ...
output:
3655 3740 3823 3570 5995 5886 5886 5886 5886 5886 5886 5778 5778 5778 5778 5778 5778 5778 5778 5778 5778 5671 5671 5671 5671 5565 6441 6328 6328 6328 6328 6328 6216 6105 5995 5995 5995 5995 5995 5995 5886 5886 5886 5886 5778 5671 5671 5565 5565 5460 5460 5460 5460 5460 5356 5253 5253 5253 5151 5151 ...
result:
ok 249877 numbers
Test #4:
score: 0
Accepted
time: 122ms
memory: 15232kb
input:
3 82425 27858 30801 30802 1 82425 73850 73850 1 82425 65949 65949 82425 1 76026 76025 61936 61936 82425 1 82425 1 82425 1 6504 6504 82425 1 25155 25156 79743 79743 1 82425 69406 69406 29247 29247 18351 18351 23171 23170 29704 29703 82425 1 1 82425 82425 1 74918 74917 22395 22394 893 894 82425 1 391 ...
output:
3396899100 3396816676 3396816676 3396734253 3396734253 3396734253 3396651831 3396651831 3396651831 3396651831 3396651831 3396651831 3396651831 3396569410 3396569410 3396569410 3396569410 3396569410 3396569410 3396486990 3396404571 3396404571 3396404571 3396404571 3396322153 3396239736 3396157320 339...
result:
ok 116748 numbers
Test #5:
score: 0
Accepted
time: 200ms
memory: 27304kb
input:
1 250000 250000 248617 248617 1 250000 47808 47809 1 250000 1 250000 110493 110494 1 250000 66675 66676 141326 141327 250000 1 115279 115280 193218 193219 250000 1 77714 77715 1 250000 1 250000 212943 212943 223061 223060 1 250000 250000 1 1 250000 71059 71059 1 250000 246523 246522 1 250000 88700 8...
output:
31249875000 31249875000 31249625001 31249375003 31249375003 31249125006 31249125006 31248875010 31248625015 31248625015 31248375021 31248125028 31248125028 31247875036 31247875036 31247875036 31247875036 31247625045 31247625045 31247625045 31247625045 31247625045 31247625045 31247375055 31247375055 ...
result:
ok 250000 numbers
Test #6:
score: 0
Accepted
time: 71ms
memory: 10000kb
input:
45364 9 7 1 8 9 8 8 9 8 2 9 8 2 8 4 2 10 2 2 10 1 10 10 7 8 9 4 4 10 10 1 10 2 9 9 1 6 8 6 7 6 2 5 1 1 5 5 5 1 5 2 3 5 1 10 1 2 10 9 6 1 8 2 9 2 1 9 8 2 8 8 1 1 4 1 1 1 1 1 1 1 1 8 1 2 2 3 7 3 2 2 2 3 1 2 3 2 3 3 3 3 3 5 1 4 2 3 9 3 1 1 2 1 2 2 1 2 1 1 1 3 2 2 2 3 2 3 2 3 1 3 2 3 6 3 1 2 2 2 2 1 3 3...
output:
36 29 28 16 16 16 8 45 29 45 53 61 36 18 16 8 15 5 4 4 4 2 2 45 36 17 16 15 15 15 0 0 0 0 28 3 4 1 1 1 1 1 10 3 1 1 1 1 1 0 0 0 3 1 3 3 3 1 0 0 6 36 30 12 8 8 3 4 5 5 1 0 0 0 0 0 6 5 6 1 0 0 0 0 0 0 28 32 19 20 11 7 7 21 17 17 12 4 3 2 1 1 21 11 7 6 3 3 1 2 1 1 28 25 20 21 22 22 23 11 1 1 28 1 1 0 0...
result:
ok 249141 numbers
Test #7:
score: 0
Accepted
time: 86ms
memory: 10028kb
input:
2517 14 35 2 13 14 1 14 14 1 14 7 7 1 14 7 7 2 14 9 11 2 4 2 13 11 12 14 2 13 1 14 1 13 2 12 11 2 14 1 13 12 11 1 14 4 5 2 14 14 14 13 13 10 9 14 2 1 14 14 2 13 2 14 2 7 8 6 6 1 1 13 1 51 125 30 30 40 39 25 24 51 1 1 51 40 40 8 7 50 2 2 50 7 9 50 1 30 30 47 49 14 16 2 4 1 51 1 50 6 6 1 51 4 4 50 2 2...
output:
91 58 58 56 56 56 56 55 37 23 23 17 17 17 17 17 17 17 17 17 17 12 12 12 12 11 11 11 11 11 11 7 7 7 7 1275 1324 1370 1176 1128 1128 1081 991 991 947 946 946 862 782 706 706 706 706 706 706 706 706 706 668 598 598 598 598 532 532 532 532 532 532 532 500 469 469 469 469 411 383 383 383 331 331 331 331 ...
result:
ok 250000 numbers
Test #8:
score: 0
Accepted
time: 88ms
memory: 18692kb
input:
5 65849 4012 8907 8905 21927 21927 2 65849 2 65848 65849 1 1 65849 48863 48861 2 65849 7795 7795 65849 2 2 65849 65849 2 2696 2695 65848 2 41766 41765 2 65849 36403 36403 65849 2 32613 32613 26782 26781 60024 60024 44568 44570 5043 5043 52955 52954 15301 15299 65849 2 1 65849 27002 27000 22706 22707...
output:
2168012476 2168078322 2167880786 2167749099 2167683248 2167683247 2167551563 2167551563 2167551563 2167551563 2167551563 2167551563 2167485722 2167485722 2167419882 2167419882 2167419882 2167419882 2167419882 2167354043 2167354043 2167222369 2167222369 2167156533 2167024865 2167024865 2167024865 216...
result:
ok 52236 numbers
Test #9:
score: 0
Accepted
time: 215ms
memory: 27216kb
input:
1 250000 250000 97733 97731 132027 132027 196875 196877 1 250000 170476 170476 44407 44407 250000 1 249999 2 133959 133958 45337 45335 246071 246069 2589 2587 1 249999 172569 172570 2 249999 250000 2 244802 244804 79199 79199 1 249999 249999 1 213003 213003 84015 84014 92491 92492 124485 124485 1803...
output:
31249875000 31250124997 31250374986 31248875012 31248875012 31248875012 31248625017 31248125031 31247875039 31247375059 31246875083 31246375111 31246375110 31246125125 31246125125 31246125125 31245625159 31245625159 31245625159 31245625159 31245625159 31245375177 31245125196 31245125196 31244875216 ...
result:
ok 250000 numbers
Test #10:
score: 0
Accepted
time: 70ms
memory: 10024kb
input:
45413 6 5 3 1 6 5 5 1 2 5 2 2 9 3 5 5 4 5 5 4 6 10 1 6 5 2 6 3 5 2 2 2 2 6 3 5 5 5 2 2 1 6 7 3 4 4 1 1 4 1 6 10 1 1 4 6 2 2 3 5 3 5 5 3 4 6 4 4 3 5 5 5 1 10 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 10 4 4 10 6 3 3 8 3 6 10 1 4 4 9 5 2 9 2 1 7 7 2 9 1 9 5 1 5 5 3 2 1 3 2 1 9 8 6 3 9 6 4 4 6 9 7 7 7 4 ...
output:
15 15 5 2 2 36 43 49 15 6 2 2 2 2 2 2 2 1 21 27 27 15 18 21 17 18 20 21 23 25 27 0 0 0 0 0 0 0 0 0 0 45 31 26 28 45 36 29 29 22 21 10 3 1 36 29 31 30 32 28 29 4 1 2 3 4 5 6 1 1 0 0 45 52 43 37 34 34 36 35 37 21 16 12 11 12 13 12 13 10 10 8 8 9 10 11 1 1 36 28 8 45 32 26 27 18 16 17 17 2 1 10 8 2 1 0...
result:
ok 250000 numbers
Test #11:
score: 0
Accepted
time: 107ms
memory: 9952kb
input:
2446 12 162 6 8 8 9 11 8 3 10 9 8 2 5 10 1 1 4 7 8 10 12 1 5 10 4 2 11 7 4 3 9 10 5 8 3 11 1 4 10 11 6 7 10 12 8 11 9 4 3 6 1 8 4 2 2 10 12 7 9 12 12 7 9 8 11 4 4 11 11 6 10 8 5 8 5 11 8 8 2 5 7 9 9 2 2 10 4 6 9 12 8 7 1 1 6 12 10 1 8 5 11 4 3 6 8 4 5 3 7 4 8 12 7 1 11 2 9 6 8 12 7 8 5 9 3 11 3 9 3 ...
output:
66 72 69 47 50 36 21 20 20 1 1 1 1 1 1 1 1 1 1 1 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 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 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 0 0 0 0 0 0 0 0 0 0 0...
result:
ok 244825 numbers
Test #12:
score: 0
Accepted
time: 162ms
memory: 18028kb
input:
4 39845 77223 11304 11308 2 39838 6 39838 9 39836 39840 2 3 39844 5582 5576 11054 11055 39841 6 15426 15418 39837 3 18844 18851 5 39839 15992 16000 9 39844 39358 39355 9 39843 6 39843 7 39844 34287 34281 284 276 6614 6606 27606 27605 2870 2868 6 39845 39842 7 36916 36913 33317 33321 39836 3 39841 3 ...
output:
793792090 793632766 793433634 793234527 793154851 792995480 792756580 792716766 792716764 792398302 792398300 792119695 792119694 791801352 791801348 791681980 791681980 791681982 791681982 791443280 791125074 790806932 790767167 790687639 790647775 790647775 790528490 790369459 790369460 790369461 ...
result:
ok 250000 numbers
Test #13:
score: 0
Accepted
time: 234ms
memory: 27300kb
input:
1 250000 250000 237315 237325 161044 161036 137460 137451 247727 247730 38655 38653 23041 23049 5 249992 249997 2 178760 178760 198841 198847 10 249995 146224 146229 5 249999 8273 8274 249995 5 210583 210583 5 249996 249997 2 249998 9 81327 81318 3 249991 25090 25085 249991 10 48955 48955 249996 1 1...
output:
31249875000 31250124901 31250374702 31250624584 31250874485 31251124156 31239876513 31237626626 31237626630 31236126988 31234877294 31233627643 31233127625 31232877697 31232877699 31232877701 31232877702 31232877701 31232877697 31230628410 31230378490 31229128917 31229128919 31229128921 31228878902 ...
result:
ok 250000 numbers
Test #14:
score: 0
Accepted
time: 125ms
memory: 9900kb
input:
2502 18 58 12 14 10 14 16 6 17 5 11 12 7 7 3 3 13 3 9 10 10 6 10 7 4 4 2 14 7 12 9 9 10 6 2 6 16 3 12 9 14 8 18 14 9 11 7 8 13 10 15 8 4 5 3 6 6 2 6 17 18 9 17 18 12 7 15 6 18 16 11 12 14 8 13 15 9 5 5 15 2 11 18 2 1 3 16 6 5 1 13 11 12 13 17 13 4 3 16 14 11 15 6 18 18 15 13 7 10 7 4 4 16 11 9 6 16 ...
output:
153 160 135 110 114 119 124 80 80 83 84 87 62 64 66 68 69 71 73 74 40 41 42 43 43 43 44 45 46 46 47 48 49 50 51 52 53 54 55 56 57 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 4753 3942 3981 3590 3619 3639 3612 3584 3507 2005 2005 1721 1604 1225 1228 1227 1130 1120 1120 1120 1114 899 878 750 740 745 746 751 724...
result:
ok 250000 numbers
Test #15:
score: 0
Accepted
time: 140ms
memory: 10308kb
input:
102 4953 1459 24 4912 4916 160 4771 89 139 4945 4897 187 2648 2783 119 4844 2725 2891 3572 3737 695 880 316 258 45 4925 159 4883 199 4923 4847 52 1026 1185 193 4882 4449 4249 3997 4032 4860 10 163 4910 3344 3396 1738 1730 2418 2339 4304 4163 1874 1837 4884 106 4880 72 4809 86 2724 2895 67 4832 4820 ...
output:
12263628 11593112 10938335 10795386 10669759 10069175 10064737 9591474 8902465 8164161 7936078 7934952 7934417 7887382 7887046 7288919 7288879 6576510 6453096 6383660 6383579 6202896 6175177 5907542 5615612 5494824 5494607 5494244 5492889 5479786 5479452 5479335 5473146 5163189 4688416 4646510 46390...
result:
ok 250000 numbers
Test #16:
score: 0
Accepted
time: 170ms
memory: 15216kb
input:
4 21918 92931 82 21855 7116 7178 9491 9490 21730 78 43 21862 5666 5629 21015 20888 21890 82 5601 5698 104 21745 12125 12198 21860 87 20657 20742 147 21825 12995 13023 50 21817 21917 162 21740 43 9798 9869 5509 5678 21888 160 21916 38 21752 106 108 21891 11552 11750 52 21803 21741 67 17717 17606 193 ...
output:
240188403 238842403 238820836 236014166 235099375 234302197 231581828 230970546 229688956 229217918 227665570 227665545 225865230 224953966 224362956 224362226 223455542 223455528 221962867 220036366 220036331 219926847 219926348 219926283 215820989 215820261 215820130 213531015 212892565 212892184 ...
result:
ok 250000 numbers
Test #17:
score: 0
Accepted
time: 240ms
memory: 27168kb
input:
1 250000 250000 111 249894 249917 58 218975 218775 249877 56 27879 27766 173773 173666 156284 156320 91013 90934 94 249845 87959 87909 249981 112 249935 1 249903 46 173989 173869 188 249834 13 249973 37722 37870 111 250000 47757 47909 249990 16 195 249827 249825 178 78173 78038 205733 205898 54532 5...
output:
31249875000 31230641849 31180725389 31175981911 31147793860 31121113976 31112138954 31092449843 31084475001 31072017689 31055776912 31042029658 31042029091 31012145750 30990487902 30990487150 30953665805 30948915873 30911122441 30911122252 30907641474 30907143405 30873597255 30832623630 30788949406 ...
result:
ok 250000 numbers
Test #18:
score: 0
Accepted
time: 149ms
memory: 10196kb
input:
109 1078 1889 1007 282 178 79 751 816 125 68 1066 175 742 543 497 489 930 354 847 438 315 601 821 685 951 524 489 665 836 3 984 270 1062 332 344 978 550 22 580 703 895 626 1021 237 827 678 954 925 316 455 1059 524 679 727 945 945 254 123 1061 193 420 105 1054 522 484 402 251 359 770 922 704 785 284 ...
output:
580503 508981 466269 454941 317613 225953 222408 177191 154391 131150 126077 122805 120227 46277 44428 43793 43525 42262 40944 38303 35796 35665 35457 34877 34777 34425 34439 34093 33445 31803 31602 30607 30364 29378 28904 28824 27974 27919 27397 27111 27082 26766 26608 26498 26332 26334 26238 26190...
result:
ok 250000 numbers
Test #19:
score: 0
Accepted
time: 210ms
memory: 17456kb
input:
4 97869 79786 97622 3759 51039 48491 3746 96678 14109 12461 6629 4082 1371 93507 2333 97649 94628 1603 2356 93761 8368 12451 38763 36986 1521 96702 96912 1332 3645 4908 93548 3615 37535 42115 4122 94942 49098 48685 507 93973 38937 34664 61132 58080 96699 4317 94764 4828 54733 58221 24842 22743 96548...
output:
4789121646 4556452483 4469835648 4323624136 4104137856 3617965605 3614006620 3611540070 3611289472 3289052536 3151967461 3151934589 3148031619 3121667929 3121622977 2874678916 2874103923 2873223719 2793609996 2627852094 2420023828 2419909246 2419844884 2202720256 2071218632 2071009041 2070682619 182...
result:
ok 174605 numbers
Test #20:
score: 0
Accepted
time: 281ms
memory: 27304kb
input:
1 250000 250000 72499 76406 249218 4952 77574 76846 249739 244771 248750 3284 78949 74197 2272 247857 247357 1612 1772 246339 582 249942 17878 18405 245086 199 246304 4360 248683 3281 159052 160180 160056 163657 162450 161367 2701 248329 6867 3683 79691 76969 247219 2874 3917 248097 249343 4784 7903...
output:
31249875000 30310794213 30136347850 28963221739 28552818207 28125506134 27873333680 27708709360 27707034508 27401084011 27278376916 27182263647 27181584281 27181526168 26920153032 26126448743 26123856297 26123440645 25689764148 25521704629 25521513034 25521353948 25521233472 25521144124 24480414364 ...
result:
ok 250000 numbers
Test #21:
score: 0
Accepted
time: 167ms
memory: 19220kb
input:
6 4504 68246 1935 1539 2647 2420 4176 1531 1242 3504 594 1855 2365 3008 1399 2440 4283 3866 1281 822 1552 2661 2794 4456 581 1251 1730 2010 1408 4014 1493 1085 3013 572 1497 1984 3285 2854 147 1562 2360 949 645 1199 241 813 2881 3772 2481 90 3258 907 2744 3523 616 4378 4440 1546 3893 1335 1605 3559 ...
output:
10140756 10054744 8794251 7122287 5183727 4799432 4542354 4046722 3946754 3938771 3270727 3220521 3172274 3147819 3103926 3067076 3066285 2998096 1338676 1319848 1306113 1273350 1244923 991293 981245 972501 964495 963536 956950 944044 934765 927579 895626 889606 878145 873397 867276 859443 825217 81...
result:
ok 250000 numbers
Test #22:
score: 0
Accepted
time: 324ms
memory: 27296kb
input:
1 250000 250000 78728 18467 96029 29326 146284 226853 151138 242845 17298 237050 215585 165899 148360 57422 139200 46464 91709 101742 170802 7337 40205 201363 243742 181387 23836 188875 74041 226144 32715 104452 207839 16584 161154 155400 81599 152793 55837 102307 48013 239741 3124 20119 112705 1858...
output:
31249875000 29670966156 23421884677 20525501292 11512135494 10218883052 9555728650 9062131534 8792080512 6159442482 5656726770 5234028963 5111056603 5025690613 4906153517 4849400943 4797588259 4756408483 4740353947 4719895301 3717700639 3498872878 3469326746 3388194413 2780288653 2743462855 27262393...
result:
ok 250000 numbers
Test #23:
score: 0
Accepted
time: 335ms
memory: 27216kb
input:
1 250000 250000 98350 139819 117361 123481 47387 136547 40152 163109 32803 210394 39234 141097 223538 41000 173606 25779 201484 240798 106552 149426 164258 101032 32861 141545 202238 109711 64708 123868 195171 52486 201726 79996 132517 141751 72535 168680 218355 4746 149137 138248 129101 194905 1794...
output:
31249875000 31033741530 28815475466 25994000423 19276245666 19039617712 16394718112 14668835501 11007023197 10689107134 10663596622 10659731280 10588174792 9903595567 9705170724 9424485848 9388084308 9307939269 4743832141 4739039263 4715511748 4595009974 4583730433 3694188832 3688460299 3604351811 1...
result:
ok 250000 numbers
Test #24:
score: 0
Accepted
time: 342ms
memory: 27288kb
input:
1 250000 250000 47945 118382 42757 25501 200466 28665 153547 227037 8846 165216 165912 146621 172496 97140 208128 10321 183866 90543 45575 190028 213347 33638 83567 16117 178986 170414 60599 7118 126503 14585 157202 219073 124452 176526 41791 119637 181301 102458 238476 19252 175136 157698 133661 60...
output:
31249875000 30034576434 22336749083 15794380063 12026404059 11770870881 10395244087 10227981795 9758252597 9687286789 9570516481 9267659553 9226646997 8558983746 8389103100 8314234420 8291901130 8278012587 8187420860 5651981579 5644601692 5547629980 5484228508 5469130686 3807787358 3796677396 377786...
result:
ok 250000 numbers
Test #25:
score: 0
Accepted
time: 348ms
memory: 27332kb
input:
1 250000 250000 219096 227828 225541 45464 101569 208289 92599 90242 162552 230720 187252 123722 48344 238778 20167 127441 109452 93641 218652 159941 44465 200315 238229 8979 199822 18339 238111 13193 6254 81754 193527 113718 218621 25761 148135 152511 233081 14976 2840 3058 66378 106936 209301 2020...
output:
31249875000 29719041851 22578154126 22426063269 18528675447 17148925300 15509595247 10488629906 10035742564 9946315280 9817907605 7367841809 7344553091 7322010763 6377389024 6295228310 6190295317 6067242168 6049387584 5998710685 5707933786 5687485059 5663637988 5568376556 5000296228 4987029489 49579...
result:
ok 250000 numbers
Test #26:
score: 0
Accepted
time: 170ms
memory: 8612kb
input:
42 8581 8581 6435 1 6434 2 6433 3 4 6432 6431 5 6430 6 6429 7 6428 8 6427 9 10 6426 11 6425 6424 12 6423 13 14 6422 15 6421 16 6420 17 6419 6418 18 19 6417 20 6416 6415 21 6414 22 6413 23 24 6412 6411 25 6410 26 27 6409 28 6408 29 6407 6406 30 6405 31 6404 32 33 6403 34 6402 6401 35 36 6400 37 6399 ...
output:
36812490 36795340 36784626 36773916 36763210 36752508 36741810 36731116 36720426 36709740 36699058 36688380 36677706 36667036 36656370 36645708 36635050 36624396 36613746 36603100 36592458 36581820 36571186 36560556 36549930 36539308 36528690 36518076 36507466 36496860 36486258 36475660 36465066 364...
result:
ok 250000 numbers
Test #27:
score: 0
Accepted
time: 206ms
memory: 12508kb
input:
10 17692 17692 1 13269 2 13268 3 13267 4 13266 5 13265 13264 6 13263 7 13262 8 13261 9 10 13260 13259 11 13258 12 13257 13 14 13256 13255 15 13254 16 17 13253 13252 18 19 13251 13250 20 13249 21 22 13248 23 13247 24 13246 13245 25 13244 26 27 13243 13242 28 13241 29 13240 30 31 13239 13238 32 33 132...
output:
156494586 156459211 156437106 156415005 156392908 156370815 156348726 156326641 156304560 156282483 156260410 156238341 156216276 156194215 156172158 156150105 156128056 156106011 156083970 156061933 156039900 156017871 155995846 155973825 155951808 155929795 155907786 155885781 155863780 155841783 ...
result:
ok 250000 numbers
Test #28:
score: 0
Accepted
time: 228ms
memory: 19180kb
input:
4 41764 41764 31323 1 31322 2 31321 3 4 31320 31319 5 6 31318 31317 7 31316 8 31315 9 31314 10 31313 11 12 31312 13 31311 14 31310 31309 15 31308 16 31307 17 31306 18 19 31305 20 31304 31303 21 22 31302 31301 23 24 31300 25 31299 26 31298 31297 27 28 31296 29 31295 30 31294 31293 31 31292 32 33 3129...
output:
872094966 872011447 871959252 871907061 871854874 871802691 871750512 871698337 871646166 871593999 871541836 871489677 871437522 871385371 871333224 871281081 871228942 871176807 871124676 871072549 871020426 870968307 870916192 870864081 870811974 870759871 870707772 870655677 870603586 870551499 ...
result:
ok 250000 numbers
Test #29:
score: 0
Accepted
time: 276ms
memory: 21576kb
input:
2 108324 108324 81243 1 81242 2 81241 3 81240 4 81239 5 6 81238 81237 7 8 81236 9 81235 81234 10 11 81233 12 81232 81231 13 14 81230 81229 15 16 81228 17 81227 18 81226 19 81225 20 81224 21 81223 81222 22 81221 23 81220 24 81219 25 81218 26 81217 27 28 81216 81215 29 30 81214 81213 31 32 81212 81211...
output:
5866990326 5866773687 5866638292 5866502901 5866367514 5866232131 5866096752 5865961377 5865826006 5865690639 5865555276 5865419917 5865284562 5865149211 5865013864 5864878521 5864743182 5864607847 5864472516 5864337189 5864201866 5864066547 5863931232 5863795921 5863660614 5863525311 5863390012 586...
result:
ok 250000 numbers
Test #30:
score: 0
Accepted
time: 271ms
memory: 21768kb
input:
2 104982 104982 78736 1 2 78735 78734 3 78733 4 5 78732 6 78731 7 78730 8 78729 9 78728 10 78727 78726 11 78725 12 78724 13 78723 14 15 78722 16 78721 78720 17 18 78719 19 78718 20 78717 78716 21 22 78715 78714 23 24 78713 78712 25 78711 26 78710 27 78709 28 78708 29 30 78707 31 78706 32 78705 33 78...
output:
5510557671 5510347718 5510216502 5510085290 5509954082 5509822878 5509691678 5509560482 5509429290 5509298102 5509166918 5509035738 5508904562 5508773390 5508642222 5508511058 5508379898 5508248742 5508117590 5507986442 5507855298 5507724158 5507593022 5507461890 5507330762 5507199638 5507068518 550...
result:
ok 250000 numbers
Test #31:
score: 0
Accepted
time: 295ms
memory: 27180kb
input:
1 250000 250000 1 187500 2 187499 3 187498 187497 4 187496 5 6 187495 187494 7 187493 8 9 187492 10 187491 187490 11 12 187489 13 187488 14 187487 187486 15 16 187485 17 187484 18 187483 19 187482 20 187481 21 187480 187479 22 23 187478 187477 24 25 187476 187475 26 187474 27 28 187473 29 187472 187...
output:
31249875000 31249375009 31249062519 31248750033 31248437551 31248125073 31247812599 31247500129 31247187663 31246875201 31246562743 31246250289 31245937839 31245625393 31245312951 31245000513 31244688079 31244375649 31244063223 31243750801 31243438383 31243125969 31242813559 31242501153 31242188751 ...
result:
ok 250000 numbers
Test #32:
score: 0
Accepted
time: 166ms
memory: 10616kb
input:
42 8581 8579 1 4291 1 2146 2146 3218 2146 2682 2146 2414 2548 2682 2414 2481 2514 2548 2531 2548 2522 2531 2522 2526 2522 2524 2524 2525 2523 2524 2528 2531 2526 2527 2529 2531 2529 2530 2518 2522 2520 2522 2519 2520 2521 2522 2516 2518 2517 2518 2515 2516 2539 2548 2543 2548 2545 2548 2546 2548 254...
output:
36812490 32213610 31066572 30783566 30716032 30702366 30702167 30705335 30709336 30713554 30717824 30722110 30726399 30730688 30734972 30739261 30743549 30747838 30752112 30756398 30760687 30764976 30769262 30773551 30777840 30782058 30786328 30790612 30794900 30799189 30803478 30807764 30812053 308...
result:
ok 249916 numbers
Test #33:
score: 0
Accepted
time: 180ms
memory: 12640kb
input:
10 17692 17690 8846 17692 13269 17692 15480 17692 13269 14374 13269 13821 13821 14097 13821 13959 13959 14028 13993 14028 13976 13993 13959 13967 13971 13976 13971 13973 13972 13973 13973 13974 13975 13976 13969 13971 13967 13968 13969 13970 13959 13963 13963 13965 13964 13965 13966 13967 13961 1396...
output:
156494586 136936079 132054192 130840907 130544496 130476889 130466690 130470774 130478429 130486985 130495758 130504583 130513422 130522266 130531109 130539953 130548794 130557638 130566482 130575311 130584152 130592996 130601840 130610681 130619525 130628369 130637142 130645971 130654812 130663656 ...
result:
ok 249980 numbers
Test #34:
score: 0
Accepted
time: 206ms
memory: 19416kb
input:
4 41764 41762 1 20882 1 10441 10441 15661 15661 18271 15661 16966 15661 16313 16639 16966 16639 16802 16639 16720 16679 16720 16679 16699 16699 16709 16714 16720 16714 16717 16718 16720 16718 16719 16715 16717 16716 16717 16709 16711 16711 16712 16713 16714 16709 16710 16704 16709 16704 16706 16706 ...
output:
872094966 763101368 735863410 729066972 727384829 726979955 726894235 726888385 726902625 726921867 726942329 726963101 726983953 727004826 727025706 727046587 727067467 727088348 727109224 727130104 727150985 727171866 727192723 727213599 727234479 727255360 727276241 727297117 727317998 727338878 ...
result:
ok 249992 numbers
Test #35:
score: 0
Accepted
time: 224ms
memory: 22088kb
input:
2 108324 108322 1 54162 1 27081 1 13541 13541 20311 23696 27081 22003 23696 22003 22849 22849 23272 23484 23696 23590 23696 23643 23696 23590 23616 23590 23603 23590 23596 23596 23599 23599 23601 23601 23602 23600 23601 23596 23597 23597 23598 23590 23593 23594 23596 23594 23595 23590 23591 23591 23...
output:
5866990326 5133663928 4950386490 4904607752 4893203689 4890393295 4889730895 4889605705 4889614923 4889657849 4889709202 4889762662 4889816655 4889870775 4889924925 4889979083 4890033244 4890087405 4890141565 4890195726 4890249879 4890304039 4890358200 4890412360 4890466521 4890520641 4890574791 489...
result:
ok 249996 numbers
Test #36:
score: 0
Accepted
time: 213ms
memory: 22320kb
input:
2 104982 104980 1 52491 52491 78736 65613 78736 72174 78736 75455 78736 75455 77095 75455 76275 75865 76275 75865 76070 76172 76275 76172 76223 76223 76249 76249 76262 76249 76255 76249 76252 76253 76255 76254 76255 76249 76250 76251 76252 76258 76262 76256 76258 76257 76258 76260 76262 76259 76260 ...
output:
5510557671 4132983867 3960796984 3917769948 3907031233 3904366239 3903720085 3903578231 3903562452 3903578192 3903601786 3903627356 3903653433 3903679637 3903705874 3903732118 3903758363 3903784607 3903810852 3903837086 3903863330 3903889575 3903915817 3903942062 3903968307 3903994511 3904020748 390...
result:
ok 249996 numbers
Test #37:
score: 0
Accepted
time: 253ms
memory: 27300kb
input:
1 250000 249998 125000 250000 187500 250000 125000 156250 156250 171875 164062 171875 164062 167968 169921 171875 169921 170898 171386 171875 171630 171875 171752 171875 171691 171752 171660 171691 171630 171645 171652 171660 171648 171652 171650 171652 171650 171651 171649 171650 171645 171646 1716...
output:
31249875000 27343687499 26367218748 26123187497 26062277340 26047141597 26043450434 26042620904 26042507271 26042572490 26042682483 26042803761 26042927830 26043052604 26043177547 26043302534 26043427529 26043552527 26043677525 26043802522 26043927520 26044052503 26044177498 26044302496 26044427494 ...
result:
ok 249998 numbers