QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#811120 | #9840. Tree Partition | liuhengxi | AC ✓ | 337ms | 654104kb | C++14 | 2.9kb | 2024-12-12 15:38:16 | 2024-12-12 15:38:17 |
Judging History
answer
#include<cstdio>
#include<cctype>
#include<algorithm>
#include<vector>
#define F(i,l,r) for(int i=(l),i##_end=(r);i<i##_end;++i)
#define I128 //||is_same<T,__int128_t>::value||is_same<T,__uint128_t>::value
using namespace std;
template<typename T>enable_if_t<is_integral<T>::value I128,void> readmain(T &x)
{
bool neg=false;int c=getchar();
for(;!isdigit(c);c=getchar())if(c=='-')neg=true;
for(x=0;isdigit(c);c=getchar())x=(T)(10*x+(c-'0'));
if(neg)x=-x;
}
template<typename T>T& read(T &x){readmain(x);return x;}
template<typename T,typename ...Tr>void read(T &x,Tr&... r){readmain(x);read(r...);}
constexpr int N=2e5+5,K=405,MOD=998244353,INF=0x3fffffff;
void reduce(int &x){if(x>=MOD)x-=MOD;}
void reduce_(int &x){if(x<0)x+=MOD;}
struct dsu
{
typedef unsigned long long ull;
static constexpr int N=3130;
int n,f[N],l[N];
ull a[N];
void init(int n_)
{
n=(n_+63)>>6;
F(i,0,n)f[i]=-1,l[i]=i,a[i]=-1;
}
int find(int x){return f[x]<0?x:f[x]=find(f[x]);}
void erase(int x)
{
++x;
if(a[x>>6]^=1ull<<(x&63))return;
x>>=6;
int u=find(x),v=find(x-1);
if(f[u]>f[v])swap(u,v);
f[u]+=f[v];f[v]=u;
l[u]=min(l[u],l[v]);
}
int query(int x)
{
++x;
ull s=a[x>>6]<<(63-(x&63));
if(s)return x-__builtin_clzll(s);
x=l[find((x>>6)-1)];
return x<<6|(63^__builtin_clzll(a[x]));
}
}q;
int n,k,f[N],e[N],d[N],l[N],r[N],s[N],t,c[N],w[N][K],p[N][K];
vector<int> adj[N];
void merge(int x,int y,int z)
{
while(f[x]>=0)x=f[x];
while(f[y]>=0)y=f[y];
if(f[x]>f[y])swap(x,y);
f[x]+=f[y];e[y]=z;f[y]=x;
}
int dep(int x){return ~d[x]?d[x]:d[x]=f[x]<0?0:dep(f[x])+1;}
int pathmin(int x,int y)
{
int h=dep(x)-dep(y),ans=INF;
while(h>0)--h,ans=min(ans,e[x]),x=f[x];
while(h<0)++h,ans=min(ans,e[y]),y=f[y];
while(x!=y)ans=min(ans,e[x]),ans=min(ans,e[y]),x=f[x],y=f[y];
return ans;
}
int pathmax(int x,int y)
{
int h=dep(x)-dep(y),ans=-INF;
while(h>0)--h,ans=max(ans,e[x]),x=f[x];
while(h<0)++h,ans=max(ans,e[y]),y=f[y];
while(x!=y)ans=max(ans,e[x]),ans=max(ans,e[y]),x=f[x],y=f[y];
return ans;
}
int main()
{
read(n,k);
F(i,0,n-1)
{
int u,v;read(u,v);--u,--v;
adj[u].emplace_back(v);
adj[v].emplace_back(u);
}
F(i,0,n)f[i]=-1,d[i]=-1;
for(int u=n;~--u;)for(int v:adj[u])if(v>u)merge(u,v,u);
F(i,0,n-1)l[i]=pathmin(i,i+1);
F(i,0,n)f[i]=-1,d[i]=-1;
F(u,0,n)for(int v:adj[u])if(v<u)merge(u,v,u);
F(i,0,n-1)r[i]=pathmax(i,i+1)-1;
t=0;
for(int i=n-1;~--i;)
{
c[i]=-1;
s[t++]=i;
while(t&&s[t-1]<r[i])c[s[--t]]=i;
}
t=0;
w[0][0]=1;
w[1][1]=1;
q.init(n);
F(i,0,n-1)
{
if(t)F(j,0,k+1)p[i][j]=p[s[t-1]][j];
F(j,0,k+1)reduce(p[i][j]+=w[i][j]);
s[t++]=i;
while(t&&s[t-1]>l[i])q.erase(s[--t]);
int v=q.query(c[i]);
F(j,0,k)reduce(w[i+2][j+1]+=p[s[t-1]][j]);
if(v)F(j,0,k)reduce_(w[i+2][j+1]-=p[v-1][j]);
F(j,0,k)reduce(w[i+2][j+1]+=w[i+1][j]);
}
F(i,1,k+1)printf("%d\n",w[n][i]);
return 0;
}
这程序好像有点Bug,我给组数据试试?
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 18040kb
input:
4 3 1 2 2 3 2 4
output:
1 2 2
result:
ok 3 lines
Test #2:
score: 0
Accepted
time: 0ms
memory: 16660kb
input:
7 7 2 5 3 6 4 5 5 1 1 6 6 7
output:
1 1 0 0 1 2 1
result:
ok 7 lines
Test #3:
score: 0
Accepted
time: 79ms
memory: 653568kb
input:
200000 20 1 2 1 3 1 4 6 5 6 7 6 8 12 9 12 10 12 11 13 14 13 15 13 16 20 17 20 18 20 19 21 22 21 23 21 24 21 25 1 13 6 13 12 13 20 13 21 13 27 26 27 28 27 29 32 30 32 31 32 33 34 35 34 36 34 37 38 39 38 40 38 41 43 42 43 44 43 45 46 47 46 48 46 49 46 50 27 38 32 38 34 38 43 38 46 38 51 52 51 53 51 54...
output:
1 13 176 2319 30068 384955 4875560 61165940 760811301 405332244 246475419 554163687 400425475 668396606 125703386 89953555 995149440 774574469 541392385 429619985
result:
ok 20 lines
Test #4:
score: 0
Accepted
time: 71ms
memory: 653624kb
input:
200000 20 4 1 4 2 4 3 5 6 5 7 5 8 9 10 9 11 9 12 13 14 13 15 13 16 18 17 18 19 18 20 22 21 22 23 22 24 22 25 4 13 5 13 9 13 18 13 22 13 29 26 29 27 29 28 30 31 30 32 30 33 37 34 37 35 37 36 39 38 39 40 39 41 42 43 42 44 42 45 49 46 49 47 49 48 49 50 29 39 30 39 37 39 42 39 49 39 53 51 53 52 53 54 57...
output:
1 14 185 2404 30814 390564 4902418 61000454 752983100 242139987 472863106 929714703 119782922 593712683 609125416 872539629 83372963 639293742 622266226 792288795
result:
ok 20 lines
Test #5:
score: 0
Accepted
time: 72ms
memory: 653640kb
input:
200000 20 1 2 1 3 1 4 8 5 8 6 8 7 9 10 9 11 9 12 16 13 16 14 16 15 19 17 19 18 19 20 24 21 24 22 24 23 24 25 1 16 8 16 9 16 19 16 24 16 27 26 27 28 27 29 33 30 33 31 33 32 36 34 36 35 36 37 39 38 39 40 39 41 45 42 45 43 45 44 46 47 46 48 46 49 46 50 27 39 33 39 36 39 45 39 46 39 53 51 53 52 53 54 57...
output:
1 12 158 2033 25819 324544 4044421 50013717 614106750 503048605 961357590 169415689 710064641 320301852 756985177 967742311 374036652 941058124 588191422 810964435
result:
ok 20 lines
Test #6:
score: 0
Accepted
time: 60ms
memory: 653604kb
input:
200000 20 4 1 4 2 4 3 8 5 8 6 8 7 9 10 9 11 9 12 15 13 15 14 15 16 17 18 17 19 17 20 22 21 22 23 22 24 22 25 4 15 8 15 9 15 17 15 22 15 28 26 28 27 28 29 33 30 33 31 33 32 36 34 36 35 36 37 39 38 39 40 39 41 44 42 44 43 44 45 47 46 47 48 47 49 47 50 28 39 33 39 36 39 44 39 47 39 51 52 51 53 51 54 58...
output:
1 14 185 2408 30925 392609 4934344 61457495 759192354 323633583 518118990 62869842 461787830 235002280 820524864 245863891 813843155 518367835 237965261 480206392
result:
ok 20 lines
Test #7:
score: 0
Accepted
time: 71ms
memory: 653620kb
input:
200000 20 1 2 1 3 1 4 5 6 5 7 5 8 12 9 12 10 12 11 13 14 13 15 13 16 19 17 19 18 19 20 21 22 21 23 21 24 21 25 1 13 5 13 12 13 19 13 21 13 28 26 28 27 28 29 30 31 30 32 30 33 34 35 34 36 34 37 38 39 38 40 38 41 45 42 45 43 45 44 48 46 48 47 48 49 48 50 28 38 30 38 34 38 45 38 48 38 52 51 52 53 52 54...
output:
1 12 162 2139 27808 356888 4528437 56878811 707911548 751808398 222054974 279791496 166135229 747401538 76231320 784949109 746019826 344226740 417885502 996177574
result:
ok 20 lines
Test #8:
score: 0
Accepted
time: 79ms
memory: 653932kb
input:
200000 20 2 1 2 3 2 4 2 5 10 6 10 7 10 8 10 9 14 11 14 12 14 13 14 15 17 16 17 18 17 19 17 20 24 21 24 22 24 23 24 25 26 27 26 28 26 29 26 30 33 31 33 32 33 34 33 35 36 37 36 38 36 39 36 40 45 41 45 42 45 43 45 44 47 46 47 48 47 49 47 50 55 51 55 52 55 53 55 54 58 56 58 57 58 59 58 60 64 61 64 62 64...
output:
1 6 32 163 801 3828 17892 82166 372001 1665172 7387818 32555111 142719061 623206098 716382056 798032235 111522191 907324205 649183234 711010078
result:
ok 20 lines
Test #9:
score: 0
Accepted
time: 75ms
memory: 653856kb
input:
200000 20 2 1 3 4 5 6 7 8 10 9 11 12 14 13 15 16 18 17 20 19 21 22 23 24 25 26 27 28 30 29 31 32 34 33 36 35 38 37 40 39 41 42 44 43 45 46 47 48 49 50 52 51 54 53 55 56 57 58 59 60 62 61 64 63 66 65 67 68 70 69 72 71 74 73 75 76 78 77 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 96 95 97 98 100 9...
output:
1 6 28 123 525 2208 9163 37593 152795 616275 2469825 9844142 39045545 154178384 606270389 378274962 284370698 119748351 103605835 50887914
result:
ok 20 lines
Test #10:
score: 0
Accepted
time: 72ms
memory: 653808kb
input:
200000 20 1 2 4 3 6 5 7 8 10 9 12 11 14 13 15 16 17 18 19 20 22 21 23 24 25 26 28 27 30 29 31 32 33 34 36 35 38 37 39 40 42 41 43 44 46 45 47 48 50 49 52 51 53 54 55 56 58 57 60 59 61 62 64 63 66 65 68 67 70 69 71 72 73 74 75 76 78 77 79 80 82 81 84 83 85 86 88 87 90 89 91 92 94 93 95 96 97 98 99 10...
output:
1 5 25 115 508 2190 9251 38406 157199 636331 2554240 10189169 40463651 160179875 632664753 498284531 840893370 717575251 148116836 172090581
result:
ok 20 lines
Test #11:
score: 0
Accepted
time: 63ms
memory: 654036kb
input:
200000 20 467 400 467 401 467 402 467 403 467 404 467 405 467 406 467 407 467 408 467 409 467 410 467 411 467 412 467 413 467 414 467 415 467 416 467 417 467 418 467 419 467 420 467 421 467 422 467 423 467 424 467 425 467 426 467 427 467 428 467 429 467 430 467 431 467 432 467 433 467 434 467 435 46...
output:
1 5 22 91 362 1400 5294 19643 71709 258203 919227 3243034 11361294 39589640 137398867 475398158 642761809 662785128 484515930 947390198
result:
ok 20 lines
Test #12:
score: 0
Accepted
time: 68ms
memory: 654104kb
input:
200000 20 455 400 455 401 455 402 455 403 455 404 455 405 455 406 455 407 455 408 455 409 455 410 455 411 455 412 455 413 455 414 455 415 455 416 455 417 455 418 455 419 455 420 455 421 455 422 455 423 455 424 455 425 455 426 455 427 455 428 455 429 455 430 455 431 455 432 455 433 455 434 455 435 45...
output:
1 5 22 90 351 1326 4904 17878 64521 231108 822900 2915704 10287661 36166071 126730974 442804706 544933029 374157333 646357026 568707420
result:
ok 20 lines
Test #13:
score: 0
Accepted
time: 72ms
memory: 653104kb
input:
200000 20 1 2 2 3 3 4 4 5 6 7 7 8 1 8 9 10 10 11 11 12 12 13 6 13 14 15 15 16 9 16 17 18 18 19 19 20 20 21 14 21 22 23 23 24 24 25 17 25 26 27 27 28 28 29 29 30 22 30 31 32 32 33 33 34 34 35 26 35 36 37 37 38 38 39 31 39 40 41 41 42 42 43 43 44 36 44 45 46 46 47 47 48 48 49 40 49 50 51 51 52 45 52 5...
output:
1 75128 825619948 444091206 829062655 278521469 237815773 597313479 230618480 802373716 773304989 712677613 237839372 746087668 488970002 17171562 966595372 573931325 526227355 786896120
result:
ok 20 lines
Test #14:
score: 0
Accepted
time: 76ms
memory: 653116kb
input:
200000 20 1 2 2 3 4 5 5 6 6 7 1 7 8 9 9 10 10 11 4 11 12 13 13 14 14 15 8 15 16 17 17 18 18 19 19 20 12 20 21 22 22 23 23 24 24 25 16 25 26 27 27 28 28 29 21 29 30 31 31 32 32 33 33 34 26 34 35 36 36 37 37 38 38 39 30 39 40 41 41 42 42 43 35 43 44 45 45 46 46 47 47 48 40 48 49 50 50 51 51 52 44 52 5...
output:
1 74924 810314840 300962407 478589319 917569974 956848093 997993685 610439861 464664111 727916732 379581436 628134845 967956923 510293112 232570299 200815218 68195908 282199335 336981800
result:
ok 20 lines
Test #15:
score: 0
Accepted
time: 59ms
memory: 653088kb
input:
200000 20 1 2 2 3 3 4 4 5 6 7 7 8 1 8 9 10 10 11 11 12 12 13 6 13 14 15 15 16 16 17 9 17 18 19 19 20 20 21 14 21 22 23 23 24 24 25 18 25 26 27 27 28 22 28 29 30 30 31 31 32 26 32 33 34 34 35 35 36 36 37 29 37 38 39 39 40 40 41 41 42 33 42 43 44 44 45 38 45 46 47 47 48 48 49 43 49 50 51 51 52 52 53 5...
output:
1 74816 802229102 87574505 650723285 656771309 903210078 759853062 497829574 934167620 19659044 378226331 541156973 747002420 518657516 877052886 534925663 978847677 544335234 759285585
result:
ok 20 lines
Test #16:
score: 0
Accepted
time: 75ms
memory: 653108kb
input:
200000 20 1 2 2 3 3 4 5 6 6 7 7 8 1 8 9 10 10 11 11 12 12 13 5 13 14 15 15 16 16 17 17 18 9 18 19 20 20 21 21 22 22 23 14 23 24 25 25 26 26 27 19 27 28 29 29 30 30 31 31 32 24 32 33 34 34 35 35 36 28 36 37 38 38 39 33 39 40 41 41 42 42 43 37 43 44 45 45 46 46 47 47 48 40 48 49 50 50 51 51 52 44 52 5...
output:
1 75374 844131479 167760448 888082583 609134201 948617932 153572706 178975301 328051520 73388765 85180514 272758077 330693357 607354014 41138540 352388304 181035418 700179830 380818871
result:
ok 20 lines
Test #17:
score: 0
Accepted
time: 52ms
memory: 653104kb
input:
200000 20 1 2 2 3 3 4 4 5 6 7 7 8 1 8 9 10 10 11 6 11 12 13 13 14 14 15 15 16 9 16 17 18 18 19 19 20 20 21 12 21 22 23 23 24 24 25 25 26 17 26 27 28 28 29 29 30 22 30 31 32 32 33 33 34 27 34 35 36 36 37 31 37 38 39 39 40 35 40 41 42 42 43 43 44 38 44 45 46 46 47 47 48 41 48 49 50 50 51 45 51 52 53 5...
output:
1 75199 830956574 357426492 112509948 195018850 421113770 193411448 335077876 377273995 475470289 268270822 77011129 165741977 462738002 565429706 856897182 215648623 387452734 155908406
result:
ok 20 lines
Test #18:
score: 0
Accepted
time: 80ms
memory: 653240kb
input:
200000 20 1 2 3 4 6 5 7 8 10 9 12 11 1 7 3 7 6 7 10 7 12 7 13 14 15 16 17 18 19 20 22 21 24 23 13 19 15 19 17 19 22 19 24 19 26 25 27 28 30 29 31 32 33 34 35 36 26 31 27 31 30 31 33 31 35 31 38 37 40 39 42 41 43 44 46 45 47 48 38 43 40 43 42 43 46 43 47 43 49 50 52 51 54 53 56 55 57 58 59 60 49 56 5...
output:
1 25022 313037746 326143902 549774611 529251151 305780838 871118941 935396901 480994057 69357038 565079041 586295267 211954109 885697920 760727702 378813144 362368839 436168000 934195921
result:
ok 20 lines
Test #19:
score: 0
Accepted
time: 75ms
memory: 653288kb
input:
200000 20 1 2 4 3 5 6 7 8 9 10 11 12 1 7 4 7 5 7 9 7 11 7 13 14 16 15 17 18 19 20 21 22 24 23 13 19 16 19 17 19 21 19 24 19 26 25 27 28 30 29 31 32 33 34 36 35 26 31 27 31 30 31 33 31 36 31 38 37 39 40 41 42 43 44 45 46 48 47 38 43 39 43 41 43 45 43 48 43 50 49 51 52 54 53 55 56 58 57 60 59 50 55 51...
output:
1 24979 311962749 864673370 738256178 859803066 635402830 556545282 855791149 536184113 221223658 204825894 469874837 321756201 125751585 559254761 403551309 409720573 327717032 474698395
result:
ok 20 lines
Test #20:
score: 0
Accepted
time: 92ms
memory: 653240kb
input:
200000 20 1 2 3 4 6 5 8 7 10 9 12 11 1 8 3 8 6 8 10 8 12 8 14 13 15 16 18 17 20 19 22 21 24 23 14 20 15 20 18 20 22 20 24 20 26 25 27 28 29 30 31 32 33 34 35 36 26 31 27 31 29 31 33 31 35 31 38 37 40 39 41 42 43 44 46 45 47 48 38 43 40 43 41 43 46 43 47 43 49 50 51 52 53 54 55 56 57 58 59 60 49 55 5...
output:
1 24966 311638113 804407690 904869492 356159781 168039729 736355042 911503299 220764485 699645233 470237319 608891505 629949150 942729056 635359884 2910092 259962910 472382352 237930444
result:
ok 20 lines
Test #21:
score: 0
Accepted
time: 79ms
memory: 653296kb
input:
200000 20 2 1 4 3 6 5 7 8 9 10 12 11 2 7 4 7 6 7 9 7 12 7 14 13 16 15 18 17 19 20 22 21 23 24 14 19 16 19 18 19 22 19 23 19 26 25 28 27 30 29 31 32 33 34 36 35 26 31 28 31 30 31 33 31 36 31 37 38 40 39 41 42 44 43 45 46 47 48 37 44 40 44 41 44 45 44 47 44 49 50 51 52 54 53 56 55 57 58 59 60 49 56 51...
output:
1 24995 312362533 867853624 113718730 125212677 984396175 115757038 835848249 140165564 289892017 653931404 693769958 908935338 786552055 691399344 607827304 79632108 715392002 843837992
result:
ok 20 lines
Test #22:
score: 0
Accepted
time: 80ms
memory: 653312kb
input:
200000 20 2 1 3 4 6 5 8 7 10 9 12 11 2 8 3 8 6 8 10 8 12 8 13 14 16 15 18 17 20 19 22 21 23 24 13 20 16 20 18 20 22 20 23 20 26 25 27 28 30 29 32 31 34 33 36 35 26 32 27 32 30 32 34 32 36 32 38 37 39 40 42 41 43 44 45 46 47 48 38 43 39 43 42 43 45 43 47 43 50 49 52 51 53 54 55 56 57 58 60 59 50 55 5...
output:
1 24987 312162609 366341775 420189392 785247360 653767722 635540731 467217164 82860127 85151628 795586249 157408413 858298559 578884196 687568581 472309769 355929158 351941926 360039605
result:
ok 20 lines
Test #23:
score: 0
Accepted
time: 310ms
memory: 653564kb
input:
200000 400 1 2 1 3 1 4 6 5 6 7 6 8 12 9 12 10 12 11 13 14 13 15 13 16 20 17 20 18 20 19 21 22 21 23 21 24 21 25 1 13 6 13 12 13 20 13 21 13 27 26 27 28 27 29 32 30 32 31 32 33 34 35 34 36 34 37 38 39 38 40 38 41 43 42 43 44 43 45 46 47 46 48 46 49 46 50 27 38 32 38 34 38 43 38 46 38 51 52 51 53 51 5...
output:
1 13 176 2319 30068 384955 4875560 61165940 760811301 405332244 246475419 554163687 400425475 668396606 125703386 89953555 995149440 774574469 541392385 429619985 153707904 106921164 198533594 172842346 145487131 395761353 802870346 718416085 974753277 889563296 782374450 719462325 425524494 7046412...
result:
ok 400 lines
Test #24:
score: 0
Accepted
time: 337ms
memory: 653644kb
input:
200000 400 4 1 4 2 4 3 5 6 5 7 5 8 9 10 9 11 9 12 13 14 13 15 13 16 18 17 18 19 18 20 22 21 22 23 22 24 22 25 4 13 5 13 9 13 18 13 22 13 29 26 29 27 29 28 30 31 30 32 30 33 37 34 37 35 37 36 39 38 39 40 39 41 42 43 42 44 42 45 49 46 49 47 49 48 49 50 29 39 30 39 37 39 42 39 49 39 53 51 53 52 53 54 5...
output:
1 14 185 2404 30814 390564 4902418 61000454 752983100 242139987 472863106 929714703 119782922 593712683 609125416 872539629 83372963 639293742 622266226 792288795 600728583 225592562 556837440 651666086 554181585 903356905 848302630 516822436 329149245 758860960 561208235 106595442 666493238 3840710...
result:
ok 400 lines
Test #25:
score: 0
Accepted
time: 298ms
memory: 653560kb
input:
200000 400 1 2 1 3 1 4 8 5 8 6 8 7 9 10 9 11 9 12 16 13 16 14 16 15 19 17 19 18 19 20 24 21 24 22 24 23 24 25 1 16 8 16 9 16 19 16 24 16 27 26 27 28 27 29 33 30 33 31 33 32 36 34 36 35 36 37 39 38 39 40 39 41 45 42 45 43 45 44 46 47 46 48 46 49 46 50 27 39 33 39 36 39 45 39 46 39 53 51 53 52 53 54 5...
output:
1 12 158 2033 25819 324544 4044421 50013717 614106750 503048605 961357590 169415689 710064641 320301852 756985177 967742311 374036652 941058124 588191422 810964435 1387914 33485362 761039784 114611071 990946263 74961464 368274761 22763708 134585439 126688829 128863621 500459393 617372699 908873145 2...
result:
ok 400 lines
Test #26:
score: 0
Accepted
time: 303ms
memory: 653628kb
input:
200000 400 4 1 4 2 4 3 8 5 8 6 8 7 9 10 9 11 9 12 15 13 15 14 15 16 17 18 17 19 17 20 22 21 22 23 22 24 22 25 4 15 8 15 9 15 17 15 22 15 28 26 28 27 28 29 33 30 33 31 33 32 36 34 36 35 36 37 39 38 39 40 39 41 44 42 44 43 44 45 47 46 47 48 47 49 47 50 28 39 33 39 36 39 44 39 47 39 51 52 51 53 51 54 5...
output:
1 14 185 2408 30925 392609 4934344 61457495 759192354 323633583 518118990 62869842 461787830 235002280 820524864 245863891 813843155 518367835 237965261 480206392 83007026 675577716 706331352 647940591 610174514 874250318 5766246 813537688 106547773 751239454 118844176 87650162 119806560 514822115 2...
result:
ok 400 lines
Test #27:
score: 0
Accepted
time: 283ms
memory: 653552kb
input:
200000 400 1 2 1 3 1 4 5 6 5 7 5 8 12 9 12 10 12 11 13 14 13 15 13 16 19 17 19 18 19 20 21 22 21 23 21 24 21 25 1 13 5 13 12 13 19 13 21 13 28 26 28 27 28 29 30 31 30 32 30 33 34 35 34 36 34 37 38 39 38 40 38 41 45 42 45 43 45 44 48 46 48 47 48 49 48 50 28 38 30 38 34 38 45 38 48 38 52 51 52 53 52 5...
output:
1 12 162 2139 27808 356888 4528437 56878811 707911548 751808398 222054974 279791496 166135229 747401538 76231320 784949109 746019826 344226740 417885502 996177574 349472094 565147431 513790346 174526581 454539286 143877766 779466898 725119790 513978107 330221565 444565735 723483613 493963275 6832927...
result:
ok 400 lines
Test #28:
score: 0
Accepted
time: 313ms
memory: 653936kb
input:
200000 400 2 1 2 3 2 4 2 5 10 6 10 7 10 8 10 9 14 11 14 12 14 13 14 15 17 16 17 18 17 19 17 20 24 21 24 22 24 23 24 25 26 27 26 28 26 29 26 30 33 31 33 32 33 34 33 35 36 37 36 38 36 39 36 40 45 41 45 42 45 43 45 44 47 46 47 48 47 49 47 50 55 51 55 52 55 53 55 54 58 56 58 57 58 59 58 60 64 61 64 62 6...
output:
1 6 32 163 801 3828 17892 82166 372001 1665172 7387818 32555111 142719061 623206098 716382056 798032235 111522191 907324205 649183234 711010078 795211021 512004677 20298100 361619834 51342569 939800938 347785401 552487155 460073712 269832902 59669787 127735227 533337026 370758508 552296758 298078972...
result:
ok 400 lines
Test #29:
score: 0
Accepted
time: 337ms
memory: 653848kb
input:
200000 400 2 1 3 4 5 6 7 8 10 9 11 12 14 13 15 16 18 17 20 19 21 22 23 24 25 26 27 28 30 29 31 32 34 33 36 35 38 37 40 39 41 42 44 43 45 46 47 48 49 50 52 51 54 53 55 56 57 58 59 60 62 61 64 63 66 65 67 68 70 69 72 71 74 73 75 76 78 77 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 96 95 97 98 100 ...
output:
1 6 28 123 525 2208 9163 37593 152795 616275 2469825 9844142 39045545 154178384 606270389 378274962 284370698 119748351 103605835 50887914 519623850 649536277 985432959 844855773 786738265 43425510 594141846 945032998 908786419 985255306 118929044 828715049 172550527 744245760 557900325 651137679 98...
result:
ok 400 lines
Test #30:
score: 0
Accepted
time: 307ms
memory: 653788kb
input:
200000 400 1 2 4 3 6 5 7 8 10 9 12 11 14 13 15 16 17 18 19 20 22 21 23 24 25 26 28 27 30 29 31 32 33 34 36 35 38 37 39 40 42 41 43 44 46 45 47 48 50 49 52 51 53 54 55 56 58 57 60 59 61 62 64 63 66 65 68 67 70 69 71 72 73 74 75 76 78 77 79 80 82 81 84 83 85 86 88 87 90 89 91 92 94 93 95 96 97 98 99 1...
output:
1 5 25 115 508 2190 9251 38406 157199 636331 2554240 10189169 40463651 160179875 632664753 498284531 840893370 717575251 148116836 172090581 794143415 157415919 416995381 801288969 723998988 425019613 204283937 65886743 392156464 995347716 344602632 452682326 720930530 225771033 964555543 812385975 ...
result:
ok 400 lines
Test #31:
score: 0
Accepted
time: 279ms
memory: 654104kb
input:
200000 400 467 400 467 401 467 402 467 403 467 404 467 405 467 406 467 407 467 408 467 409 467 410 467 411 467 412 467 413 467 414 467 415 467 416 467 417 467 418 467 419 467 420 467 421 467 422 467 423 467 424 467 425 467 426 467 427 467 428 467 429 467 430 467 431 467 432 467 433 467 434 467 435 4...
output:
1 5 22 91 362 1400 5294 19643 71709 258203 919227 3243034 11361294 39589640 137398867 475398158 642761809 662785128 484515930 947390198 771515002 807742636 641978688 251281902 582483060 904165323 271349636 371348100 32303297 722137941 731362326 167043457 188736857 816616140 118396690 975433818 73440...
result:
ok 400 lines
Test #32:
score: 0
Accepted
time: 264ms
memory: 654052kb
input:
200000 400 455 400 455 401 455 402 455 403 455 404 455 405 455 406 455 407 455 408 455 409 455 410 455 411 455 412 455 413 455 414 455 415 455 416 455 417 455 418 455 419 455 420 455 421 455 422 455 423 455 424 455 425 455 426 455 427 455 428 455 429 455 430 455 431 455 432 455 433 455 434 455 435 4...
output:
1 5 22 90 351 1326 4904 17878 64521 231108 822900 2915704 10287661 36166071 126730974 442804706 544933029 374157333 646357026 568707420 180921859 136858975 469351643 456085795 258179111 456393836 299137929 342879872 361975739 469839096 880827106 691523974 259733168 573040878 373150726 424744524 7921...
result:
ok 400 lines
Test #33:
score: 0
Accepted
time: 282ms
memory: 653060kb
input:
200000 400 1 2 2 3 3 4 4 5 6 7 7 8 1 8 9 10 10 11 11 12 12 13 6 13 14 15 15 16 9 16 17 18 18 19 19 20 20 21 14 21 22 23 23 24 24 25 17 25 26 27 27 28 28 29 29 30 22 30 31 32 32 33 33 34 34 35 26 35 36 37 37 38 38 39 31 39 40 41 41 42 42 43 43 44 36 44 45 46 46 47 47 48 48 49 40 49 50 51 51 52 45 52 ...
output:
1 75128 825619948 444091206 829062655 278521469 237815773 597313479 230618480 802373716 773304989 712677613 237839372 746087668 488970002 17171562 966595372 573931325 526227355 786896120 104733771 625597682 447084095 615928944 226888482 712378921 644151511 873336013 337375014 14693659 846235065 8106...
result:
ok 400 lines
Test #34:
score: 0
Accepted
time: 275ms
memory: 653040kb
input:
200000 400 1 2 2 3 4 5 5 6 6 7 1 7 8 9 9 10 10 11 4 11 12 13 13 14 14 15 8 15 16 17 17 18 18 19 19 20 12 20 21 22 22 23 23 24 24 25 16 25 26 27 27 28 28 29 21 29 30 31 31 32 32 33 33 34 26 34 35 36 36 37 37 38 38 39 30 39 40 41 41 42 42 43 35 43 44 45 45 46 46 47 47 48 40 48 49 50 50 51 51 52 44 52 ...
output:
1 74924 810314840 300962407 478589319 917569974 956848093 997993685 610439861 464664111 727916732 379581436 628134845 967956923 510293112 232570299 200815218 68195908 282199335 336981800 511302426 331698824 914944286 668457693 598569173 825415530 105907494 420017007 835577997 11036243 682802309 7274...
result:
ok 400 lines
Test #35:
score: 0
Accepted
time: 276ms
memory: 653112kb
input:
200000 400 1 2 2 3 3 4 4 5 6 7 7 8 1 8 9 10 10 11 11 12 12 13 6 13 14 15 15 16 16 17 9 17 18 19 19 20 20 21 14 21 22 23 23 24 24 25 18 25 26 27 27 28 22 28 29 30 30 31 31 32 26 32 33 34 34 35 35 36 36 37 29 37 38 39 39 40 40 41 41 42 33 42 43 44 44 45 38 45 46 47 47 48 48 49 43 49 50 51 51 52 52 53 ...
output:
1 74816 802229102 87574505 650723285 656771309 903210078 759853062 497829574 934167620 19659044 378226331 541156973 747002420 518657516 877052886 534925663 978847677 544335234 759285585 123365286 505525954 981866811 791990649 326867716 573213992 642088849 673259567 532796806 955497837 955383770 7330...
result:
ok 400 lines
Test #36:
score: 0
Accepted
time: 282ms
memory: 653048kb
input:
200000 400 1 2 2 3 3 4 5 6 6 7 7 8 1 8 9 10 10 11 11 12 12 13 5 13 14 15 15 16 16 17 17 18 9 18 19 20 20 21 21 22 22 23 14 23 24 25 25 26 26 27 19 27 28 29 29 30 30 31 31 32 24 32 33 34 34 35 35 36 28 36 37 38 38 39 33 39 40 41 41 42 42 43 37 43 44 45 45 46 46 47 47 48 40 48 49 50 50 51 51 52 44 52 ...
output:
1 75374 844131479 167760448 888082583 609134201 948617932 153572706 178975301 328051520 73388765 85180514 272758077 330693357 607354014 41138540 352388304 181035418 700179830 380818871 289712996 760845472 468867095 51265418 606551745 712507652 587919100 414731666 668975592 201270524 797435133 551096...
result:
ok 400 lines
Test #37:
score: 0
Accepted
time: 277ms
memory: 653036kb
input:
200000 400 1 2 2 3 3 4 4 5 6 7 7 8 1 8 9 10 10 11 6 11 12 13 13 14 14 15 15 16 9 16 17 18 18 19 19 20 20 21 12 21 22 23 23 24 24 25 25 26 17 26 27 28 28 29 29 30 22 30 31 32 32 33 33 34 27 34 35 36 36 37 31 37 38 39 39 40 35 40 41 42 42 43 43 44 38 44 45 46 46 47 47 48 41 48 49 50 50 51 45 51 52 53 ...
output:
1 75199 830956574 357426492 112509948 195018850 421113770 193411448 335077876 377273995 475470289 268270822 77011129 165741977 462738002 565429706 856897182 215648623 387452734 155908406 690700002 705558489 211183060 895057602 851104697 238964838 267031579 732130566 417773477 412000287 704262017 611...
result:
ok 400 lines
Test #38:
score: 0
Accepted
time: 299ms
memory: 653236kb
input:
200000 400 1 2 3 4 6 5 7 8 10 9 12 11 1 7 3 7 6 7 10 7 12 7 13 14 15 16 17 18 19 20 22 21 24 23 13 19 15 19 17 19 22 19 24 19 26 25 27 28 30 29 31 32 33 34 35 36 26 31 27 31 30 31 33 31 35 31 38 37 40 39 42 41 43 44 46 45 47 48 38 43 40 43 42 43 46 43 47 43 49 50 52 51 54 53 56 55 57 58 59 60 49 56 ...
output:
1 25022 313037746 326143902 549774611 529251151 305780838 871118941 935396901 480994057 69357038 565079041 586295267 211954109 885697920 760727702 378813144 362368839 436168000 934195921 350924517 713024609 893096924 112290393 244186426 817961526 136240718 255798720 754791404 286385867 933576947 356...
result:
ok 400 lines
Test #39:
score: 0
Accepted
time: 284ms
memory: 653356kb
input:
200000 400 1 2 4 3 5 6 7 8 9 10 11 12 1 7 4 7 5 7 9 7 11 7 13 14 16 15 17 18 19 20 21 22 24 23 13 19 16 19 17 19 21 19 24 19 26 25 27 28 30 29 31 32 33 34 36 35 26 31 27 31 30 31 33 31 36 31 38 37 39 40 41 42 43 44 45 46 48 47 38 43 39 43 41 43 45 43 48 43 50 49 51 52 54 53 55 56 58 57 60 59 50 55 5...
output:
1 24979 311962749 864673370 738256178 859803066 635402830 556545282 855791149 536184113 221223658 204825894 469874837 321756201 125751585 559254761 403551309 409720573 327717032 474698395 619394949 658272675 32051015 601749543 441529237 989468258 111236170 205064424 466026156 324279871 298876716 497...
result:
ok 400 lines
Test #40:
score: 0
Accepted
time: 323ms
memory: 653304kb
input:
200000 400 1 2 3 4 6 5 8 7 10 9 12 11 1 8 3 8 6 8 10 8 12 8 14 13 15 16 18 17 20 19 22 21 24 23 14 20 15 20 18 20 22 20 24 20 26 25 27 28 29 30 31 32 33 34 35 36 26 31 27 31 29 31 33 31 35 31 38 37 40 39 41 42 43 44 46 45 47 48 38 43 40 43 41 43 46 43 47 43 49 50 51 52 53 54 55 56 57 58 59 60 49 55 ...
output:
1 24966 311638113 804407690 904869492 356159781 168039729 736355042 911503299 220764485 699645233 470237319 608891505 629949150 942729056 635359884 2910092 259962910 472382352 237930444 141099504 721554128 739257447 268391028 714434136 478588649 29192432 284955559 925850292 326744670 812095813 13268...
result:
ok 400 lines
Test #41:
score: 0
Accepted
time: 280ms
memory: 653364kb
input:
200000 400 2 1 4 3 6 5 7 8 9 10 12 11 2 7 4 7 6 7 9 7 12 7 14 13 16 15 18 17 19 20 22 21 23 24 14 19 16 19 18 19 22 19 23 19 26 25 28 27 30 29 31 32 33 34 36 35 26 31 28 31 30 31 33 31 36 31 37 38 40 39 41 42 44 43 45 46 47 48 37 44 40 44 41 44 45 44 47 44 49 50 51 52 54 53 56 55 57 58 59 60 49 56 5...
output:
1 24995 312362533 867853624 113718730 125212677 984396175 115757038 835848249 140165564 289892017 653931404 693769958 908935338 786552055 691399344 607827304 79632108 715392002 843837992 526185601 517454724 562829253 476858833 578568040 319179903 330709754 377989930 26142808 135851746 915121195 8003...
result:
ok 400 lines
Test #42:
score: 0
Accepted
time: 306ms
memory: 653304kb
input:
200000 400 2 1 3 4 6 5 8 7 10 9 12 11 2 8 3 8 6 8 10 8 12 8 13 14 16 15 18 17 20 19 22 21 23 24 13 20 16 20 18 20 22 20 23 20 26 25 27 28 30 29 32 31 34 33 36 35 26 32 27 32 30 32 34 32 36 32 38 37 39 40 42 41 43 44 45 46 47 48 38 43 39 43 42 43 45 43 47 43 50 49 52 51 53 54 55 56 57 58 60 59 50 55 ...
output:
1 24987 312162609 366341775 420189392 785247360 653767722 635540731 467217164 82860127 85151628 795586249 157408413 858298559 578884196 687568581 472309769 355929158 351941926 360039605 388406355 912464382 765819639 737151920 108486821 913482198 701899705 72140621 413030165 428817685 877125998 74484...
result:
ok 400 lines
Test #43:
score: 0
Accepted
time: 306ms
memory: 653352kb
input:
200000 400 1 2 1 3 2 4 2 5 3 6 6 7 1 1394 8 9 8 10 10 11 8 12 12 13 11 14 1 13 8 1395 15 16 15 17 15 18 17 19 15 20 17 21 10 15 15 1396 22 23 23 24 23 25 25 26 24 27 23 28 15 28 22 1397 29 30 30 31 29 32 31 33 31 34 30 35 22 32 29 1398 36 37 36 38 37 39 36 40 39 41 39 42 34 41 36 1399 43 44 43 45 45...
output:
1 3 8 20 48 112 256 576 1280 2816 6144 13312 28672 61440 131072 278528 589824 1245184 2621440 5505024 11534336 24117248 50331648 104857600 218103808 452984832 939524096 947912703 33554428 335544312 209715183 494927837 142606263 587202410 780140235 771751300 964688613 771749252 226486909 813683687 35...
result:
ok 400 lines
Test #44:
score: 0
Accepted
time: 292ms
memory: 653236kb
input:
200000 400 1 2 2 3 2 4 3 5 2 6 1 7 1 1394 8 9 9 10 10 11 8 12 11 13 9 14 3 11 8 1395 15 16 16 17 15 18 17 19 18 20 17 21 13 16 15 1396 22 23 23 24 22 25 23 26 26 27 25 28 18 28 22 1397 29 30 29 31 31 32 30 33 30 34 29 35 27 34 29 1398 36 37 37 38 36 39 37 40 36 41 39 42 30 41 36 1399 43 44 44 45 45 ...
output:
1 3 8 20 48 112 256 576 1280 2816 6144 13312 28672 61440 131072 278528 589824 1245184 2621440 5505024 11534336 24117248 50331648 104857600 218103808 452984832 939524096 947912703 33554428 335544312 209715183 494927837 142606263 587202410 780140235 771751300 964688613 771749252 226486909 813683687 35...
result:
ok 400 lines
Test #45:
score: 0
Accepted
time: 296ms
memory: 653168kb
input:
200000 400 1 2 2 3 3 4 1 5 4 6 2 7 1 1394 8 9 8 10 9 11 8 12 12 13 8 14 1 14 8 1395 15 16 15 17 17 18 18 19 17 20 15 21 9 19 15 1396 22 23 22 24 24 25 23 26 24 27 26 28 19 28 22 1397 29 30 30 31 31 32 30 33 30 34 33 35 24 33 29 1398 36 37 36 38 38 39 39 40 40 41 39 42 29 41 36 1399 43 44 43 45 45 46...
output:
1 3 8 20 48 112 256 576 1280 2816 6144 13312 28672 61440 131072 278528 589824 1245184 2621440 5505024 11534336 24117248 50331648 104857600 218103808 452984832 939524096 947912703 33554428 335544312 209715183 494927837 142606263 587202410 780140235 771751300 964688613 771749252 226486909 813683687 35...
result:
ok 400 lines
Test #46:
score: 0
Accepted
time: 275ms
memory: 653232kb
input:
200000 400 1 2 1 3 1 4 3 5 1 6 1 7 1 1394 8 9 9 10 8 11 10 12 11 13 13 14 6 13 8 1395 15 16 15 17 17 18 18 19 15 20 15 21 10 19 15 1396 22 23 23 24 24 25 23 26 26 27 27 28 16 26 22 1397 29 30 29 31 29 32 30 33 30 34 34 35 27 35 29 1398 36 37 37 38 37 39 37 40 39 41 40 42 31 39 36 1399 43 44 44 45 44...
output:
1 3 8 20 48 112 256 576 1280 2816 6144 13312 28672 61440 131072 278528 589824 1245184 2621440 5505024 11534336 24117248 50331648 104857600 218103808 452984832 939524096 947912703 33554428 335544312 209715183 494927837 142606263 587202410 780140235 771751300 964688613 771749252 226486909 813683687 35...
result:
ok 400 lines
Test #47:
score: 0
Accepted
time: 3ms
memory: 16032kb
input:
2 1 1 2
output:
1
result:
ok single line: '1'
Test #48:
score: 0
Accepted
time: 0ms
memory: 16168kb
input:
1 1
output:
1
result:
ok single line: '1'
Test #49:
score: 0
Accepted
time: 3ms
memory: 16276kb
input:
2 2 2 1
output:
1 1
result:
ok 2 lines
Extra Test:
score: 0
Extra Test Passed