QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#532850#7477. 梦断 SCOI2017Crysfly100 ✓327ms56940kbC++175.7kb2024-08-25 13:19:112024-08-25 13:19:11

Judging History

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

  • [2024-08-25 13:19:11]
  • 评测
  • 测评结果:100
  • 用时:327ms
  • 内存:56940kb
  • [2024-08-25 13:19:11]
  • 提交

answer

#include<bits/stdc++.h>
#define For(i,a,b) for(register int i=(a);i<=(b);++i)
#define Rep(i,a,b) for(register int i=(a);i>=(b);--i)
using namespace std;
inline int read()
{
	char c=getchar();int x=0;bool f=0;
	for(;!isdigit(c);c=getchar())f^=!(c^45);
	for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+(c^48);
	if(f)x=-x;return x;
}

#define fi first
#define se second
#define pb push_back
#define mkp make_pair
typedef pair<int,int>pii;
typedef vector<int>vi;

#define N 200005
#define inf 0x3f3f3f3f

const int A=(1u<<31)-1;
int n,m,c[N],pa[N],l[N],r[N],dep[N];
int anc[N][18];
vi e[N];

int pre[N],suf[N],mn[N],mx[N],sz[N],tou[N];
int ch[N][2],fa[N],tag[N],col[N],ctag[N],stag[N];
#define ls(p) ch[p][0]
#define rs(p) ch[p][1]
void up(int u){
	if(!u)return;
	int l=ls(u),r=rs(u);
	pre[u]=l?pre[l]:u;
	suf[u]=r?suf[r]:u;
	sz[u]=sz[l]+sz[r]+1;
	mx[u]=mn[u]=dep[u];
	if(l) mx[u]=max(mx[u],mx[l]),mn[u]=min(mn[u],mn[l]);
	if(r) mx[u]=max(mx[u],mx[r]),mn[u]=min(mn[u],mn[r]);
	stag[u]=stag[l]|stag[r]|ctag[u];
}
void pt(int u,int c){if(u)tag[u]=c,col[u]=c;}
void down(int u){if(tag[u])pt(ls(u),tag[u]),pt(rs(u),tag[u]),tag[u]=0;}
bool chk(int x){return ch[fa[x]][1]==x;}
void rot(int x){
	int y=fa[x],z=fa[y],k=chk(x),s=ch[x][!k];
	down(z),down(y);
	if(z)ch[z][chk(y)]=x; fa[x]=z;
	ch[y][k]=s; if(s)fa[s]=y;
	ch[x][!k]=y; fa[y]=x; up(y),up(x);
}
void splay(int x,int to=0){
    if(!x)assert(!to);
    int qwq=0;
	while(fa[x]!=to){
		if(fa[fa[x]]!=to)rot(chk(x)^chk(fa[x])?x:fa[x]);
		rot(x);
		++qwq;
		if(qwq>n)exit(-1);
	}//up(x);
}
void cut(int x){
	if(!x)return;
	ch[fa[x]][chk(x)]=0,up(fa[x]),fa[x]=0;
}

void ins(int x,int y){
	if(!x||!y)return;
//	cout<<"ins "<<tou[x]<<" "<<tou[y]<<endl;
	splay(x),splay(y);
	if(!ls(x))return ls(x)=y,fa[y]=x,splay(y);
	x=ls(x);
	while(down(x),x){
		if(!rs(x))return rs(x)=y,fa[y]=x,splay(y);
		x=rs(x);
	}
}
void add(int x,int y){
	if(!x||!y)return;
//	cout<<"add "<<tou[x]<<' '<<tou[y]<<endl;
	splay(x),splay(y);
	int p=suf[x];
	if(!rs(p))return rs(p)=y,fa[y]=p,splay(y);
	p=rs(p);
	while(down(p),p){
		if(ls(p))p=ls(p);
		else return ls(p)=y,fa[y]=p,splay(y);
	} 
}

int top(int x){return x?splay(x),pre[x]:0;}
int nd[N],tp;
void dfs(int x,int c){
	down(x);
	if(ctag[x]>>c&1)nd[++tp]=tou[x],ctag[x]^=(1<<c);
	if(ls(x)&&(stag[ls(x)]>>c&1))dfs(ls(x),c);
	if(rs(x)&&(stag[rs(x)]>>c&1))dfs(rs(x),c);
	up(x);
}
int findrt(int x){
	int tp=top(l[x]);
	Rep(i,17,0)if(top(l[anc[x][i]])==tp)x=anc[x][i];
	return x;
}
void split(int l,int r){
	splay(l),splay(r,l);
	down(l),down(r);
}

int son[N][32];

void mdf1(int x,int c) {
	int p=findrt(x);
	split(l[x],r[x]);
	if(c==col[l[x]]) return;
	int L=ch[l[x]][0],R=ch[r[x]][1],lc=col[l[x]];
	fa[L]=fa[R]=0,ch[l[x]][0]=ch[r[x]][1]=0,up(r[x]),up(l[x]);
	add(L,R),splay(l[x]);
	int fa=pa[x];
	splay(l[fa]);
	int an=pa[p];
	if(fa) {
		splay(l[an]);
		if(col[l[an]]!=lc) {
			if(L) son[an][lc]=L;
			else if(R) son[an][lc]=R;
			else son[an][lc]=0,splay(l[an]),ctag[l[an]]&=(A^(1<<lc));
		}
	}
	if((p=ch[r[x]][0]))
		son[x][lc]=p,ctag[l[x]]|=1<<lc,::fa[p]=0,ch[r[x]][0]=0,up(r[x]),up(l[x]);
	col[l[x]]=col[r[x]]=c;
	if(son[x][c])
		ctag[l[x]]&=(A^(1<<c)),ins(r[x],son[x][c]),son[x][c]=0;
	if(fa) {
		splay(l[fa]);
		if(son[fa][c]) add(son[fa][c],l[x]);
		else son[fa][c]=l[x],splay(l[fa]),splay(r[fa],l[fa]),ctag[l[fa]]|=1<<c;
		if(col[l[fa]]==c) ctag[l[fa]]&=(A^(1<<c)),son[fa][c]=0,ins(r[fa],l[x]);
	}
}

