QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#548639 | #8670. 独立 | zhouhuanyi | 100 ✓ | 291ms | 20212kb | C++14 | 3.7kb | 2024-09-05 19:42:03 | 2024-09-05 19:42:03 |
Judging History
answer
#include<iostream>
#include<cstdio>
#include<vector>
#define N 2001
#define K 12
#define M 4096
#define g 3
#define mod 998244353
using namespace std;
int read()
{
char c=0;
int sum=0;
while (c<'0'||c>'9') c=getchar();
while ('0'<=c&&c<='9') sum=sum*10+c-'0',c=getchar();
return sum;
}
int fast_pow(int a,int b)
{
int res=1,mul=a;
while (b)
{
if (b&1) res=1ll*res*mul%mod;
mul=1ll*mul*mul%mod,b>>=1;
}
return res;
}
void Adder(int &x,int d)
{
x=x+d>=mod?x+d-mod:x+d;
return;
}
void Adder2(int &x,int d)
{
x=x+d<0?x+d+mod:x+d;
return;
}
int MD(int x)
{
return x>=mod?x-mod:x;
}
int MD2(int x)
{
return x<0?x+mod:x;
}
int n,m,ans,length,sz[N+1],szt[N+1],A[N+1],B[N+1],rev[M+1],tA[M+1],tB[M+1],wn[K+1][M+1],wn2[K+1][M+1],num[M+1],delta[N+1],delta2[N+1],fac[N+1],invfac[N+1],inv[N+1],pw[N+1],F[N+1],dp[N+1][N+1];
bool used[N+1];
vector<int>E[N+1];
void add(int x,int y)
{
E[x].push_back(y),E[y].push_back(x);
return;
}
int calc(int x)
{
int res=0;
for (int i=0;i<=szt[x];++i) Adder(res,1ll*dp[x][i]*delta[i]%mod);
return res;
}
int calc2(int x)
{
int res=0;
for (int i=0;i<=szt[x];++i) Adder(res,1ll*dp[x][i]*delta2[i]%mod);
return res;
}
void NTT(int limit,int *s,int type)
{
int s1,s2;
for (int i=1;i<limit;++i) rev[i]=(rev[i>>1]>>1)|((i&1)?limit>>1:0);
for (int i=0;i<limit;++i)
if (rev[i]>i)
swap(s[i],s[rev[i]]);
if (type==1)
{
for (int i=2;i<=limit;i<<=1)
for (int j=0;j+i-1<limit;j+=i)
for (int k=j;k<j+(i>>1);++k)
s1=s[k],s2=1ll*s[k+(i>>1)]*wn[num[i]][k-j]%mod,s[k]=MD(s1+s2),s[k+(i>>1)]=MD2(s1-s2);
}
else
{
for (int i=2;i<=limit;i<<=1)
for (int j=0;j+i-1<limit;j+=i)
for (int k=j;k<j+(i>>1);++k)
s1=s[k],s2=1ll*s[k+(i>>1)]*wn2[num[i]][k-j]%mod,s[k]=MD(s1+s2),s[k+(i>>1)]=MD2(s1-s2);
s1=fast_pow(limit,mod-2);
for (int i=0;i<=limit;++i) s[i]=1ll*s[i]*s1%mod;
}
return;
}
void dfs(int x)
{
int limit=1;
used[x]=1,sz[x]=1,szt[x]=0,dp[x][0]=1;
for (int i=0;i<E[x].size();++i)
if (!used[E[x][i]])
{
dfs(E[x][i]),sz[x]+=sz[E[x][i]];
for (int j=0;j<=szt[x]+szt[E[x][i]];++j) F[j]=0;
for (int j=0;j<=szt[x];++j)
for (int k=0;k<=szt[E[x][i]];++k)
Adder(F[j+k],1ll*dp[x][j]*dp[E[x][i]][k]%mod);
szt[x]+=szt[E[x][i]];
for (int j=0;j<=szt[x];++j) dp[x][j]=F[j];
}
szt[x]++;
for (int i=szt[x];i>=1;--i) dp[x][i]=dp[x][i-1];
dp[x][0]=0;
while (limit<=(szt[x]<<1)) limit<<=1;
for (int i=0;i<=limit;++i) tA[i]=tB[i]=0;
for (int i=0;i<=szt[x];++i) tA[i]=1ll*dp[x][i]*A[i]%mod,tB[szt[x]-i]=invfac[i];
NTT(limit,tA,1),NTT(limit,tB,1);
for (int i=0;i<=limit;++i) tA[i]=1ll*tA[i]*tB[i]%mod;
NTT(limit,tA,-1);
for (int i=0;i<=szt[x];++i) dp[x][i]=(i&1)?1ll*tA[szt[x]+i]*B[i]%mod:MD2(-1ll*tA[szt[x]+i]*B[i]%mod);
Adder(dp[x][0],MD2(pw[sz[x]]-calc(x))),Adder(ans,1ll*calc2(x)*pw[n-sz[x]]%mod);
return;
}
int main()
{
int x,y;
fac[0]=1;
for (int i=1;i<=N;++i) fac[i]=1ll*fac[i-1]*i%mod;
invfac[N]=fast_pow(fac[N],mod-2);
for (int i=N-1;i>=0;--i) invfac[i]=1ll*invfac[i+1]*(i+1)%mod;
for (int i=1;i<=N;++i) inv[i]=1ll*fac[i-1]*invfac[i]%mod;
for (int i=2,w;i<=M;i<<=1)
{
num[i]=++length,w=fast_pow(g,(mod-1)/i);
for (int j=0,res=1;j<(i>>1);++j,res=1ll*res*w%mod) wn[num[i]][j]=res;
w=fast_pow(g,(mod-1)/i*(i-1));
for (int j=0,res=1;j<(i>>1);++j,res=1ll*res*w%mod) wn2[num[i]][j]=res;
}
n=read(),m=read(),pw[0]=A[0]=B[0]=1;
for (int i=1;i<=n;++i) A[i]=1ll*A[i-1]*(m+i)%mod,B[i]=1ll*B[i-1]*fast_pow(m+i,mod-2)%mod;
for (int i=0;i<=n;++i) delta[i]=1ll*A[i]*invfac[i]%mod,delta2[i]=1ll*A[i]*m%mod*invfac[i+1]%mod*i%mod;
for (int i=1;i<=n;++i) pw[i]=1ll*pw[i-1]*m%mod;
for (int i=1;i<=n-1;++i) x=read(),y=read(),add(x,y);
dfs(1),printf("%d\n",ans);
return 0;
}
詳細信息
Subtask #1:
score: 11
Accepted
Test #1:
score: 11
Accepted
time: 0ms
memory: 4160kb
input:
4 1 1 2 1 3 1 4
output:
3
result:
ok single line: '3'
Test #2:
score: 11
Accepted
time: 1ms
memory: 4036kb
input:
2 4 1 2
output:
50
result:
ok single line: '50'
Test #3:
score: 11
Accepted
time: 1ms
memory: 4032kb
input:
3 1 1 2 1 3
output:
2
result:
ok single line: '2'
Test #4:
score: 11
Accepted
time: 1ms
memory: 4116kb
input:
5 5 1 2 1 3 1 4 4 5
output:
30873
result:
ok single line: '30873'
Test #5:
score: 11
Accepted
time: 1ms
memory: 4088kb
input:
5 5 1 2 2 3 1 4 1 5
output:
30873
result:
ok single line: '30873'
Test #6:
score: 11
Accepted
time: 1ms
memory: 4096kb
input:
5 5 1 2 1 3 2 4 3 5
output:
29268
result:
ok single line: '29268'
Subtask #2:
score: 24
Accepted
Dependency #1:
100%
Accepted
Test #7:
score: 24
Accepted
time: 0ms
memory: 6084kb
input:
20 18 1 2 2 3 1 4 1 5 1 6 1 7 5 8 1 9 1 10 2 11 5 12 11 13 5 14 5 15 3 16 7 17 15 18 9 19 19 20
output:
326123819
result:
ok single line: '326123819'
Test #8:
score: 24
Accepted
time: 1ms
memory: 5964kb
input:
18 14 1 2 2 3 3 4 2 5 1 6 4 7 7 8 5 9 6 10 7 11 2 12 1 13 4 14 4 15 8 16 3 17 1 18
output:
26385774
result:
ok single line: '26385774'
Test #9:
score: 24
Accepted
time: 1ms
memory: 4228kb
input:
20 20 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20
output:
799358395
result:
ok single line: '799358395'
Test #10:
score: 24
Accepted
time: 1ms
memory: 4196kb
input:
20 20 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 10 1 11 1 12 1 13 1 14 1 15 1 16 1 17 1 18 1 19 1 20
output:
819211514
result:
ok single line: '819211514'
Test #11:
score: 24
Accepted
time: 0ms
memory: 6188kb
input:
20 18 1 2 2 3 2 4 3 5 1 6 2 7 4 8 4 9 6 10 8 11 10 12 12 13 12 14 10 15 15 16 13 17 14 18 17 19 15 20
output:
788316439
result:
ok single line: '788316439'
Test #12:
score: 24
Accepted
time: 1ms
memory: 6064kb
input:
19 19 1 2 1 3 1 4 2 5 3 6 3 7 4 8 8 9 9 10 6 11 8 12 11 13 13 14 11 15 11 16 12 17 17 18 16 19
output:
481833846
result:
ok single line: '481833846'
Subtask #3:
score: 13
Accepted
Dependency #1:
100%
Accepted
Dependency #2:
100%
Accepted
Test #13:
score: 13
Accepted
time: 0ms
memory: 6536kb
input:
131 428 1 2 2 3 1 4 4 5 3 6 5 7 4 8 7 9 4 10 5 11 1 12 9 13 3 14 10 15 2 16 15 17 13 18 11 19 14 20 19 21 1 22 16 23 17 24 19 25 2 26 1 27 5 28 4 29 29 30 10 31 25 32 22 33 19 34 15 35 24 36 19 37 29 38 15 39 4 40 30 41 6 42 9 43 29 44 36 45 38 46 20 47 26 48 13 49 17 50 45 51 9 52 24 53 43 54 26 55...
output:
855674508
result:
ok single line: '855674508'
Test #14:
score: 13
Accepted
time: 2ms
memory: 8208kb
input:
415 425 1 2 2 3 3 4 1 5 4 6 4 7 2 8 1 9 9 10 4 11 4 12 3 13 1 14 7 15 10 16 7 17 11 18 16 19 16 20 11 21 20 22 21 23 20 24 22 25 5 26 21 27 7 28 6 29 25 30 29 31 11 32 30 33 17 34 13 35 6 36 6 37 36 38 37 39 23 40 30 41 35 42 10 43 19 44 6 45 26 46 22 47 36 48 36 49 32 50 1 51 24 52 19 53 49 54 48 5...
output:
921095443
result:
ok single line: '921095443'
Test #15:
score: 13
Accepted
time: 2ms
memory: 8924kb
input:
223 325 1 2 2 3 1 4 1 5 3 6 4 7 4 8 4 9 1 10 5 11 11 12 9 13 4 14 1 15 15 16 15 17 1 18 2 19 1 20 9 21 2 22 18 23 14 24 7 25 9 26 2 27 12 28 1 29 11 30 13 31 4 32 22 33 31 34 21 35 29 36 9 37 7 38 14 39 13 40 40 41 25 42 14 43 25 44 34 45 13 46 7 47 19 48 36 49 11 50 10 51 24 52 13 53 14 54 36 55 18...
output:
954879612
result:
ok single line: '954879612'
Test #16:
score: 13
Accepted
time: 0ms
memory: 8364kb
input:
452 126 1 2 2 3 3 4 3 5 2 6 2 7 2 8 2 9 4 10 3 11 8 12 7 13 5 14 14 15 6 16 8 17 1 18 11 19 2 20 1 21 5 22 11 23 2 24 18 25 2 26 2 27 10 28 16 29 28 30 22 31 30 32 23 33 25 34 19 35 12 36 4 37 15 38 37 39 4 40 5 41 22 42 35 43 38 44 37 45 13 46 27 47 41 48 17 49 48 50 33 51 7 52 51 53 27 54 33 55 14...
output:
374580067
result:
ok single line: '374580067'
Test #17:
score: 13
Accepted
time: 14ms
memory: 9060kb
input:
500 500 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 40 41 41 42 42 43 43 44 44 45 45 46 46 47 47 48 48 49 49 50 50 51 51 52 52 ...
output:
318407545
result:
ok single line: '318407545'
Test #18:
score: 13
Accepted
time: 2ms
memory: 8624kb
input:
500 500 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 10 1 11 1 12 1 13 1 14 1 15 1 16 1 17 1 18 1 19 1 20 1 21 1 22 1 23 1 24 1 25 1 26 1 27 1 28 1 29 1 30 1 31 1 32 1 33 1 34 1 35 1 36 1 37 1 38 1 39 1 40 1 41 1 42 1 43 1 44 1 45 1 46 1 47 1 48 1 49 1 50 1 51 1 52 1 53 1 54 1 55 1 56 1 57 1 58 1 59 1 60 1 61 ...
output:
792738825
result:
ok single line: '792738825'
Test #19:
score: 13
Accepted
time: 3ms
memory: 8232kb
input:
498 500 1 2 2 3 2 4 1 5 2 6 5 7 5 8 8 9 7 10 10 11 7 12 10 13 11 14 12 15 12 16 13 17 15 18 16 19 17 20 16 21 17 22 21 23 22 24 21 25 21 26 25 27 25 28 24 29 26 30 29 31 27 32 29 33 30 34 33 35 34 36 36 37 35 38 37 39 39 40 36 41 41 42 40 43 39 44 44 45 45 46 43 47 46 48 44 49 49 50 46 51 47 52 49 5...
output:
877351641
result:
ok single line: '877351641'
Test #20:
score: 13
Accepted
time: 4ms
memory: 11088kb
input:
499 492 1 2 2 3 2 4 2 5 1 6 3 7 5 8 8 9 7 10 6 11 11 12 8 13 10 14 13 15 13 16 14 17 15 18 17 19 18 20 18 21 17 22 20 23 21 24 21 25 21 26 25 27 26 28 27 29 29 30 28 31 30 32 30 33 29 34 32 35 35 36 34 37 33 38 38 39 37 40 39 41 37 42 41 43 40 44 40 45 43 46 44 47 47 48 46 49 46 50 48 51 49 52 52 53...
output:
839162155
result:
ok single line: '839162155'
Test #21:
score: 13
Accepted
time: 4ms
memory: 11104kb
input:
496 500 1 2 1 3 3 4 2 5 2 6 6 7 7 8 5 9 5 10 10 11 9 12 12 13 12 14 12 15 11 16 14 17 15 18 14 19 17 20 17 21 17 22 22 23 19 24 21 25 24 26 25 27 24 28 24 29 27 30 27 31 31 32 31 33 32 34 31 35 33 36 35 37 34 38 37 39 36 40 38 41 41 42 42 43 41 44 41 45 44 46 42 47 44 48 47 49 45 50 47 51 48 52 49 5...
output:
47619248
result:
ok single line: '47619248'
Test #22:
score: 13
Accepted
time: 3ms
memory: 6180kb
input:
250 500 1 2 1 3 3 4 3 5 5 6 5 7 7 8 7 9 9 10 9 11 11 12 11 13 13 14 13 15 15 16 15 17 17 18 17 19 19 20 19 21 21 22 21 23 23 24 23 25 25 26 25 27 27 28 27 29 29 30 29 31 31 32 31 33 33 34 33 35 35 36 35 37 37 38 37 39 39 40 39 41 41 42 41 43 43 44 43 45 45 46 45 47 47 48 47 49 49 50 49 51 51 52 51 5...
output:
765248458
result:
ok single line: '765248458'
Subtask #4:
score: 27
Accepted
Dependency #1:
100%
Accepted
Dependency #2:
100%
Accepted
Dependency #3:
100%
Accepted
Test #23:
score: 27
Accepted
time: 1ms
memory: 6328kb
input:
100 8917507 1 2 1 3 3 4 3 5 2 6 6 7 1 8 6 9 8 10 9 11 10 12 1 13 2 14 14 15 10 16 6 17 1 18 10 19 14 20 11 21 19 22 12 23 18 24 12 25 2 26 20 27 2 28 3 29 13 30 4 31 29 32 26 33 32 34 7 35 32 36 7 37 27 38 19 39 9 40 9 41 4 42 24 43 22 44 33 45 33 46 29 47 14 48 33 49 45 50 17 51 33 52 28 53 35 54 1...
output:
268113455
result:
ok single line: '268113455'
Test #24:
score: 27
Accepted
time: 2ms
memory: 8496kb
input:
422 19747075 1 2 2 3 1 4 3 5 3 6 4 7 4 8 8 9 9 10 5 11 8 12 10 13 7 14 2 15 15 16 8 17 15 18 14 19 4 20 1 21 11 22 20 23 11 24 14 25 15 26 7 27 17 28 9 29 23 30 12 31 3 32 16 33 1 34 30 35 16 36 17 37 28 38 29 39 32 40 3 41 10 42 33 43 37 44 19 45 17 46 26 47 5 48 44 49 42 50 31 51 29 52 40 53 51 54...
output:
946606434
result:
ok single line: '946606434'
Test #25:
score: 27
Accepted
time: 0ms
memory: 6204kb
input:
252 80449725 1 2 1 3 1 4 3 5 1 6 6 7 3 8 8 9 1 10 6 11 1 12 11 13 10 14 1 15 15 16 8 17 4 18 16 19 2 20 12 21 1 22 17 23 17 24 1 25 19 26 9 27 6 28 17 29 19 30 30 31 23 32 32 33 25 34 3 35 15 36 2 37 20 38 17 39 31 40 27 41 11 42 23 43 35 44 30 45 20 46 3 47 38 48 14 49 26 50 31 51 22 52 33 53 36 54...
output:
362245610
result:
ok single line: '362245610'
Test #26:
score: 27
Accepted
time: 0ms
memory: 8900kb
input:
405 83386580 1 2 2 3 1 4 1 5 4 6 3 7 1 8 7 9 1 10 3 11 8 12 9 13 5 14 2 15 1 16 1 17 11 18 12 19 12 20 1 21 10 22 1 23 15 24 10 25 4 26 17 27 21 28 3 29 27 30 26 31 26 32 27 33 17 34 7 35 24 36 11 37 7 38 13 39 17 40 1 41 10 42 42 43 17 44 11 45 26 46 18 47 9 48 45 49 26 50 45 51 42 52 31 53 33 54 8...
output:
678972362
result:
ok single line: '678972362'
Test #27:
score: 27
Accepted
time: 15ms
memory: 11252kb
input:
500 100000000 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 40 41 41 42 42 43 43 44 44 45 45 46 46 47 47 48 48 49 49 50 50 51 51 ...
output:
705713378
result:
ok single line: '705713378'
Test #28:
score: 27
Accepted
time: 2ms
memory: 8672kb
input:
500 100000000 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 10 1 11 1 12 1 13 1 14 1 15 1 16 1 17 1 18 1 19 1 20 1 21 1 22 1 23 1 24 1 25 1 26 1 27 1 28 1 29 1 30 1 31 1 32 1 33 1 34 1 35 1 36 1 37 1 38 1 39 1 40 1 41 1 42 1 43 1 44 1 45 1 46 1 47 1 48 1 49 1 50 1 51 1 52 1 53 1 54 1 55 1 56 1 57 1 58 1 59 1 60...
output:
244438911
result:
ok single line: '244438911'
Test #29:
score: 27
Accepted
time: 7ms
memory: 8760kb
input:
491 55280954 1 2 1 3 2 4 2 5 4 6 3 7 6 8 8 9 8 10 7 11 10 12 8 13 9 14 12 15 12 16 14 17 13 18 16 19 17 20 17 21 17 22 22 23 22 24 20 25 25 26 22 27 27 28 26 29 27 30 30 31 31 32 32 33 31 34 31 35 35 36 32 37 37 38 36 39 37 40 40 41 40 42 40 43 42 44 41 45 42 46 46 47 43 48 45 49 48 50 48 51 48 52 4...
output:
564876887
result:
ok single line: '564876887'
Test #30:
score: 27
Accepted
time: 8ms
memory: 8288kb
input:
500 11609594 1 2 1 3 2 4 1 5 4 6 2 7 7 8 8 9 5 10 6 11 8 12 8 13 9 14 13 15 15 16 13 17 15 18 14 19 15 20 20 21 18 22 22 23 23 24 24 25 25 26 25 27 24 28 24 29 28 30 27 31 30 32 28 33 32 34 32 35 31 36 36 37 33 38 34 39 36 40 38 41 37 42 38 43 39 44 43 45 42 46 43 47 47 48 45 49 48 50 50 51 49 52 49...
output:
228579924
result:
ok single line: '228579924'
Test #31:
score: 27
Accepted
time: 8ms
memory: 11064kb
input:
494 31306076 1 2 1 3 3 4 4 5 1 6 4 7 5 8 6 9 5 10 8 11 9 12 8 13 13 14 10 15 13 16 12 17 14 18 15 19 18 20 16 21 18 22 22 23 19 24 21 25 22 26 25 27 27 28 26 29 26 30 30 31 30 32 29 33 31 34 31 35 33 36 35 37 34 38 37 39 36 40 36 41 39 42 42 43 39 44 44 45 45 46 46 47 46 48 44 49 48 50 50 51 51 52 4...
output:
643295951
result:
ok single line: '643295951'
Test #32:
score: 27
Accepted
time: 3ms
memory: 6404kb
input:
250 100000000 1 2 1 3 3 4 3 5 5 6 5 7 7 8 7 9 9 10 9 11 11 12 11 13 13 14 13 15 15 16 15 17 17 18 17 19 19 20 19 21 21 22 21 23 23 24 23 25 25 26 25 27 27 28 27 29 29 30 29 31 31 32 31 33 33 34 33 35 35 36 35 37 37 38 37 39 39 40 39 41 41 42 41 43 43 44 43 45 45 46 45 47 47 48 47 49 49 50 49 51 51 5...
output:
79358352
result:
ok single line: '79358352'
Subtask #5:
score: 25
Accepted
Dependency #1:
100%
Accepted
Dependency #2:
100%
Accepted
Dependency #3:
100%
Accepted
Dependency #4:
100%
Accepted
Test #33:
score: 25
Accepted
time: 7ms
memory: 16796kb
input:
1514 72630467 1 2 1 3 1 4 4 5 5 6 1 7 1 8 5 9 3 10 6 11 6 12 5 13 3 14 12 15 8 16 16 17 4 18 11 19 13 20 14 21 18 22 22 23 23 24 9 25 19 26 17 27 24 28 4 29 11 30 17 31 2 32 14 33 12 34 15 35 28 36 6 37 28 38 24 39 25 40 16 41 6 42 18 43 15 44 8 45 13 46 20 47 33 48 37 49 30 50 16 51 7 52 41 53 23 5...
output:
771044900
result:
ok single line: '771044900'
Test #34:
score: 25
Accepted
time: 9ms
memory: 19272kb
input:
1771 2668838 1 2 2 3 1 4 2 5 4 6 3 7 6 8 8 9 3 10 6 11 9 12 10 13 10 14 13 15 15 16 2 17 8 18 12 19 10 20 14 21 16 22 9 23 18 24 6 25 17 26 26 27 1 28 26 29 20 30 18 31 12 32 1 33 23 34 33 35 4 36 1 37 26 38 24 39 37 40 7 41 28 42 12 43 33 44 16 45 30 46 20 47 3 48 30 49 22 50 50 51 22 52 41 53 2 54...
output:
573260204
result:
ok single line: '573260204'
Test #35:
score: 25
Accepted
time: 4ms
memory: 18812kb
input:
1774 710 1 2 1 3 3 4 1 5 3 6 2 7 6 8 4 9 3 10 3 11 1 12 6 13 7 14 12 15 7 16 6 17 7 18 2 19 2 20 17 21 12 22 13 23 4 24 12 25 25 26 4 27 16 28 4 29 7 30 29 31 5 32 16 33 18 34 33 35 29 36 21 37 25 38 12 39 11 40 11 41 41 42 16 43 40 44 34 45 6 46 45 47 5 48 41 49 21 50 26 51 21 52 22 53 6 54 9 55 37...
output:
362013258
result:
ok single line: '362013258'
Test #36:
score: 25
Accepted
time: 3ms
memory: 19320kb
input:
1865 952 1 2 1 3 1 4 4 5 2 6 6 7 7 8 1 9 8 10 4 11 7 12 5 13 1 14 9 15 15 16 11 17 11 18 1 19 8 20 15 21 7 22 12 23 11 24 11 25 5 26 19 27 3 28 6 29 29 30 1 31 13 32 29 33 22 34 16 35 4 36 5 37 27 38 1 39 22 40 28 41 9 42 32 43 28 44 40 45 41 46 38 47 8 48 20 49 47 50 37 51 39 52 7 53 20 54 49 55 40...
output:
996024345
result:
ok single line: '996024345'
Test #37:
score: 25
Accepted
time: 291ms
memory: 20212kb
input:
2000 100000000 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 40 41 41 42 42 43 43 44 44 45 45 46 46 47 47 48 48 49 49 50 50 51 51...
output:
426981666
result:
ok single line: '426981666'
Test #38:
score: 25
Accepted
time: 10ms
memory: 19180kb
input:
2000 100000000 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 10 1 11 1 12 1 13 1 14 1 15 1 16 1 17 1 18 1 19 1 20 1 21 1 22 1 23 1 24 1 25 1 26 1 27 1 28 1 29 1 30 1 31 1 32 1 33 1 34 1 35 1 36 1 37 1 38 1 39 1 40 1 41 1 42 1 43 1 44 1 45 1 46 1 47 1 48 1 49 1 50 1 51 1 52 1 53 1 54 1 55 1 56 1 57 1 58 1 59 1 6...
output:
646449010
result:
ok single line: '646449010'
Test #39:
score: 25
Accepted
time: 104ms
memory: 19388kb
input:
1993 76023311 1 2 1 3 2 4 3 5 4 6 4 7 3 8 5 9 8 10 7 11 7 12 11 13 11 14 11 15 11 16 16 17 17 18 14 19 17 20 17 21 19 22 20 23 19 24 24 25 22 26 23 27 26 28 28 29 28 30 30 31 29 32 28 33 32 34 31 35 32 36 33 37 36 38 36 39 39 40 36 41 41 42 38 43 39 44 42 45 43 46 44 47 45 48 46 49 47 50 49 51 50 52...
output:
579873711
result:
ok single line: '579873711'
Test #40:
score: 25
Accepted
time: 104ms
memory: 19356kb
input:
1998 30040018 1 2 1 3 3 4 2 5 2 6 3 7 7 8 7 9 7 10 8 11 7 12 10 13 11 14 10 15 13 16 12 17 15 18 16 19 15 20 18 21 18 22 19 23 21 24 23 25 24 26 23 27 25 28 28 29 25 30 29 31 29 32 29 33 33 34 34 35 33 36 34 37 34 38 37 39 39 40 38 41 41 42 38 43 40 44 42 45 44 46 42 47 43 48 48 49 49 50 48 51 47 52...
output:
964923618
result:
ok single line: '964923618'
Test #41:
score: 25
Accepted
time: 99ms
memory: 19180kb
input:
1990 943 1 2 2 3 2 4 4 5 3 6 2 7 4 8 8 9 8 10 6 11 10 12 9 13 13 14 10 15 12 16 16 17 15 18 15 19 16 20 20 21 21 22 22 23 20 24 21 25 21 26 24 27 27 28 28 29 28 30 27 31 29 32 28 33 32 34 32 35 32 36 33 37 33 38 36 39 39 40 40 41 37 42 39 43 41 44 43 45 43 46 43 47 45 48 48 49 45 50 46 51 48 52 49 5...
output:
184212933
result:
ok single line: '184212933'
Test #42:
score: 25
Accepted
time: 144ms
memory: 19800kb
input:
2000 100000000 1 2 1 3 3 4 3 5 5 6 5 7 7 8 7 9 9 10 9 11 11 12 11 13 13 14 13 15 15 16 15 17 17 18 17 19 19 20 19 21 21 22 21 23 23 24 23 25 25 26 25 27 27 28 27 29 29 30 29 31 31 32 31 33 33 34 33 35 35 36 35 37 37 38 37 39 39 40 39 41 41 42 41 43 43 44 43 45 45 46 45 47 47 48 47 49 49 50 49 51 51 ...
output:
364931793
result:
ok single line: '364931793'