QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#277754#7772. 意念力yyyyxh100 ✓1119ms67064kbC++235.9kb2023-12-06 22:19:462023-12-06 22:19:46

Judging History

你现在查看的是最新测评结果

  • [2023-12-06 22:19:46]
  • 评测
  • 测评结果:100
  • 用时:1119ms
  • 内存:67064kb
  • [2023-12-06 22:19:46]
  • 提交

answer

#include <cstdio>
#include <vector>
#include <cassert>
#include <algorithm>
#define lc (p<<1)
#define rc (p<<1|1)
#define ALL(p) p.begin(),p.end()
#define IL inline
#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<22,stdin)),p1==p2?EOF:*p1++)
using namespace std;
char buf[1<<22],*p1=buf,*p2=buf;
template<typename T>
T read(){
	char c=getchar();T x=0;
	while(c<48||c>57) c=getchar();
	do x=(x<<1)+(x<<3)+(c^48),c=getchar();
	while(c>=48&&c<=57);
	return x;
}
typedef vector<int> vi;
const int P=998244353,N=100003;
typedef long long ll;
IL int qp(int a,int b=P-2){
	int res=1;
	while(b){
		if(b&1) res=(ll)res*a%P;
		a=(ll)a*a%P;b>>=1;
	}
	return res;
}
int len,ilen,bt;
int rev[1<<20],cw[1<<20|1];
IL void init(int _len){ // mod x^len
	len=1;bt=-1;
	while(len<_len) len<<=1,++bt;
	int w=qp(3,(P-1)>>(bt+1));
	cw[0]=cw[len]=1;
	for(int i=1;i<len;++i){
		cw[i]=(ll)cw[i-1]*w%P;
		rev[i]=(rev[i>>1]>>1)|((i&1)<<bt);
	}
	ilen=qp(len);
}
struct poly{
	vi f;
	poly():f(){}
	poly(int Len):f(Len){}
	poly(initializer_list<int> Init):f(Init){}
	IL void NTT(){
		f.resize(len,0);
		for(int i=1;i<len;++i) if(rev[i]<i) swap(f[rev[i]],f[i]);
		for(int i=1,tt=len>>1;i<len;i<<=1,tt>>=1)
			for(int j=0;j<len;j+=(i<<1))
				for(int k=j,t=0;k<(j|i);++k,t+=tt){
					int x=f[k],y=(ll)f[k|i]*cw[t]%P;
					if((f[k]=x+y)>=P) f[k]-=P;
					if((f[k|i]=x-y)<0) f[k|i]+=P;
				}
	}
	IL void INTT(){
		for(int i=1;i<len;++i) if(rev[i]<i) swap(f[rev[i]],f[i]);
		for(int i=1,tt=len>>1;i<len;i<<=1,tt>>=1)
			for(int j=0;j<len;j+=(i<<1))
				for(int k=j,t=len;k<(j|i);++k,t-=tt){
					int x=f[k],y=(ll)f[k|i]*cw[t]%P;
					if((f[k]=x+y)>=P) f[k]-=P;
					if((f[k|i]=x-y)<0) f[k|i]+=P;
				}
		for(int i=0;i<len;++i) f[i]=(ll)f[i]*ilen%P;
	}
	IL void reduce(){while(!f.empty()&&!f.back()) f.pop_back();}
	IL void trunc(int lim){
		if(lim<int(f.size())) f.erase(f.begin()+lim,f.end());
	}
	IL poly inv(int lim){ // mod x^lim
		assert(f[0]);
		poly cur({qp(f[0])});
		for(int t=1;t<lim;t<<=1){
			poly ff(t<<2);
			copy(f.begin(),f.begin()+min(t<<1,int(f.size())),ff.f.begin());
			init(t<<2);ff.NTT();cur.NTT();
			poly tmp(len);
			for(int i=0;i<len;++i){
				tmp.f[i]=(2ll-(ll)cur.f[i]*ff.f[i])%P*cur.f[i]%P;
				if(tmp.f[i]<0) tmp.f[i]+=P;
			}
			tmp.INTT();
			cur.f.swap(tmp.f);
			cur.trunc(t<<1);
		}
		cur.trunc(lim);
		return cur;
	}
	IL void prod(poly A,poly B){
		init(A.f.size()+B.f.size()-1);A.NTT();B.NTT();
		f.resize(len);
		for(int i=0;i<len;++i) f[i]=(ll)A.f[i]*B.f[i]%P;
		INTT();reduce();
	}
	IL void prodT(poly A,poly B){
		int an=A.f.size()-1,bn=B.f.size()-1;
		reverse(ALL(B.f));prod(A,B);
		for(int i=0;i<=an;++i) f[i]=f[i+bn];
		trunc(an+1);
	}
	IL int calc(int t){
		int pw=1,res=0;
		for(int x:f){
			res=(res+(ll)pw*x)%P;
			if(res>=P) res-=P;
			pw=(ll)pw*t%P;
		}
		return res;
	}
}F;
int n;ll k;
int res[N];
namespace multieval{
	poly G[N<<2],H[N<<2];
	void calc(int p,int l,int r){
		if(l==r){G[p]=poly({1,P-r});return;}
		int mid=(l+r)>>1;
		calc(lc,l,mid);
		calc(rc,mid+1,r);
		G[p].prod(G[lc],G[rc]);
	}
	void solve(int p,int l,int r){
		H[p].trunc(r-l+1);
		if(l==r){res[r]=H[p].f[0];return;}
		int mid=(l+r)>>1;
		G[p].f.clear();G[p].f.shrink_to_fit();
		H[lc].prodT(H[p],G[rc]);
		H[rc].prodT(H[p],G[lc]);
		H[p].f.clear();H[p].f.shrink_to_fit();
		solve(lc,l,mid);
		solve(rc,mid+1,r);
	}
	IL void solve(){
		calc(1,1,n);
		H[1].prodT(F,G[1].inv(n+1));
		solve(1,1,n);
	}
}
int hd[N],ver[N<<1],nxt[N<<1],val[N<<1],tot;
IL void add(int u,int v,int w){
	nxt[++tot]=hd[u];hd[u]=tot;ver[tot]=v;val[tot]=w;
}
ll de[N];
int p[N],ip[N],d[N];
IL bool cmp(int x,int y){return de[x]<de[y];}
void dfs(int u,int fa){
	for(int i=hd[u];i;i=nxt[i]){
		int v=ver[i];
		if(v==fa) continue;
		de[v]=de[u]+val[i];
		dfs(v,u);
	}
}
bool del[N];
int sz[N],sn[N];
void getsiz(int u,int fa){
	sz[u]=1;sn[u]=0;
	for(int i=hd[u];i;i=nxt[i]){
		int v=ver[i];
		if(v==fa||del[v]) continue;
		getsiz(v,u);
		sz[u]+=sz[v];
		if(sz[v]>sz[sn[u]]) sn[u]=v;
	}
}
int seq[N],rk;
int stk[N],tp;
int tr[N];
IL void upd(int x,int v){
	for(int i=x;i<=n;i+=(i&-i)) tr[i]+=v;
}
IL int qry(int x){
	int res=0;
	for(int i=x;i;i^=(i&-i)) res+=tr[i];
	return res;
}
IL void work(int *arr,int len,int c){
	sort(arr+1,arr+len+1,cmp);
	int e=1;
	for(int i=len;i;--i){
		int x=arr[i];
		while(e<=len&&de[arr[e]]+de[x]<k) upd(ip[arr[e++]],1);
		d[x]+=qry(ip[x])*c;
	}
	while(e>1) upd(ip[arr[--e]],-1);
}
IL void trav(int u,int fa){
	sz[u]=1;stk[++tp]=u;
	for(int i=hd[u];i;i=nxt[i]){
		int v=ver[i];
		if(v==fa||del[v]) continue;
		de[v]=de[u]+val[i];
		trav(v,u);
		sz[u]+=sz[v];
	}
}
void proc(int u,int all){
	getsiz(u,0);
	while(2*sz[sn[u]]>all) u=sn[u];
	del[u]=1;de[u]=0;
	seq[rk=1]=u;++d[u];
	for(int i=hd[u];i;i=nxt[i]){
		int v=ver[i];
		if(del[v]) continue;
		de[v]=de[u]+val[i];
		trav(v,u);
		work(stk,tp,-1);
		while(tp) seq[++rk]=stk[tp--];
	}
	work(seq,rk,1);
	for(int i=hd[u];i;i=nxt[i]){
		int v=ver[i];
		if(del[v]) continue;
		proc(v,sz[v]);
	}
}
poly eval(int l,int r){
	if(l==r) return poly({(P-d[r]+2)%P,1});
	int mid=(l+r)>>1;
	poly tmp;
	tmp.prod(eval(l,mid),eval(mid+1,r));
	return tmp;
}
int fac[N],fiv[N];
int main(){
	n=read<int>();k=read<ll>();
	for(int i=1;i<n;++i){
		int u=read<int>(),v=read<int>(),w=read<int>();
		add(u,v,w);add(v,u,w);
	}
	dfs(1,0);
	for(int i=1;i<=n;++i) p[i]=i;
	sort(p+1,p+n+1,cmp);
	for(int i=1;i<=n;++i) ip[p[i]]=i;
	proc(1,n);
	F=eval(1,n);
	multieval::solve();
	fac[0]=1;
	for(int i=1;i<=n;++i) fac[i]=(ll)fac[i-1]*i%P;
	fiv[n]=qp(fac[n]);
	for(int i=n;i;--i) fiv[i-1]=(ll)fiv[i]*i%P;
	poly U(n+1),V(n+1);
	for(int i=0;i<=n;++i){
		U.f[i]=(ll)res[i]*fiv[i]%P;
		V.f[i]=fiv[i];
		if(U.f[i]&&(i&1)) U.f[i]=P-U.f[i];
	}
	poly W;
	W.prod(U,V);
	for(int i=1;i<=n;++i)
		if(W.f[i]&&(i&1)) printf("%d ",P-W.f[i]);
		else printf("%d ",W.f[i]);
	putchar('\n');
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 10
Accepted

Test #1:

score: 10
Accepted
time: 0ms
memory: 28384kb

input:

10 586964961
10 4 500997470
4 5 361413298
5 3 239036149
5 6 187680375
3 1 199761661
1 2 459686305
6 7 8390746
7 8 59889425
7 9 419949781

output:

0 0 0 0 192 708 636 203 25 1 

result:

ok 10 numbers

Test #2:

score: 0
Accepted
time: 3ms
memory: 28332kb

input:

10 496325758
3 10 66740689
10 7 456797411
7 9 33319567
9 8 23850338
7 4 698698151
9 6 85638167
4 1 239701723
6 5 11453081
1 2 27039301

output:

0 0 0 0 720 1680 1110 282 29 1 

result:

ok 10 numbers

Test #3:

score: 0
Accepted
time: 0ms
memory: 30712kb

input:

10 206036637
1 4 60775873
1 9 331998567
1 3 106469067
4 10 157533279
3 6 296084755
3 8 488192398
6 7 215556090
6 5 209447883
5 2 1467187

output:

0 0 972 8244 16270 11846 3815 579 40 1 

result:

ok 10 numbers

Subtask #2:

score: 15
Accepted

Test #4:

score: 15
Accepted
time: 11ms
memory: 29084kb

input:

2000 4
325 968 1
968 1118 1
325 430 1
325 1693 1
430 676 1
430 199 1
1693 631 1
631 362 1
325 385 1
676 1441 1
199 1087 1
430 1583 1
1118 674 1
968 1690 1
325 1340 1
199 1718 1
1340 987 1
1690 34 1
362 607 1
607 277 1
34 718 1
1583 1804 1
987 498 1
607 1567 1
362 1332 1
1583 1443 1
607 1920 1
430 76...

output:

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 34396558 560597970 342257989 111016545 648115845 896789689 629359408 787287175 225051136 369808516 679693851 350349341 87270678 655949285 424883363 48112584 924467409 910138594 952274861 286758842 346948302 140881427 121554860 465126000 481298451 326871880 970926640...

result:

ok 2000 numbers

Test #5:

score: 0
Accepted
time: 12ms
memory: 31180kb

input:

2000 72
1430 1960 1
1960 1174 1
1174 1305 1
1430 696 1
696 58 1
696 1185 1
1430 610 1
1185 1512 1
1430 1358 1
58 388 1
610 1000 1
388 157 1
1185 1966 1
610 890 1
1966 329 1
1185 800 1
1358 1316 1
890 1517 1
388 1708 1
157 1116 1
157 21 1
1517 1612 1
1612 879 1
1708 567 1
1708 1850 1
1316 124 1
567 5...

output:

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 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 2000 numbers

Test #6:

score: 0
Accepted
time: 12ms
memory: 28884kb

input:

2000 99
117 583 1
117 1553 1
1553 301 1
1553 912 1
912 1582 1
912 1045 1
1582 522 1
1045 898 1
1045 385 1
898 1090 1
385 1499 1
1090 1790 1
1499 1347 1
1499 417 1
1347 1465 1
1465 1932 1
417 291 1
1465 345 1
1932 1312 1
345 1027 1
1027 210 1
1312 1180 1
210 588 1
210 1156 1
1156 1901 1
1901 1662 1
1...

output:

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 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 2000 numbers

Subtask #3:

score: 15
Accepted

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Test #7:

score: 15
Accepted
time: 13ms
memory: 30884kb

input:

2000 1451615371
1496 1341 49707670
1341 444 345030850
1496 1007 685475095
444 1909 278749381
1909 1110 3639571
1341 1869 60712733
1869 521 19317650
1007 732 443227891
444 1258 126491905
1496 1004 482872791
1110 1504 31497121
1004 279 30903287
521 1485 375275915
1007 605 72133480
1869 1570 326176977
...

output:

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 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 2000 numbers

Test #8:

score: 0
Accepted
time: 10ms
memory: 28908kb

input:

2000 18850124083
950 1232 22289119
1232 1743 201827311
950 852 235698364
1743 430 879933721
950 416 192976076
1743 195 44313799
950 318 36655137
416 1669 371460821
416 1541 46177715
430 1339 66159023
852 1642 517803961
195 358 294138445
1669 671 183145735
195 1096 412001955
318 1549 213915493
1339 1...

output:

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 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 2000 numbers

Test #9:

score: 0
Accepted
time: 13ms
memory: 31256kb

input:

2000 24843324444
1717 1032 273506143
1717 1999 561959269
1999 1982 29071225
1982 1537 8968261
1982 768 2135953
1982 1125 432656466
1537 1291 56651365
1125 302 269030781
302 1842 161254215
302 138 76677902
138 1663 558013730
1842 1384 269534851
1384 1706 317644801
1663 1240 280572041
1706 628 5688469...

output:

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 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 2000 numbers

Subtask #4:

score: 15
Accepted

Test #10:

score: 15
Accepted
time: 938ms
memory: 66360kb

input:

100000 49999
1 2 1
2 3 1
3 4 1
4 5 1
5 6 1
6 7 1
7 8 1
8 9 1
9 10 1
10 11 1
11 12 1
12 13 1
13 14 1
14 15 1
15 16 1
16 17 1
17 18 1
18 19 1
19 20 1
20 21 1
21 22 1
22 23 1
23 24 1
24 25 1
25 26 1
26 27 1
27 28 1
28 29 1
29 30 1
30 31 1
31 32 1
32 33 1
33 34 1
34 35 1
35 36 1
36 37 1
37 38 1
38 39 1
...

output:

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 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 100000 numbers

Test #11:

score: 0
Accepted
time: 841ms
memory: 61468kb

input:

100000 89999
1 2 1
2 3 1
3 4 1
4 5 1
5 6 1
6 7 1
7 8 1
8 9 1
9 10 1
10 11 1
11 12 1
12 13 1
13 14 1
14 15 1
15 16 1
16 17 1
17 18 1
18 19 1
19 20 1
20 21 1
21 22 1
22 23 1
23 24 1
24 25 1
25 26 1
26 27 1
27 28 1
28 29 1
29 30 1
30 31 1
31 32 1
32 33 1
33 34 1
34 35 1
35 36 1
36 37 1
37 38 1
38 39 1
...

output:

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 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 100000 numbers

Test #12:

score: 0
Accepted
time: 1048ms
memory: 66112kb

input:

100000 9999
1 2 1
2 3 1
3 4 1
4 5 1
5 6 1
6 7 1
7 8 1
8 9 1
9 10 1
10 11 1
11 12 1
12 13 1
13 14 1
14 15 1
15 16 1
16 17 1
17 18 1
18 19 1
19 20 1
20 21 1
21 22 1
22 23 1
23 24 1
24 25 1
25 26 1
26 27 1
27 28 1
28 29 1
29 30 1
30 31 1
31 32 1
32 33 1
33 34 1
34 35 1
35 36 1
36 37 1
37 38 1
38 39 1
3...

output:

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 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 100000 numbers

Subtask #5:

score: 15
Accepted

Dependency #1:

100%
Accepted

Dependency #4:

100%
Accepted

Test #13:

score: 15
Accepted
time: 926ms
memory: 66644kb

input:

100000 13263852090411
1 2 125807845
2 3 212692191
3 4 239521145
4 5 602330743
5 6 73379737
6 7 385714963
7 8 454319901
8 9 26509162
9 10 623911298
10 11 630961501
11 12 617362129
12 13 57632397
13 14 540398476
14 15 51636311
15 16 142241401
16 17 514331280
17 18 375448890
18 19 92240301
19 20 374139...

output:

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 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 100000 numbers

Test #14:

score: 0
Accepted
time: 819ms
memory: 63464kb

input:

100000 23978785130960
1 2 21127781
2 3 97510471
3 4 272199663
4 5 129512097
5 6 66154591
6 7 39439131
7 8 334112365
8 9 396429697
9 10 506784181
10 11 356004809
11 12 366299987
12 13 56999785
13 14 159675137
14 15 765389623
15 16 84636940
16 17 93087306
17 18 1013893
18 19 107562136
19 20 141823441
...

output:

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 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 100000 numbers

Test #15:

score: 0
Accepted
time: 935ms
memory: 62816kb

input:

100000 287323586802
1 2 1
2 3 1
3 4 3
4 5 5
5 6 3
6 7 1
7 8 1
8 9 3
9 10 6
10 11 7
11 12 4
12 13 9
13 14 1
14 15 1
15 16 5
16 17 4
17 18 3
18 19 6
19 20 7
20 21 9
21 22 8
22 23 5
23 24 5
24 25 1
25 26 1
26 27 3
27 28 5
28 29 5
29 30 8
30 31 5
31 32 1
32 33 3
33 34 7
34 35 1
35 36 9
36 37 1
37 38 6
3...

output:

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 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 100000 numbers

Test #16:

score: 0
Accepted
time: 932ms
memory: 67064kb

input:

100000 26778924982
1 2 3
2 3 4
3 4 9
4 5 1
5 6 5
6 7 3
7 8 1
8 9 1
9 10 3
10 11 2
11 12 7
12 13 5
13 14 2
14 15 3
15 16 5
16 17 6
17 18 3
18 19 1
19 20 1
20 21 1
21 22 1
22 23 8
23 24 3
24 25 4
25 26 7
26 27 1
27 28 4
28 29 1
29 30 9
30 31 7
31 32 5
32 33 3
33 34 3
34 35 9
35 36 6
36 37 6
37 38 8
38...

output:

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 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 100000 numbers

Test #17:

score: 0
Accepted
time: 938ms
memory: 61492kb

input:

100000 2706473915
1 2 2
2 3 3
3 4 1
4 5 7
5 6 3
6 7 5
7 8 5
8 9 5
9 10 5
10 11 9
11 12 1
12 13 6
13 14 7
14 15 3
15 16 7
16 17 9
17 18 3
18 19 1
19 20 1
20 21 4
21 22 9
22 23 1
23 24 1
24 25 9
25 26 9
26 27 10
27 28 9
28 29 3
29 30 5
30 31 2
31 32 7
32 33 9
33 34 10
34 35 9
35 36 5
36 37 7
37 38 9
3...

output:

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 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 100000 numbers

Subtask #6:

score: 15
Accepted

Dependency #2:

100%
Accepted

Dependency #4:

100%
Accepted

Test #18:

score: 15
Accepted
time: 992ms
memory: 59460kb

input:

100000 9068
69440 52256 1
69440 83089 1
69440 94352 1
52256 91376 1
91376 83238 1
52256 89768 1
91376 33724 1
89768 26830 1
94352 80177 1
91376 9192 1
94352 87232 1
9192 51458 1
83238 98011 1
83238 88887 1
88887 77270 1
87232 45542 1
9192 91166 1
88887 84875 1
98011 48031 1
48031 99586 1
77270 46971...

output:

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 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 100000 numbers

Test #19:

score: 0
Accepted
time: 1020ms
memory: 58456kb

input:

100000 492
96232 74188 1
74188 71245 1
96232 86046 1
86046 90417 1
86046 54649 1
96232 24898 1
96232 61964 1
74188 74009 1
90417 91168 1
96232 98784 1
96232 92160 1
74009 82674 1
54649 89765 1
86046 94252 1
24898 77735 1
74009 88030 1
96232 76695 1
91168 88831 1
77735 79528 1
86046 79644 1
54649 157...

output:

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 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 100000 numbers

Test #20:

score: 0
Accepted
time: 1097ms
memory: 55084kb

input:

100000 1820
91599 39208 1
91599 26809 1
91599 66606 1
26809 34935 1
34935 98110 1
66606 22131 1
66606 61150 1
26809 63337 1
26809 67353 1
91599 83940 1
67353 93322 1
63337 42679 1
22131 84494 1
34935 99268 1
42679 86821 1
84494 98736 1
83940 74906 1
86821 78948 1
84494 91224 1
83940 99805 1
98736 73...

output:

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 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 100000 numbers

Test #21:

score: 0
Accepted
time: 889ms
memory: 54952kb

input:

100000 16374
85304 59107 1
59107 54182 1
59107 13098 1
59107 59350 1
59107 76509 1
13098 99436 1
59350 82717 1
13098 65060 1
99436 82905 1
59107 85165 1
59107 96174 1
76509 42678 1
96174 9004 1
42678 99806 1
96174 98354 1
99806 94848 1
96174 93361 1
85165 75306 1
75306 60158 1
85165 91353 1
42678 91...

output:

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 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 100000 numbers

Test #22:

score: 0
Accepted
time: 1107ms
memory: 59572kb

input:

100000 1106
97539 64391 1
64391 89243 1
89243 99575 1
89243 90429 1
64391 92533 1
99575 95908 1
90429 82932 1
99575 82134 1
90429 77559 1
82134 71262 1
71262 94673 1
82134 83913 1
77559 96727 1
77559 73969 1
94673 92253 1
92253 30844 1
92253 99069 1
92253 72219 1
92253 71509 1
72219 62306 1
99069 96...

output:

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 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 100000 numbers

Subtask #7:

score: 15
Accepted

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Dependency #3:

100%
Accepted

Dependency #4:

100%
Accepted

Dependency #5:

100%
Accepted

Dependency #6:

100%
Accepted

Test #23:

score: 15
Accepted
time: 986ms
memory: 60240kb

input:

100000 2418281403029
84015 45780 401657711
45780 66164 25505611
84015 62142 129669033
84015 82806 516122920
66164 79160 43075265
79160 66797 10379359
84015 86814 264371829
86814 96961 299843523
96961 68022 282612723
86814 87439 145410185
87439 92904 270871465
68022 84252 190033201
62142 77100 361618...

output:

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 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 100000 numbers

Test #24:

score: 0
Accepted
time: 1038ms
memory: 56012kb

input:

100000 133760570773
47390 50927 83452083
50927 84773 8324416
47390 70203 4369834
47390 53093 134685646
84773 87805 928955189
70203 84556 181701517
70203 66959 26057920
70203 54335 14162164
70203 85641 115301395
53093 86851 21902641
87805 72716 386860497
85641 6539 14987643
47390 66270 79946641
54335...

output:

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 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 100000 numbers

Test #25:

score: 0
Accepted
time: 1103ms
memory: 56528kb

input:

100000 489583943550
72338 90954 145295929
90954 66627 24618331
66627 39912 724025821
90954 62890 403017525
72338 51483 616741217
90954 85308 204481349
66627 54533 138463720
62890 8313 99112461
8313 28614 92766187
85308 53933 258394513
66627 29453 8154497
8313 34865 95146681
8313 74237 131605501
2861...

output:

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 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 100000 numbers

Test #26:

score: 0
Accepted
time: 915ms
memory: 59440kb

input:

100000 4394939857119
80936 96018 68735877
96018 69278 236811532
96018 71682 177309589
80936 29283 444812345
96018 86412 177048351
71682 96455 220533952
69278 97419 628654573
96018 82572 481498862
96455 5634 217619812
29283 94680 101768561
96455 74038 172597286
5634 45836 46902049
94680 62601 1409485...

output:

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 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 100000 numbers

Test #27:

score: 0
Accepted
time: 1119ms
memory: 57208kb

input:

100000 296164092463
93678 15359 535956721
93678 69347 23593821
15359 82120 643418377
82120 95282 410468165
15359 23598 311136775
95282 36578 62110113
95282 91991 497695741
91991 91175 742959469
91175 41797 18250937
36578 90024 255529081
36578 97407 340226305
90024 4280 251217615
90024 84975 15453220...

output:

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 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 100000 numbers