void mdf2(int u,int c){
	u=findrt(u); split(l[u],r[u]);
	if(col[l[u]]==c)return;
	int L=ls(l[u]),R=rs(r[u]),lstc=col[l[u]];
	cut(L),cut(R),add(L,R),splay(l[u]);
	int f=pa[u];
	splay(l[f]);
	if(f && col[l[f]]!=lstc){
		if(L) son[f][lstc]=L;
		else if(R) son[f][lstc]=R;
		else son[f][lstc]=0,splay(l[f]),ctag[l[f]]&=(A^(1<<lstc));
	}
	tp=0;
	splay(l[u]),dfs(l[u],c),pt(l[u],c);
	For(i,1,tp){
		int v=nd[i];
		ins(r[v],son[v][c]),son[v][c]=0;
	}
	if(f){
		splay(l[f]);
		if(son[f][c]) add(son[f][c],l[u]);
		else son[f][c]=l[u],splay(l[f]),splay(r[f],l[f]),ctag[l[f]]|=(1<<c),splay(l[f]);
		if(col[l[f]]==c) ctag[l[f]]&=(A^(1<<c)),son[f][c]=0,ins(r[f],l[u]);
	}
}

void output(int u){
	if(!u)return;
	output(ls(u));
	cout<<"u: "<<tou[u]<<" "<<dep[u]<<" "<<col[u]<<' '<<mx[u]<<" "<<mn[u]<<endl;
	down(u);
	output(rs(u));
	up(u);
}

void ask(int u){
	u=findrt(u); split(l[u],r[u]);
	int a=col[l[u]];
	int b=sz[ls(r[u])]/2+1;
	int c=max(mx[ls(r[u])],dep[l[u]])-min(mn[ls(r[u])],dep[l[u]])+1;
//	printf("a,b,c %d %d %d %d\n",u,a,b,c);
	printf("%d %d %d\n",a,b,c);
}

bool cmpc(int u,int v){return c[u]<c[v];}
void init(int u,int d){
	dep[l[u]]=dep[r[u]]=d;
	For(i,1,17)anc[u][i]=anc[anc[u][i-1]][i-1];
	for(auto v:e[u])anc[v][0]=u,init(v,d+1);
	sz[l[u]]=sz[r[u]]=1,tou[l[u]]=tou[r[u]]=u,col[l[u]]=col[r[u]]=c[u];
	rs(l[u])=r[u],fa[r[u]]=l[u],up(r[u]),up(l[u]);
	static vector <int> vec;
	vector<int>().swap(vec);
	for(auto v:e[u]) vec.pb(v);
	sort(vec.begin(),vec.end(),cmpc);
	for(unsigned i=0 ; i<vec.size() ; ++i)
		if(c[vec[i]]!=c[u]&&(i==0||c[vec[i-1]]!=c[vec[i]]))
			ctag[l[u]]|=1<<c[vec[i]];
	for(unsigned i=0 ; i<vec.size() ; ++i)
		if(!son[u][c[vec[i]]]&&c[vec[i]]!=c[u]) son[u][c[vec[i]]]=l[vec[i]];
	for(unsigned i=1 ; i<vec.size() ; ++i)
		if(c[vec[i-1]]==c[vec[i]]) add(r[vec[i-1]],l[vec[i]]);
	for(unsigned i=0 ; i<vec.size() ; ++i)
		if(c[vec[i]]==c[u])
			{ins(r[u],l[vec[i]]);break ;}
}

signed main()
{
	mx[0]=-inf,mn[0]=inf;
	n=read();
	For(i,1,n)e[pa[i]=read()].pb(i);
	For(i,1,n)c[i]=read(),l[i]=i*2-1,r[i]=i*2;
	init(1,1);
//	exit(0);
	m=read();
	For(_,1,m){
		int o=read(),x=read();
		if(o==1)mdf1(x,read());
		if(o==2)mdf2(x,read());
		if(o==3)ask(x);
	//	if(o<=2)For(x,1,n)ask(x);
	//	output(l[2]);
	}
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 40
Accepted

Test #1:

score: 40
Accepted
time: 4ms
memory: 22440kb

input:

1000
0 1 1 2 1 3 3 7 2 1 1 5 9 1 10 4 9 13 4 13 9 16 5 21 11 22 17 14 24 8 24 19 7 13 1 9 12 22 8 35 39 4 9 34 19 28 40 8 34 4 50 39 6 32 4 1 31 25 31 37 46 44 60 12 54 48 25 43 15 69 1 38 2 23 12 73 59 39 75 7 36 9 27 73 2 43 37 81 53 58 58 83 10 86 17 89 82 52 10 14 40 46 25 4 56 61 16 96 21 70 14...

output:

11 1 1
26 1 1
22 1 1
12 1 1
1 1 1
30 1 1
17 1 1
1 1 1
17 1 1
16 1 1
3 1 1
9 1 1
8 1 1
13 1 1
10 1 1
7 1 1
28 1 1
20 1 1
28 1 1
24 1 1
26 1 1
14 1 1
3 1 1
16 1 1
1 1 1
27 1 1
14 1 1
13 1 1
13 1 1
3 1 1
30 1 1
13 1 1
21 2 2
16 1 1
28 2 2
17 1 1
8 1 1
12 1 1
10 1 1
27 1 1
10 1 1
19 1 1
23 1 1
16 1 1
2 ...

result:

ok 996 numbers

Subtask #2:

score: 40
Accepted

Test #2:

score: 40
Accepted
time: 264ms
memory: 45608kb

input:

100000
0 1 1 1 4 3 4 6 2 4 5 4 9 3 14 3 10 14 16 9 5 14 3 6 13 12 12 21 19 26 21 13 19 26 32 8 5 2 5 30 3 1 12 21 6 44 1 10 32 31 47 1 44 34 9 38 12 44 47 1 3 30 12 62 15 56 5 1 53 3 69 57 53 12 9 58 8 77 20 76 18 63 59 61 80 42 30 70 33 16 38 5 28 42 91 88 85 7 38 98 7 100 1 93 91 103 25 66 95 24 8...

output:

1 1 1
1 2 2
1 1 1
1 2 2
2 5 5
1 2 2
1 11 5
2 173 10
1 1 1
2 2 2
1 2 2
1 2 2
1 4 3
1 2 2
1 11 4
2 2 2
2 2 2
2 1 1
2 141 12
1 2 2
1 178 11
1 3 3
1 10 4
2 6 4
1 6 4
2 5 4
1 6 4
1 2 2
2 4 3
2 173 10
1 21 5
1 7 3
2 7 5
1 8 3
1 10 5
1 3 2
2 2 2
1 7 2
2 1 1
2 1 1
1 1 1
1 2 2
2 2 2
1 1 1
2 1 1
2 4 3
1 3 3
2...

result:

ok 180339 numbers

Test #3:

score: 40
Accepted
time: 184ms
memory: 46056kb

input:

100000
0 1 2 3 4 5 1 5 4 9 4 9 5 6 14 11 8 4 7 2 2 19 10 1 5 1 10 4 10 24 28 28 11 7 20 31 33 36 33 3 29 28 23 28 3 40 28 35 45 17 8 51 24 22 3 35 23 36 50 7 1 11 20 25 54 22 20 54 49 56 35 44 10 46 37 34 21 67 16 40 67 44 49 22 16 4 33 78 79 58 70 89 51 16 55 44 90 8 66 2 84 58 59 17 53 19 55 107 9...

output:

2 12 5
2 2 2
1 18 6
1 1 1
1 19 6
1 1 1
1 4 3
2 3 3
2 15 6
1 5 3
1 2 2
2 2 2
2 5 3
1 8 4
1 1 1
1 2 2
1 1 1
2 14 5
1 4 4
2 14 6
1 1 1
1 4 3
1 4 3
1 281 12
1 6 5
2 7 4
1 1 1
1 3 2
1 4 3
2 1 1
2 19 6
2 3 2
1 2 2
1 2 2
1 2 2
2 3 2
2 3 2
2 3 2
2 9 5
1 6 4
2 2942 18
2 24322 23
2 24322 23
1 5 3
2 59712 24
1...

result:

ok 60228 numbers

Test #4:

score: 40
Accepted
time: 309ms
memory: 45392kb

input:

100000
0 1 2 1 4 4 1 3 5 1 7 7 3 10 10 2 4 7 17 5 19 2 3 20 16 22 2 11 10 16 7 14 1 33 12 17 33 11 16 38 10 10 32 38 31 5 26 15 35 48 50 27 8 10 51 3 48 3 18 6 2 57 8 31 3 59 27 16 66 43 21 50 52 15 60 13 18 20 3 31 48 5 30 71 63 33 11 53 56 64 51 63 11 91 3 86 30 67 53 20 27 22 61 75 9 88 92 82 103...

output:

1 4 3
1 1 1
1 98 9
2 2 2
2 2 2
2 3 3
2 3 2
2 3 2
2 2 2
1 1 1
1 9 4
2 2 2
2 3 3
1 1 1
1 3 2
1 10 4
2 1 1
1 1 1
1 6 3
2 7 3
1 484 13
1 3 3
2 5 4
2 2 2
1 1 1
1 1 1
2 11 5
2 48 8
2 1 1
2 1 1
1 1 1
2 5 3
2 3 3
1 690 13
1 1 1
1 4 2
1 57 7
1 9 5
2 6 3
1 3 3
2 1 1
2 26 5
2 1 1
1 1 1
2 1 1
1 91 8
2 3 2
2 14 ...

result:

ok 60072 numbers

Test #5:

score: 40
Accepted
time: 74ms
memory: 43164kb

input:

100000
0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

2 15808 10
2 15808 10
1 49647 10
1 49647 10
2 78329 11
2 78329 11
2 78329 11
1 99593 12
2 1 1
1 99593 12
1 99593 12
1 99593 12
1 99593 12
1 99593 12
1 99593 12
2 99900 12
1 99980 12
2 99998 12
2 1 1
2 1 1
2 1 1
2 1 1
2 1 1
2 1 1
1 100000 12
1 100000 12
1 100000 12
2 100000 12
2 100000 12
2 100000 12...

result:

ok 143451 numbers

Test #6:

score: 40
Accepted
time: 254ms
memory: 48020kb

input:

99937
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 87 88 89 91 92 93 90 95 94 96 98 97 99 1...

output:

2 1 1
1 4 4
1 2 2
2 9 9
1 3 3
1 2 2
2 9 9
2 2 2
2 1 1
1 4 4
1 1 1
2 6 6
1 1 1
2 3 3
1 6 6
2 2 2
2 5 5
1 4 4
2 3 3
2 1 1
2 1 1
1 5 5
1 2 2
1 2 2
2 1 1
1 3 3
2 3 3
2 3 3
1 4 4
1 3 3
2 2 2
2 2 2
1 3 3
2 1 1
2 6 6
2 6 6
2 2 2
2 1 1
2 4 4
1 1 1
2 5 5
1 2 2
2 2 2
2 1 1
1 2 2
1 2 2
1 1 1
1 2 2
2 2 2
1 1 1
...

result:

ok 99360 numbers

Test #7:

score: 40
Accepted
time: 237ms
memory: 39528kb

input:

100000
0 1 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 ...

output:

1 2 2
1 3 2
1 4 4
1 2 2
2 1 1
2 1 1
1 3 3
1 2 2
1 1 1
2 7 6
2 4 3
2 7 4
1 3 3
2 2 2
2 1 1
1 2 2
1 1 1
1 1 1
1 2 2
2 2 2
2 1 1
1 1 1
2 2 2
1 2 2
1 1 1
1 1 1
2 5 3
2 2 2
1 1 1
2 3 2
2 3 2
1 3 3
1 3 2
2 2 2
1 1 1
1 24 7
2 4 3
2 2 2
1 1 1
1 1 1
2 3 2
1 6 3
2 3 2
1 3 3
2 1 1
1 2 2
1 1 1
2 15 5
2 3 2
2 5 ...

result:

ok 150966 numbers

Test #8:

score: 40
Accepted
time: 148ms
memory: 45904kb

input:

100000
0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

1 2 2
1 3 3
2 45744 13
2 45744 13
2 45744 13
1 5 4
2 39 8
1 2 2
2 90 7
2 85134 15
1 109 9
1 93998 17
1 93998 17
2 98009 17
1 30 5
1 42 9
1 50 7
1 25 5
1 177 10
1 4 3
1 33 6
1 57 9
1 159 10
2 99865 17
2 99992 18
2 99992 18
2 231 14
2 58 6
1 99999 18
2 100000 18
1 100000 18
2 100000 18
2 74 8
2 14 5
2...

result:

ok 100605 numbers

Subtask #3:

score: 20
Accepted

Test #9:

score: 20
Accepted
time: 55ms
memory: 49660kb

input:

100000
0 1 1 1 2 4 3 6 5 5 9 10 8 12 10 13 15 14 16 16 19 17 21 19 21 21 22 23 24 26 29 29 29 30 31 31 34 35 36 37 37 37 40 40 42 42 45 46 45 48 48 49 50 51 51 52 54 56 57 55 58 58 60 62 60 61 65 63 65 65 66 67 68 71 72 74 72 75 77 78 78 77 80 80 80 83 82 84 85 87 87 90 88 92 92 92 92 93 96 96 96 99...

output:

5 1 1
5 1 1
7 1 1
3 1 1
8 1 1
8 1 1
2 2 2
3 1 1
5 1 1
4 2 2
5 2 2
7 1 1
5 1 1
6 1 1
5 1 1
8 1 1
5 1 1
4 1 1
5 1 1
4 1 1
8 4 3
3 1 1
2 1 1
3 1 1
5 1 1
10 1 1
3 1 1
8 1 1
1 2 2
3 4 3
9 2 2
2 1 1
6 2 2
8 1 1
8 3 3
3 3 3
3 1 1
3 1 1
3 1 1
9 1 1
4 1 1
6 6 5
8 6 5
8 1 1
8 1 1
10 6 5
3 1 1
3 1 1
9 1 1
8 1 ...

result:

ok 74802 numbers

Test #10:

score: 20
Accepted
time: 66ms
memory: 46968kb

input:

100000
0 1 1 1 1 4 5 5 5 8 9 8 11 11 12 14 13 14 16 18 19 19 19 22 22 22 25 24 27 28 29 28 29 30 32 33 34 36 37 36 38 40 41 41 41 42 44 44 45 48 47 48 51 52 51 53 53 55 55 56 57 59 60 61 62 64 64 66 11 67 68 68 70 70 73 72 73 75 75 78 78 78 80 82 81 82 84 85 86 87 89 89 89 91 92 93 93 96 97 98 99 98...

output:

1 1 1
5 3 3
5 3 3
1 3 2
5 3 2
4 2 2
1 2 2
1 2 2
5 1 1
1 1 1
3 1 1
3 1 1
5 4 4
5 3 3
5 3 3
2 2 2
3 2 2
5 1 1
3 2 2
3 1 1
3 2 2
3 3 3
5 2 2
5 2 2
1 2 2
1 2 2
1 2 2
1 2 2
3 1 1
4 1 1
4 1 1
1 1 1
1 1 1
1 1 1
4 1 1
4 1 1
3 2 2
2 1 1
4 1 1
3 1 1
2 1 1
5 3 3
5 3 3
3 1 1
5 3 3
3 3 3
2 4 3
4 1 1
5 4 4
2 2 2
...

result:

ok 97917 numbers

Test #11:

score: 20
Accepted
time: 47ms
memory: 39348kb

input:

100000
0 1 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 ...

output:

5 2 2
9 1 1
8 1 1
6 1 1
1 1 1
1 1 1
5 1 1
5 1 1
5 2 2
5 2 2
2 1 1
8 1 1
8 1 1
1 1 1
5 3 3
5 3 3
3 3 3
3 3 3
2 3 2
9 4 3
8 4 3
8 1 1
1 1 1
3 1 1
1 1 1
1 1 1
1 1 1
7 1 1
3 2 2
3 2 2
3 2 2
6 1 1
5 1 1
10 1 1
10 1 1
10 1 1
10 1 1
10 1 1
8 1 1
8 1 1
3 2 2
9 1 1
9 1 1
6 1 1
4 1 1
2 1 1
2 1 1
2 1 1
7 1 1
4...

result:

ok 136905 numbers

Test #12:

score: 20
Accepted
time: 66ms
memory: 56940kb

input:

100000
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100...

output:

2 2 2
2 2 2
3 5 5
2 3 3
2 3 3
2 3 3
3 3 3
1 6 6
1 6 6
2 8 8
2 8 8
3 1 1
2 15 15
2 15 15
2 15 15
3 18 18
3 18 18
2 18 18
2 18 18
2 18 18
2 18 18
2 18 18
3 18 18
2 18 18
2 18 18
2 18 18
1 1 1
1 1 1
1 1 1
1 2 2
1 2 2
2 3 3
2 3 3
2 3 3
2 3 3
3 5 5
1 6 6
2 10 10
2 10 10
3 12 12
3 12 12
3 2 2
3 2 2
2 6 6
...

result:

ok 136866 numbers

Test #13:

score: 20
Accepted
time: 162ms
memory: 45200kb

input:

100000
0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

8 1 1
27 1 1
9 1 1
9 1 1
28 1 1
28 1 1
28 1 1
1 1 1
2 1 1
26 1 1
19 1 1
4 1 1
26 1 1
24 1 1
29 2 2
26 5261 4
26 5261 4
26 5261 4
29 7064 4
29 7064 4
11 1 1
14 1 1
4 1 1
4 1 1
4 1 1
4 1 1
4 1 1
20 1 1
1 1 1
16 2 2
8 1 1
8 1 1
19 1 1
19 1 1
19 1 1
28 1 1
25 7171 5
26 7208 5
2 13077 5
30 19442 5
13 261...

result:

ok 128427 numbers

Test #14:

score: 20
Accepted
time: 135ms
memory: 45960kb

input:

100000
0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

3 1 1
2 1 1
1 3579 5
1 3579 5
1 3579 5
7 7944 6
2 13196 6
2 13196 6
5 1 1
4 3 2
2 13199 6
2 13199 6
7 1 1
7 1 1
4 30954 7
3 32596 7
3 32596 7
1 48134 8
3 50214 8
6 61657 8
6 61657 8
6 61657 8
6 1 1
6 1 1
7 78679 9
7 78679 9
7 78679 9
7 78679 9
4 86063 10
5 1 1
5 1 1
4 86049 10
4 86049 10
6 87842 10
...

result:

ok 129021 numbers

Test #15:

score: 20
Accepted
time: 239ms
memory: 45380kb

input:

100000
0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

3 3 2
3 1 1
3 2 2
1 1 1
2 1 1
1 1 1
1 2 2
2 2 2
3 4 3
1 1 1
1 1 1
3 3 3
2 4 3
3 1 1
1 2 2
1 2 2
1 1 1
1 1 1
4 2679 9
3 2 2
2 1 1
3 1 1
1 4 3
4 2 2
2 1 1
2 7374 9
2 7374 9
3 1 1
4 1 1
3 14852 9
4 21244 10
1 1 1
4 1 1
4 2 2
2 27059 10
2 1 1
1 1 1
2 27055 10
2 1 1
1 2 2
1 2 2
3 30687 11
3 30687 11
1 1 ...

result:

ok 120396 numbers

Test #16:

score: 20
Accepted
time: 260ms
memory: 45644kb

input:

100000
0 1 1 2 1 5 4 1 5 3 5 8 6 9 5 7 13 5 2 11 13 4 2 5 18 8 26 20 20 29 26 30 25 8 18 18 17 16 33 8 7 37 10 30 39 29 26 4 42 23 49 13 19 1 39 1 44 10 29 26 53 46 45 54 19 11 36 43 58 8 37 62 40 68 29 31 48 1 55 67 49 39 35 19 74 2 79 55 70 18 12 57 25 51 54 51 49 13 61 43 41 70 9 56 60 97 54 39 4...

output:

2 4 3
4 2 2
2 3 3
2 3 3
1 2 2
3 1 1
3 2 2
2 10 7
2 10 7
4 1 1
1 1 1
3 1 1
2 1 1
2 1 1
1 4 4
1 1 1
4 1 1
4 2 2
1 2 2
2 1 1
2 1 1
4 1 1
3 4 3
3 4 3
3 4 3
3 4 3
4 1 1
4 3 3
4 7 3
4 7 3
1 5 4
3 4 3
1 1 1
1 1 1
1 1 1
2 2 2
2 2 2
2 2 2
2 2 2
2 1 1
4 1 1
3 3 2
3 4 3
2 1 1
3 2 2
1 1 1
1 1 1
1 1 1
3 4 3
2 5 ...

result:

ok 99642 numbers

Test #17:

score: 20
Accepted
time: 256ms
memory: 43228kb

input:

100000
0 1 1 1 2 3 2 1 1 3 6 2 5 1 1 6 3 8 3 9 18 2 9 14 15 10 1 10 16 10 4 6 5 14 17 31 15 1 24 19 1 17 6 12 8 8 17 12 21 9 3 20 6 27 17 7 6 24 33 11 33 8 1 21 18 3 12 16 45 21 5 2 32 20 16 22 4 2 20 46 44 8 14 4 23 26 4 4 2 2 52 16 3 47 24 58 7 42 3 2 68 63 16 76 4 24 47 5 38 13 34 11 41 86 7 17 1...

output:

26 1 1
30 1 1
3 1 1
1 2 2
7 1 1
16 1 1
21 1 1
7 1 1
26 1 1
19 3 2
2 1 1
19 2 2
12 1 1
10 1 1
3 1 1
23 1 1
17 1 1
26 1 1
14 1 1
22 1 1
25 1 1
20 2 2
12 1 1
2 1 1
20 1 1
26 1 1
20 2 2
29 1 1
18 1 1
9 1 1
27 1 1
1 1 1
27 1 1
27 1 1
6 1 1
19 3 2
29 1 1
7 1 1
25 1 1
24 1 1
6 1 1
20 1 1
17 1 1
15 4 4
19 1...

result:

ok 179424 numbers

Test #18:

score: 20
Accepted
time: 252ms
memory: 43496kb

input:

100000
0 1 1 1 1 1 3 2 1 1 3 1 1 7 1 3 6 2 4 8 1 1 1 17 1 3 1 6 13 6 14 1 23 25 11 20 18 25 4 2 9 4 8 28 30 17 10 6 6 26 7 1 13 13 24 11 3 1 10 2 6 47 10 23 49 1 1 5 1 12 17 2 53 55 21 7 3 38 34 5 48 47 18 5 2 37 22 21 23 4 2 26 2 2 73 4 3 21 10 54 26 10 2 11 15 2 73 62 49 13 23 21 30 16 36 2 69 11 ...

output:

18 1 1
7 1 1
13 1 1
3 1 1
15 1 1
12 1 1
15 8 4
27 2 2
20 2 2
17 1 1
18 1 1
6 4 2
17 2 2
17 2 2
6 1 1
26 1 1
15 1 1
15 1 1
27 1 1
18 1 1
16 1 1
13 1 1
21 6 4
14 1 1
15 1 1
12 1 1
10 1 1
28 1 1
10 2 2
17 2 2
29 1 1
5 2 2
17 3 3
15 1 1
22 1 1
30 1 1
20 1 1
22 1 1
27 1 1
4 1 1
14 1 1
14 1 1
28 1 1
26 1 ...

result:

ok 142806 numbers

Test #19:

score: 20
Accepted
time: 275ms
memory: 43436kb

input:

100000
0 1 1 2 1 1 3 2 2 2 1 9 3 1 1 4 2 2 10 1 1 7 5 4 1 16 4 23 10 3 9 20 5 9 18 22 15 11 14 7 1 9 6 5 14 1 32 37 2 17 28 24 45 3 7 6 11 14 20 9 49 1 2 47 4 7 4 1 18 20 25 7 37 25 18 34 21 63 57 35 29 6 37 30 4 5 4 25 4 9 6 5 34 13 24 13 26 3 27 8 19 64 19 18 48 34 4 27 4 8 76 3 33 11 106 9 47 55 ...

output:

14 1 1
22 1 1
23 1 1
20 1 1
30 5 2
17 2 2
14 1 1
17 1 1
9 1 1
6 2 2
4 1 1
4 2 2
25 1 1
25 1 1
3 1 1
16 1 1
11 1 1
1 1 1
7 1 1
29 3 3
27 1 1
13 1 1
4 1 1
15 2 2
17 5 3
21 1 1
30 1 1
2 3 2
1 1 1
14 1 1
11 1 1
29 1 1
1 2 2
7 2 2
17 1 1
12 1 1
13 2 2
18 3 3
5 1 1
20 1 1
10 2 2
10 1 1
4 2 2
28 1 1
24 2 2...

result:

ok 136587 numbers

Test #20:

score: 20
Accepted
time: 261ms
memory: 45672kb

input:

100000
0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

3 2 2
2 4 3
3 1 1
4 1 1
4 17227 7
2 1 1
4 17227 7
2 1 1
5 1 1
2 2 2
2 17056 6
3 2 2
5 1 1
2 1 1
4 17227 7
3 1 1
2 1 1
1 2 2
3 9524 6
4 1 1
2 3 2
2 28659 8
2 2 2
4 1 1
4 3 2
4 1 1
4 2 2
2 1 1
2 1 1
4 17223 7
2 2 2
2 4 3
2 1 1
4 4 2
2 3 3
2 1 1
5 4 2
5 3 3
4 1 1
4 1 1
4 2 2
5 21172 7
3 23624 7
2 1 1
4...

result:

ok 99270 numbers

Test #21:

score: 20
Accepted
time: 327ms
memory: 42892kb

input:

100000
0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

27 1 1
13 1 1
22 1 1
2 1 1
21 1 1
28 1 1
23 1 1
6 1 1
4 1 1
16 1 1
11 1 1
29 1 1
19 1 1
15 1 1
6 1 1
13 1 1
5 1 1
7 1 1
13 1 1
23 1 1
5 1 1
28 1 1
9 1 1
25 1 1
8 1 1
25 1 1
2 1 1
19 1 1
8 1 1
1 1 1
24 1 1
21 1 1
10 1 1
15 1 1
27 1 1
10 1 1
1 1 1
10 1 1
2 2 2
9 1 1
23 1 1
25 1 1
24 1 1
16 1 1
12 1 1
...

result:

ok 49953 numbers

Test #22:

score: 20
Accepted
time: 189ms
memory: 45688kb

input:

100000
0 1 1 1 3 3 1 2 4 2 7 1 1 4 10 6 7 14 8 6 14 17 6 2 3 6 2 15 26 13 23 31 31 18 33 30 36 18 29 29 25 22 41 18 28 38 11 11 35 37 19 37 9 46 22 19 15 3 7 41 51 45 61 31 27 16 49 35 41 33 23 18 58 15 27 29 5 66 25 76 50 52 18 69 68 29 11 77 31 48 23 2 60 44 84 27 84 28 35 55 34 84 28 4 98 67 78 1...

output:

3 1 1
7 1 1
10 1 1
10 1 1
5 1 1
5 1 1
10 2 2
10 2 2
10 2 2
10 2 2
10 2 2
10 2 2
3 3 2
3 3 2
6 5 3
5 1 1
2 1 1
2 1 1
2 1 1
2 1 1
2 1 1
2 1 1
2 1 1
10 1 1
10 1 1
10 1 1
10 1 1
10 1 1
8 1 1
5 1 1
2 1 1
2 1 1
2 1 1
2 1 1
2 1 1
2 1 1
6 1 1
5 1 1
5 1 1
6 1 1
3 1 1
3 1 1
2 2 2
2 2 2
2 2 2
8 1 1
8 1 1
8 1 1...

result:

ok 149259 numbers

Test #23:

score: 20
Accepted
time: 102ms
memory: 47888kb

input:

99928
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 ...

output:

2 1 1
2 1 1
5 1 1
3 2 2
3 2 2
5 1 1
2 1 1
2 1 1
2 1 1
1 2 2
1 2 2
4 1 1
3 1 1
1 1 1
1 1 1
1 2 2
2 1 1
2 1 1
5 2 2
5 2 2
5 2 2
2 1 1
1 2 2
1 2 2
1 1 1
2 1 1
2 1 1
2 1 1
3 3 3
4 1 1
1 2 2
1 1 1
3 2 2
2 1 1
1 1 1
1 1 1
5 2 2
5 2 2
5 2 2
3 1 1
3 2 2
2 1 1
4 1 1
2 2 2
2 2 2
3 1 1
5 3 3
5 1 1
3 1 1
5 1 1
...

result:

ok 99870 numbers

Test #24:

score: 20
Accepted
time: 49ms
memory: 39444kb

input:

100000
0 1 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 ...

output:

10 1 1
1 1 1
24 2 2
7 2 2
3 1 1
9 1 1
24 2 2
5 1 1
9 1 1
12 1 1
25 1 1
26 1 1
23 1 1
1 1 1
21 1 1
3 1 1
6 1 1
25 1 1
10 1 1
23 1 1
26 1 1
26 1 1
25 1 1
5 1 1
5 1 1
2 1 1
12 2 2
19 1 1
25 1 1
20 1 1
10 1 1
15 1 1
25 1 1
29 1 1
23 1 1
17 1 1
7 1 1
7 1 1
7 1 1
23 1 1
26 1 1
26 1 1
16 1 1
18 1 1
22 1 1
...

result:

ok 100164 numbers

Test #25:

score: 20
Accepted
time: 166ms
memory: 39756kb

input:

100000
0 1 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 ...

output:

2 1 1
4 1 1
1 1 1
4 3 3
5 1 1
5 1 1
4 1 1
4 1 1
2 1 1
4 5 4
1 3 3
3 2 2
1 2 2
5 3 3
4 1 1
1 2 2
2 1 1
1 1 1
1 2 2
5 2 2
1 1 1
2 1 1
3 1 1
1 2 2
3 1 1
2 1 1
5 2 2
2 3 3
4 1 1
3 1 1
2 1 1
1 1 1
1 1 1
5 2 2
1 1 1
1 1 1
5 9 6
5 9 6
5 9 6
3 1 1
4 5 4
2 1 1
2 1 1
2 1 1
1 1 1
4 1 1
3 1 1
4 1 1
4 1 1
2 1 1
...

result:

ok 100098 numbers

Test #26:

score: 20
Accepted
time: 58ms
memory: 46128kb

input:

100000
0 1 1 2 4 4 4 6 3 3 4 9 5 13 11 12 3 14 8 16 14 12 1 8 14 10 7 27 1 6 20 28 21 25 29 2 20 5 11 8 2 1 40 30 43 5 42 38 2 46 14 42 51 51 13 26 56 56 35 58 57 1 46 43 19 62 65 30 32 62 49 67 46 69 15 10 4 13 45 19 8 15 41 77 44 47 33 58 38 48 4 42 80 30 12 40 32 46 52 89 36 60 29 4 90 84 17 10 8...

output:

29 1 1
22 1 1
8 1 1
21 1 1
2 1 1
2 1 1
2 1 1
1 1 1
30 1 1
30 1 1
30 1 1
2 1 1
2 1 1
8 1 1
1 1 1
1 1 1
26 1 1
26 1 1
26 1 1
26 1 1
18 1 1
16 2 2
2 2 2
6 2 2
10 1 1
25 1 1
25 1 1
25 1 1
12 1 1
29 1 1
8 1 1
14 1 1
21 1 1
21 1 1
14 1 1
14 1 1
27 1 1
27 1 1
25 1 1
16 1 1
8 2 2
8 9 6
8 9 6
30 1 1
30 1 1
6...

result:

ok 142659 numbers

Test #27:

score: 20
Accepted
time: 130ms
memory: 39792kb

input:

100000
0 1 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 ...

output:

1 1 1
2 1 1
2 1 1
2 3 2
1 3 2
1 3 2
3 1 1
3 2 2
1 2 2
1 2 2
2 5 3
1 8 4
1 8 4
2 8 4
3 1 1
3 1 1
1 1 1
1 4 3
3 2 2
1 2 2
1 2 2
3 1 1
3 1 1
1 1 1
1 1 1
1 13 6
3 1 1
2 1 1
1 2 2
1 2 2
2 4 3
1 5 4
2 3 2
2 3 2
3 1 1
2 3 2
3 1 1
3 1 1
3 1 1
3 3 2
1 6 3
2 1 1
1 6 3
1 3 2
2 1 1
3 1 1
3 8 5
2 13 5
3 13 5
3 1...

result:

ok 74541 numbers

Test #28:

score: 20
Accepted
time: 206ms
memory: 45312kb

input:

100000
0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

13 1 1
6 52 3
22 104 4
20 123 5
3 1 1
27 1 1
28 1 1
3 1 1
3 1 1
20 2 2
26 1 1
7 1 1
3 1 1
21 1 1
15 1 1
24 1 1
3 42 4
15 1 1
6 2 2
19 1 1
13 42 3
3 42 4
28 187 4
5 2 2
3 1 1
28 1 1
28 1 1
28 1 1
11 92 4
22 2 2
9 85 3
14 41 3
28 1 1
14 41 3
14 41 3
11 1 1
8 79 3
13 152 5
10 1 1
21 49 3
21 49 3
28 224...

result:

ok 100470 numbers

Test #29:

score: 20
Accepted
time: 196ms
memory: 44212kb

input:

100000
0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 32 9 59 3 61 95 27 101 18 109 94 69 71 61 18 1 40 110 54 53 75 86 62 76 5 115 102 99 50 103 1...

output:

7 1 1
5 36 5
8 23 4
4 6 3
8 23 4
7 1 1
7 1 1
3 4 3
6 1 1
4 7 4
6 5 3
2 2 2
4 26 5
5 5 4
3 1 1
7 1 1
2 1 1
3 1 1
6 5 3
1 32 7
4 29 5
1 4 3
5 2 2
1 1 1
7 3 3
7 10 4
2 2 2
6 2 2
1 2 2
6 6 3
4 2 2
4 3 3
6 5 4
7 175 7
5 312 8
5 312 8
5 312 8
3 12 4
1 1 1
3 2 2
3 36 6
3 1 1
3 3 2
3 13 5
3 1 1
8 1 1
6 1 1
...

result:

ok 100299 numbers

Test #30:

score: 20
Accepted
time: 35ms
memory: 47808kb

input:

100000
0 1 1 1 1 1 4 1 5 1 3 9 7 8 12 11 8 15 9 15 14 13 16 19 14 20 23 22 23 21 24 24 31 24 27 31 30 32 34 32 38 40 40 33 34 37 40 46 39 40 42 44 43 51 53 45 52 47 49 56 50 60 57 55 60 55 64 63 63 64 68 64 63 72 64 68 68 75 72 72 73 71 81 76 76 83 84 79 81 86 80 82 89 83 87 87 92 91 89 91 97 94 95 ...

output:

18 1 1
21 1 1
4 1 1
4 1 1
14 2 2
19 2 2
30 1 1
5 1 1
5 1 1
24 1 1
24 1 1
24 1 1
24 1 1
29 1 1
29 1 1
29 1 1
13 1 1
3 1 1
3 1 1
18 1 1
16 1 1
16 1 1
3 1 1
18 1 1
15 1 1
19 1 1
8 1 1
17 1 1
15 1 1
12 1 1
10 1 1
10 1 1
10 1 1
1 1 1
14 1 1
20 1 1
18 1 1
26 1 1
8 1 1
20 1 1
20 1 1
16 1 1
21 1 1
15 1 1
15...

result:

ok 75090 numbers

Test #31:

score: 20
Accepted
time: 181ms
memory: 45944kb

input:

100000
0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 82 5 90 93 19 86 38 79 26 29 96 103 105 81 36 22 31 17 100 7 55 41 38 27 104 23 76 75 21 74 1...

output:

3 8 6
2 1 1
3 8 6
3 8 6
3 1456 11
3 1456 11
3 1 1
3 56 8
2 2 2
3 57 8
1 9 4
3 6 4
2 1 1
3 7494 14
3 1 1
1 1 1
3 46 8
3 511 12
1 1 1
2 1 1
3 69 9
2 2 2
1 2 2
2 114 10
2 28 7
2 121 9
1 21 9
2 154 10
2 78 9
2 1 1
2 11864 15
3 12501 15
3 12501 15
2 1 1
3 58320 18
2 4 3
3 58320 18
3 1 1
3 410 11
1 85 8
1...

result:

ok 100284 numbers