QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#405671#8630. 字符树dingdingtang11514#30 2120ms169588kbC++146.8kb2024-05-06 12:01:592024-05-06 12:02:00

Judging History

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

  • [2024-05-06 12:02:00]
  • 评测
  • 测评结果:30
  • 用时:2120ms
  • 内存:169588kb
  • [2024-05-06 12:01:59]
  • 提交

answer

#include <iostream>
#include <cstring> 
#include <map>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>
#include <set>
// #include <bits/stdc++.h>

// #define int long long
#define For(i,a,b) for(int i=(a);i<=(b);i++)
#define Rof(i,a,b) for(int i=(a);i>=(b);i--)
#define Grf(it,u,to) for(int it=he[u],to;(to=e[it],it);it=nxt[it]) 
#define In __inline 
#define OP operator
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
namespace Mine {
	// mt19937_64 wql(514);
	In int read() {
		ll x=1,a=0;
		char ch=getchar();
		while(ch>'9' || ch<'0') x=(ch=='-')?-1:x,ch=getchar();
		while(ch>='0' && ch<='9') a=(a<<1)+(a<<3)+(ch-'0'),ch=getchar();
		return a*x;
	} const int N=5e5+100;
	char ch[N];int n,m,X,fa[N],f[N][21],dep[N];
	
	
	bool No1=1;
	
	In int lca(int x,int y) {
		if(dep[x]<dep[y]) swap(x,y);
		Rof(i,20,0) if(dep[f[x][i]]>=dep[y]) x=f[x][i];
		if(x==y) return x;
		Rof(i,20,0) if(f[x][i]!=f[y][i]) x=f[x][i],y=f[y][i];
		return f[x][0];
	} int he[N],nxt[N],cf[N],idx=1,e[N];
	void adde(int a,int b,int c) {
		e[++idx]=b,cf[idx]=c,nxt[idx]=he[a];he[a]=idx;
	}
	namespace sol {
		namespace Mine {
			// mt19937_64 wql(514);
			In ll read() {
				ll x=1,a=0;
				char ch=getchar();
				while(ch>'9' || ch<'0') x=(ch=='-')?-1:x,ch=getchar();
				while(ch>='0' && ch<='9') a=(a<<1)+(a<<3)+(ch-'0'),ch=getchar();
				return a*x;
			} const int N=1e6+100;
			struct ACAM {
				int son[N][11],fail[N],idx=0,tr[N],dfn[N],ed[N],tot;
				vector<int> fs[N];
				void dfs(int u) {
					dfn[u]=++tot; for(int to:fs[u]) {dfs(to);} ed[u]=tot;
				} void build() {
					queue<int> q; For(i,0,10) if(son[0][i]) q.push(son[0][i]);
					while(q.size()) { int u=q.front();q.pop();
						// printf("%d\n",u);
						For(i,0,10) {
							if(!son[u][i]) son[u][i]=son[fail[u]][i];
							else fail[son[u][i]]=son[fail[u]][i],q.push(son[u][i]);
						}
					} For(i,1,idx) fs[fail[i]].push_back(i);
					// For(i,0,idx) {for(int j:{'w'-'0','x'-'0'}) printf("%d ",son[i][j]);puts("");}puts("");
					dfs(0); //For(i,0,idx) printf("%d ",dfn[i]);
					// puts("");For(i,0,idx) printf("%d ",fail[i]);puts("");
				} void mdf(int pos,int val) {for(;pos<=tot;pos+=pos&-pos) tr[pos]+=val;}
				In int qry(int pos) {int ret=0; for(;pos;pos-=pos&-pos){ret+=tr[pos];}return ret;}
				In int get(int u) {return qry(ed[u])-qry(dfn[u]-1);}
			} A1,A2;int he[N],nxt[N<<1],e[N<<1],n,m; char w[N<<1];
			namespace E {int idx=1; void adde(int a,int b,char d) {e[++idx]=b,w[idx]=d,nxt[idx]=he[a],he[a]=idx;}}
			using E::adde; struct node { int qid,val; } ; vector<node> b1[N],b2[N];
			int fa[N][23],dep[N];char from[N]; void get_fa(int u,int f) {
				dep[u]=dep[f]+1;fa[u][0]=f; For(i,1,22) fa[u][i]=fa[fa[u][i-1]][i-1];
				Grf(it,u,to) {if(to!=f) {from[to]=w[it];get_fa(to,u);}}
			} In int lca(int x,int y) { if(dep[x]<dep[y]) swap(x,y);
				Rof(i,22,0) if(dep[fa[x][i]]>=dep[y]) x=fa[x][i];
				if(x==y) return x;
				Rof(i,22,0) if(fa[x][i]!=fa[y][i]) x=fa[x][i],y=fa[y][i];
				return fa[x][0];
			} struct Que {int x,y,top,a,b,ans;} q[N];
			char S[N];int ls; In int FA(int u,int x) {Rof(i,19,0) {if(x>=(1<<i))x-=(1<<i),u=fa[u][i];}return u;}
			char ch[N],lch; In int kmp() {
				static int nxt[N];
				// printf("%s ",ch+1,S);
				nxt[1]=0; int j=0; For(i,2,ls) {
					while(j && S[j+1]!=S[i]) j=nxt[j];
					if(S[j+1]==S[i]) j++;
					nxt[i]=j;
				} int ret=0; j=0; For(i,1,lch) {
					while(j && S[j+1]!=ch[i]) j=nxt[j];
					if(S[j+1]==ch[i]) j++;
					if(j==ls) ret++,j=nxt[j];
				} return ret;
			} void dfs(int u,int ff,int r1,int r2) {
				A1.mdf(A1.dfn[r1],1);A2.mdf(A2.dfn[r2],1);
				for(auto &j:b1[u]) q[j.qid].ans+=j.val*A1.get(q[j.qid].a);
				for(auto &j:b2[u]) q[j.qid].ans+=j.val*A2.get(q[j.qid].b);
				Grf(it,u,to) if(to!=ff) dfs(to,u,A1.son[r1][w[it]-'0'],A2.son[r2][w[it]-'0']);
				A1.mdf(A1.dfn[r1],-1);A2.mdf(A2.dfn[r2],-1);
			} signed main() {
				get_fa(1,0);
				For(i,1,m) {
					int opt=read(); if(opt==1) No1=0;
					
					q[i].x=read();q[i].y=read();q[i].top=lca(q[i].x,q[i].y);
					// // printf("%d %d %d\n",q[i].x,q[i].y,q[i].top);
					 scanf("%s",S+1);ls=strlen(S+1);int u=0; 
					 // printf("%s\n",ls);
					 For(i,1,ls) {
						int &to=A1.son[u][S[i]-'0']; if(!to) to=++A1.idx;
						u=to;
					}q[i].a=u; u=0; Rof(i,ls,1) {
						int &to=A2.son[u][S[i]-'0']; if(!to) to=++A2.idx;
						u=to;
					}
					q[i].b=u; 
					if(q[i].x!=q[i].top && q[i].y!=q[i].top) {
						int b=min(ls-1,dep[q[i].x]-dep[q[i].top]);lch=b;
						for(int a=1,j=FA(q[i].x,dep[q[i].x]-dep[q[i].top]-b);j!=q[i].top;j=fa[j][0],a++) ch[a]=from[j];
						b=min(ls-1,dep[q[i].y]-dep[q[i].top]);lch+=b;
						for(int a=lch,j=FA(q[i].y,dep[q[i].y]-dep[q[i].top]-b);j!=q[i].top;j=fa[j][0],a--) ch[a]=from[j];
						q[i].ans=kmp();
					}
					if(dep[q[i].x]-dep[q[i].top]>=ls) 
						b2[q[i].x].push_back((node){i,1}),b2[FA(q[i].x,dep[q[i].x]-dep[q[i].top]-ls+1)].push_back((node){i,-1});
					if(dep[q[i].y]-dep[q[i].top]>=ls)
						b1[q[i].y].push_back((node){i,1}),b1[FA(q[i].y,dep[q[i].y]-dep[q[i].top]-ls+1)].push_back((node){i,-1});
				} A1.build(),A2.build(); dfs(1,0,0,0);
				For(i,1,m) printf("%d\n",q[i].ans);
				return 0;
			}
		} using namespace Mine;
	}
	char rd[N];
	namespace S0 {
		int ch[N],lch,S[N],ls;
		
		In int kmp() {
			static int nxt[N];
			nxt[1]=0; int j=0; For(i,2,ls) {
				while(j && S[j+1]!=S[i]) j=nxt[j];
				if(S[j+1]==S[i]) j++;
				nxt[i]=j;
			} int ret=0; j=0; For(i,1,lch) {
				while(j && S[j+1]!=ch[i]) j=nxt[j];
				if(S[j+1]==ch[i]) j++;
				if(j==ls) ret++,j=nxt[j];
			} return ret;
		}
		void solve0() {
			while(m--) {
				int opt=read(),x=read(),y=read();scanf("%s",rd+1);
				For(i,1,X) S[i]=rd[i]-'0';
				int p=lca(x,y);//printf("P: %d\n",dep[p]);
				if(opt==1) {int pos=1;
					while(x!=p) cf[x]=S[pos++],x=fa[x];
					pos=X;
					while(y!=p) cf[y]=S[pos--],y=fa[y];
				} else { lch=0;ls=X;
					while(x!=p) ch[++lch]=cf[x],x=fa[x];
					int pos=lch+dep[y]-dep[p];lch+=dep[y]-dep[p];
					// printf("POS %d\n",pos);
					while(y!=p) ch[pos--]=cf[y],y=fa[y];
					// For(i,1,lch) printf("%d ",ch[i]);
					// puts("");
					printf("%d\n",kmp());
				}
			}
		}
	} 
	signed main() {
		n=read(),m=read(),X=read();
		For(i,2,n) f[i][0]=fa[i]=read();
		For(i,1,n) {dep[i]=dep[fa[i]]+1;For(j,1,20) f[i][j]=f[f[i][j-1]][j-1];}
		scanf("%s",rd+1);
		For(i,2,n) {adde(fa[i],i,rd[i-1]-'0');}
		S0::solve0();
		// if(0) ;
		// else {
			// if(X==1) {
				// S1::solve1();
			// }
			// For(i,2,n) sol::adde(i,fa[i],cf[i]+'0'),sol::adde(fa[i],i,cf[i]+'0');
			// sol::n=n,sol::m=m;
			// sol::main();
		// }
		return 0;
	}
}signed main() {
	// freopen("homework.in","r",stdin);
	// freopen("homework.out","w",stdout);
	return Mine::main();
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 10
Accepted

Test #1:

score: 10
Accepted
time: 7ms
memory: 122728kb

input:

250 250 62
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 30 67 68 8 70 16 72 3 74 75 32 77 75 31 80 81 65 83 30 19 49 4 1 89 57 91 92 43 94 95 96 85 51 32 100 8...

output:

1
1
1
1
1
1
1
1
0
1
1
1
1
0
0
1
1
1
1
1
1
0
1
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
4
2
3
0
0
0
4
4
0
0
0
0
0
2
0
4
0
0
0
0
0
0
0
0
4
0
0
0
0
1
0
0
10
0
0
0
0
0
0
2
0
0
0
0
0
0
0
3
0
2
0
1
0
0
7

result:

ok 118 numbers

Test #2:

score: 10
Accepted
time: 7ms
memory: 120476kb

input:

250 250 6
1 1 1 4 1 1 1 1 1 1 1 1 1 14 1 1 1 1 19 1 1 1 1 24 1 26 27 28 1 30 1 32 1 1 35 1 37 1 1 1 1 1 43 44 45 1 47 1 1 1 1 1 53 54 1 56 57 58 1 60 1 62 63 64 65 1 1 68 69 70 71 1 1 1 1 76 77 78 79 1 81 1 83 84 1 1 1 88 89 1 91 1 93 94 1 96 97 98 99 1 1 102 103 1 105 106 107 108 1 110 111 112 113 ...

output:

1
1
1
0
0
0
1
1
1
1
1
1
1
1
1
1
0
1
1
0
1
0
1
1
0
1
0
0
1
0
0
0
3
0
0
0
1
0
0
0
0
0
0
1
0
0
0
0
1
0
1
0
1
0
0
0
0
0
3
0
0
1
0
1
0
0
0
0
0
0
0
0
0
0
2
2
1
0
0
0
0
1
0
0
0
0
0
0
0
1
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
2
0
0
0
0
0
0
1
0
1

result:

ok 118 numbers

Test #3:

score: 10
Accepted
time: 8ms
memory: 124784kb

input:

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

output:

0
1
1
1
2
1
0
0
8
1
1
0
0
1
1
2
3
1
1
1
1
3
1
0
1
2
0
2
0
8
1
0
2
1
0
2
1
1
3
0
0
1
0
1
0
1
0
0
1
0
2
0
0
3
0
0
0
3
2
0
3
0
5
0
13
5
0
0
7
4
1
0
0
0
1
0
3
0
0
7
0
0
6
0
9
3
8
0
3
7
7
0
15
1
0
8
0
1
6
10
10
0
2
1
0
0
0
3
0
2
6
3
0
3
0
0
2
7
2
0
2
6
17
2
0
0
0
0
0

result:

ok 129 numbers

Test #4:

score: 10
Accepted
time: 16ms
memory: 126692kb

input:

246 250 113
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 ...

output:

1
1
1
1
1
0
1
1
1
1
1
1
1
0
1
0
1
1
1
1
1
1
1
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
1
0
6
1
0
1
0
2
0
2
1
1
0
0
2
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
4
1
0
0
0
0
0
0
0
0
0
0
0
0

result:

ok 128 numbers

Test #5:

score: 10
Accepted
time: 9ms
memory: 120548kb

input:

249 250 47
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 1 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 1 1 70 71 1 73 74 75 76 1 78 1 80 1 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 1 99 1 101 1 1...

output:

1
1
1
1
0
1
0
1
0
0
0
1
1
0
1
1
0
1
1
1
0
0
1
1
1
1
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
9
0
0
2
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
3
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0

result:

ok 118 numbers

Test #6:

score: 10
Accepted
time: 18ms
memory: 126736kb

input:

250 250 95
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 14 5 98 99 5 ...

output:

1
1
1
1
0
1
1
0
0
1
0
0
0
1
1
0
0
1
1
0
1
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
2
0
0
0
0

result:

ok 121 numbers

Test #7:

score: 10
Accepted
time: 11ms
memory: 118468kb

input:

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

output:

1
0
1
1
0
1
1
1
1
0
1
1
0
1
1
1
1
1
1
0
1
1
1
1
1
1
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
13
4
0
4
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
9
0
0
1
0
0
1
4
0
0
4
0
1
0
0
0
0
2
1
9
0
0
0
7
0
0
2
0
0
0
0
0
0
4
11
0
0
0
0
11
19
1
2
0
0
0
0
0
4
0
0

result:

ok 123 numbers

Test #8:

score: 10
Accepted
time: 7ms
memory: 122544kb

input:

250 250 82
1 1 1 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 1 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 10...

output:

1
1
1
1
0
1
1
0
1
1
1
1
0
1
1
1
1
1
0
1
1
1
0
0
1
1
0
1
1
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
49
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
22
0
0
0
0
0
0
0
0
0
0
0
0
36
0
0
18
0
1
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1

result:

ok 118 numbers

Test #9:

score: 10
Accepted
time: 8ms
memory: 120776kb

input:

250 250 7
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 33 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 26 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 10...

output:

1
1
0
0
1
0
1
1
1
1
0
1
1
1
1
0
0
1
1
1
0
0
1
1
0
0
0
0
1
0
1
1
1
1
1
0
1
1
1
0
1
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
1
0
1
0
1
0
0
0
0
0
0
0
0
3
0
0
0
0
3
0
8
0
6
0
7
0
10
10
10
0
0
0
0
2
0
2
0
0
0
1
0
9
0
2
17
4
1
0
0
0
0
1
0
0
0
2
0
0
1
4
3
0
0
0
0

result:

ok 123 numbers

Test #10:

score: 10
Accepted
time: 7ms
memory: 124512kb

input:

249 246 2
1 2 2 2 5 4 7 1 2 2 11 3 2 3 15 11 7 13 9 20 6 6 13 8 13 26 27 6 5 30 31 32 33 34 35 2 29 38 39 40 21 30 37 44 45 14 25 32 49 50 51 52 15 5 14 37 23 27 59 60 61 51 63 47 12 34 57 34 69 70 49 60 25 3 75 72 51 78 78 80 81 78 83 84 85 86 62 88 89 90 2 92 93 94 95 96 97 41 89 81 87 102 45 14 3...

output:

2
3
0
1
2
9
1
1
2
2
2
3
2
3
0
0
1
1
1
0
2
1
2
1
2
8
0
1
2
0
0
3
0
2
2
0
0
2
3
0
1
6
0
1
3
4
2
2
5
5
0
0
1
1
3
0
1
5
0
3
0
4
6
4
7
6
0
8
1
4
0
0
3
0
0
0
0
3
0
0
7
0
6
4
1
1
2
1
1
1
4
1
0
1
3
1
1
0
1
0
4
0
1
0
0
0
7
6
0
0
0
2
0
1
1
4
1
0
4
9
1
0
4
2
2

result:

ok 125 numbers

Subtask #2:

score: 0
Time Limit Exceeded

Test #11:

score: 10
Accepted
time: 47ms
memory: 167816kb

input:

500000 650 769
1 2 3 4 5 6 7 8 9 10 11 12 7 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 9...

output:

1
1
1
1
1
1
0
0
1
1
1
1
1
0
1
0
1
1
1
1
0
1
1
1
1
1
1
1
1
1
1
1
1
0
1
1
0
1
0
0
1
1
0
0
1
0
1
1
1
0
0
1
1
1
1
1
1
0
0
1
1
0
1
1
1
0
1
1
0
1
1
0
1
1
1
1
1
0
0
1
0
0
1
1
0
1
1
0
0
1
0
0
1
1
0
1
1
1
1
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 650 numbers

Test #12:

score: 10
Accepted
time: 737ms
memory: 163604kb

input:

500000 499995 1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 12 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 55 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...

output:

113
133
1
134
138
143
35
117
79
1
55
26
98
190
53
82
1
190
141
4
161
4
82
328
193
160
189
124
32
293
133
133
41
119
50
110
194
67
107
30
131
111
24
91
168
139
0
3
162
70
108
140
72
174
60
1
184
157
184
13
138
52
212
193
172
132
147
200
143
51
179
33
184
104
129
71
58
59
6
86
139
79
159
94
0
56
36
55...

result:

ok 499995 numbers

Test #13:

score: 10
Accepted
time: 2120ms
memory: 161676kb

input:

500000 100000 5
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 5 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 ...

output:

648
90
150
309
2
0
23
5
227
190
52
6
0
14
381
1
177
73
11
1
345
191
3
16
246
0
1
828
11
87
9
1
52
260
5
819
3
55
451
138
3
6
94
45
96
8
1
109
692
285
1
328
1
599
6
0
364
190
1
151
132
13
3
19
32
36
0
263
14
3
199
0
487
0
371
0
345
6
111
85
159
17
422
2
343
218
320
801
183
34
3
968
1
93
164
2
32
119
...

result:

ok 100000 numbers

Test #14:

score: 10
Accepted
time: 39ms
memory: 161652kb

input:

500000 8 56878
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 ...

output:

1
1
0
0
1
0
1
1

result:

ok 8 numbers

Test #15:

score: 10
Accepted
time: 107ms
memory: 163436kb

input:

499995 62500 8
1 2 3 4 5 6 7 8 2 10 11 12 13 14 15 12 17 18 19 20 21 6 23 24 25 26 27 28 14 30 31 23 33 34 13 36 37 12 39 30 41 15 43 44 20 46 47 48 1 32 51 52 17 54 55 11 57 58 59 60 61 62 63 30 65 66 67 68 69 70 71 72 73 24 75 76 77 1 79 80 81 82 18 73 85 86 87 88 89 90 91 92 93 94 95 54 97 98 99 ...

output:

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

result:

ok 62500 numbers

Test #16:

score: 10
Accepted
time: 978ms
memory: 167836kb

input:

500000 499999 1
1 2 3 4 5 5 7 8 9 10 11 12 13 14 15 16 17 18 19 20 3 20 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 32 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 27 90 91 92 93 94 95 96 97 98 ...

output:

7
207
7
66
49
163
53
104
45
266
7
17
95
20
112
181
146
1
0
102
157
97
56
76
53
227
124
20
177
11
33
282
208
63
251
198
3
46
91
29
63
78
93
2
69
95
36
95
10
63
245
61
7
5
12
267
0
18
9
10
190
177
135
138
99
10
12
16
14
18
132
13
16
9
3
303
4
9
201
50
184
134
95
11
130
148
111
124
205
103
141
13
252
1...

result:

ok 499999 numbers

Test #17:

score: 10
Accepted
time: 1790ms
memory: 165540kb

input:

500000 55552 9
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 ...

output:

18
1
2
1
3
3
1
50
0
59
1
1
17
1
0
1
0
17
8
2
1
9
0
0
1
2
8
8
6
2
56
0
6
0
2
4
87
2
2
0
0
14
2
1
45
1
2
17
50
58
38
1
3
9
0
0
0
46
1
9
0
3
12
12
0
51
40
1
1
1
0
15
0
4
59
3
0
1
10
0
7
5
1
1
0
57
131
17
56
0
57
1
7
60
11
87
1
4
1
37
19
57
76
3
0
137
62
0
36
22
0
0
69
0
0
0
0
2
26
16
122
69
35
0
4
0
0
...

result:

ok 55552 numbers

Test #18:

score: 10
Accepted
time: 147ms
memory: 167536kb

input:

500000 250000 2
1 2 3 4 5 6 1 1 1 10 11 1 1 14 15 16 17 1 1 1 1 1 1 24 1 26 27 1 29 30 31 1 1 34 1 36 37 1 1 1 41 1 1 44 45 1 1 1 1 1 1 1 53 54 1 56 1 1 59 60 1 62 63 1 1 1 1 1 69 70 71 1 1 74 75 76 77 78 1 80 81 1 1 84 85 86 87 88 1 1 1 1 1 94 1 96 1 98 1 1 1 1 1 104 105 1 107 108 109 110 111 1 113...

output:

1
1
0
1
1
0
1
0
1
3
2
1
0
0
0
0
0
0
0
1
1
1
0
1
0
1
1
0
1
0
1
1
1
1
1
1
1
1
1
0
1
0
1
2
0
1
1
4
0
1
1
0
1
1
2
1
1
0
1
0
0
1
1
0
1
1
1
1
1
1
1
1
1
1
0
2
1
0
1
0
0
1
1
0
2
1
0
1
1
0
1
1
0
0
0
1
2
1
2
0
1
0
1
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
1
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
...

result:

ok 250000 numbers

Test #19:

score: 0
Time Limit Exceeded

input:

499996 500000 1
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...

output:

997
577
24
996
4
1
1786
1286
603
11
240
809
929
968
4184
272
27
819
92
718
395
371
181
1344
301
957
472
518
1712
174
2419
933
88
379
2
215
18
975
363
96
125
1643
2
44
1126
214
849
0
205
1524
1183
1797
755
121
1742
473
160
170
34
568
518
938
794
1189
9
2257
302
182
124
81
781
1355
146
110
3741
1250
1...

result:


Subtask #3:

score: 0
Time Limit Exceeded

Test #21:

score: 10
Accepted
time: 212ms
memory: 161484kb

input:

500000 499998 1
1 2 3 4 5 6 7 8 1 1 11 12 13 14 15 16 1 1 19 20 21 22 23 24 1 26 1 28 29 30 1 32 33 34 35 1 37 38 39 40 41 42 43 1 45 46 47 48 49 50 1 52 53 54 55 56 57 1 1 60 61 62 63 64 65 66 67 68 69 1 71 1 73 1 75 76 77 78 79 80 81 82 83 1 1 86 87 88 89 1 91 92 93 94 95 96 97 98 99 100 101 102 1...

output:

2
0
6
4
8
1
3
6
5
1
8
3
11
4
6
1
3
0
2
0
2
0
1
1
3
1
1
3
1
2
1
3
4
5
4
4
5
0
0
4
1
1
5
5
0
0
1
0
1
5
0
0
4
0
0
2
3
5
13
3
3
6
0
9
0
5
1
5
0
0
4
2
4
0
0
4
0
2
6
1
4
1
3
0
1
3
7
1
0
1
5
0
0
0
3
0
0
3
1
7
1
1
0
10
0
5
7
1
0
0
2
0
0
0
0
4
0
3
0
1
5
1
1
0
0
2
0
2
8
4
4
2
4
1
3
14
6
2
5
16
0
0
10
5
0
0
5
...

result:

ok 250246 numbers

Test #22:

score: 10
Accepted
time: 329ms
memory: 167640kb

input:

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

output:

25
119
1
38
5
27
42
23
4
28
29
3
21
23
63
21
34
9
5
56
4
11
56
3
4
32
48
4
39
6
75
44
4
3
52
7
3
71
84
78
10
6
59
25
4
70
90
9
5
52
10
59
3
24
48
28
15
63
76
43
67
1
24
6
29
37
29
50
4
28
47
14
1
4
58
43
34
2
1
23
2
3
35
57
0
52
24
3
22
34
32
2
17
13
38
5
36
0
3
115
61
36
50
61
50
52
11
3
48
4
88
18...

result:

ok 249848 numbers

Test #23:

score: 10
Accepted
time: 230ms
memory: 169588kb

input:

500000 500000 1
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 1 61 62 63 1 1 66 67 68 69 70 71 72 73 74 75 76 1 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 ...

output:

9
8
11
36
5
1
6
18
25
1
7
20
23
6
2
10
1
4
1
6
3
5
1
2
21
1
2
17
1
0
27
3
36
3
6
8
3
5
3
1
10
21
26
19
0
7
5
14
37
18
31
27
18
18
3
0
1
30
0
36
9
3
5
1
0
12
2
1
0
53
1
7
0
9
7
11
0
18
34
1
18
22
19
7
1
4
8
1
4
4
3
8
1
6
0
0
16
15
12
6
10
4
16
0
10
4
0
17
2
0
37
3
12
2
6
43
3
17
32
5
5
6
19
0
5
3
4
2...

result:

ok 249445 numbers

Test #24:

score: 0
Time Limit Exceeded

input:

500000 500000 1
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...

output:

17672
25594
24568
36011
16778
68155
51386
2299
1
727
27893
112385
59514
9221
87735
5482
7401
5909
66693
15958
8958
8439
18126
16553
7925
22449
38
35874
4427
140733
9113
2
49766
31636
11655
58122
49282
14144
27748
3741
26121
38539
125007
30785
3224
12580
11780
80245
82717
21451
11646
14234
13585
1832...

result:


Subtask #4:

score: 0
Skipped

Dependency #3:

0%

Subtask #5:

score: 10
Accepted

Test #41:

score: 10
Accepted
time: 36ms
memory: 163648kb

input:

499997 9 40060
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 ...

output:

1
1
0
0
1
0

result:

ok 6 numbers

Test #42:

score: 10
Accepted
time: 42ms
memory: 167680kb

input:

500000 21 23702
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...

output:

1
1
1
0
1
0

result:

ok 6 numbers

Test #43:

score: 10
Accepted
time: 49ms
memory: 163584kb

input:

500000 20 24356
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...

output:

1
0
0
1
1
0
1
8454
1

result:

ok 9 numbers

Test #44:

score: 10
Accepted
time: 36ms
memory: 163816kb

input:

500000 20 20150
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...

output:

1
1
1
1
0
1
0
1
1
0

result:

ok 10 numbers

Test #45:

score: 10
Accepted
time: 71ms
memory: 163560kb

input:

499998 22 20008
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...

output:

1
1
1
0
1
1
1
0
1
1
1
0
0
1
1

result:

ok 15 numbers

Test #46:

score: 10
Accepted
time: 61ms
memory: 163752kb

input:

500000 24 20019
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...

output:

1
0
1
1
0
16
0
1
1

result:

ok 9 numbers

Test #47:

score: 10
Accepted
time: 66ms
memory: 167888kb

input:

499995 17 29083
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...

output:

0
1
0
0
1
0

result:

ok 6 numbers

Test #48:

score: 10
Accepted
time: 64ms
memory: 165976kb

input:

499999 4 104570
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...

output:

1

result:

ok 1 number(s): "1"

Test #49:

score: 10
Accepted
time: 50ms
memory: 161632kb

input:

500000 24 20763
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...

output:

1
0
1
1
1
0
1
1
1
1
1
1
53
1
1
1
1

result:

ok 17 numbers

Test #50:

score: 10
Accepted
time: 45ms
memory: 161540kb

input:

500000 24 20521
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...

output:

1
0
1
0
0
1
1
0
0
0
0
15456
1
1

result:

ok 14 numbers

Subtask #6:

score: 0
Time Limit Exceeded

Test #51:

score: 0
Time Limit Exceeded

input:

500000 62500 8
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 ...

output:

401
4604
1323
306
4495
376
586
755
1378
93
4870
2851
11048
323
394
285
38
3851
2964
10676
877
2741
5036
921
243
436
3738
638
594
620
5202
644
342
1969
1899
87
779
106
3665
3770
20
227
198
85
1504
1455
3
124
591
11012
33
50
36374
0
10596
188
192
28
29
177
417
2141
21266
153
728
2
2
1215
10296
0
0
630...

result:


Subtask #7:

score: 0
Time Limit Exceeded

Test #61:

score: 0
Time Limit Exceeded

input:

500000 100000 5
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...

output:

4
17986
30064
174788
38161
211015
106448
91622
13037
95529
151167
65689
66396
156390
28230
176115
272339
89286
141946
222298
17188
18213
11792
181011
84012
52257
5989
7
124253
93612
38134
153437
28244
265895
49422
144945
116186
6479
39619
48047
258474
169068
66514
134304
108561
96952
184906
38445
12...

result:


Subtask #8:

score: 10
Accepted

Test #71:

score: 10
Accepted
time: 13ms
memory: 122792kb

input:

25000 2500 10
1 2 3 4 5 6 7 8 9 10 1 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...

output:

1
1
1
4
1
1
1
1
0
2
21
1
1
1
1
1
6
1
3
1
2
0
0
1
2
2
2
1
0
1
1
2
0
14
2
0
1
0
1
1
0
1
1
3
1
1
2
1
3
2
0
0
0
0
0
0
0
0
0
0
0
2
1
1
1
0
0
0
1
0
0
0
19
0
4
0
0
0
1
1
0
0
0
0
0
1
0
1
1
2
2
0
30
0
4
3
0
1
0
0
0
0
0
3
3
0
1
1
1
1
0
0
0
2
4
0
0
1
0
0
0
1
13
0
0
1
0
1
0
0
3
0
0
0
0
0
39
2
0
0
0
0
0
2
0
0
0
...

result:

ok 1310 numbers

Test #72:

score: 10
Accepted
time: 21ms
memory: 126984kb

input:

25000 3570 7
1 2 2 4 5 4 6 1 2 1 2 4 9 6 5 16 17 7 19 15 20 22 10 24 25 20 25 12 12 30 31 32 11 34 35 25 37 38 39 15 41 42 43 32 27 28 47 48 21 12 29 2 5 54 55 4 6 6 59 25 61 57 63 64 65 26 57 37 69 48 49 72 73 74 57 72 77 37 79 6 81 82 83 84 21 55 61 88 78 76 91 92 39 69 95 7 84 98 55 100 101 94 24...

output:

1
1
0
1
0
1
1
1
1
0
0
1
1
1
0
1
1
1
1
1
0
1
0
1
0
1
0
0
0
0
0
0
0
1
0
1
1
0
0
0
0
0
0
0
0
1
1
1
0
1
0
0
0
0
0
1
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 1759 numbers

Test #73:

score: 10
Accepted
time: 45ms
memory: 122712kb

input:

25000 3125 8
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...

output:

1
1
0
1
1
0
0
2
1
1
0
1
1
1
0
1
1
1
1
1
1
0
0
1
1
0
1
0
0
2
0
1
1
1
1
0
0
1
0
1
0
0
1
1
1
1
1
1
1
0
1
1
0
1
1
0
4
0
12
1
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
1
0
0
0
0
0
3
0
0
0
0
0
0
0
0
0
0
0
0
0
7
1
0
0
0
0
0
2
0
0
0
3
1
0
0
0
0
0
0
0
0
0
0
0
0...

result:

ok 1567 numbers

Test #74:

score: 10
Accepted
time: 22ms
memory: 122964kb

input:

25000 2079 12
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 9...

output:

24
1
2
1
0
2
12
2
1
2
13
2
1
2
7
1
1
3
18
5
0
2
1
1
2
1
6
4
1
14
0
11
1
1
12
0
1
2
1
1
1
9
1
2
21
2
0
4
0
3
0
1
2
4
3
6
4
5
3
1
0
1
34
3
0
0
0
1
1
1
0
1
13
0
9
23
4
0
5
5
1
0
2
0
0
1
0
0
16
0
0
0
2
0
4
0
0
0
1
1
1
31
0
1
0
53
1
7
1
0
0
0
20
0
3
16
3
0
0
3
0
0
6
4
0
5
0
0
0
3
70
0
6
0
2
0
0
28
0
1
4
...

result:

ok 1058 numbers

Test #75:

score: 10
Accepted
time: 197ms
memory: 126856kb

input:

25000 25000 1
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 9...

output:

2798
2755
1063
1447
7043
8002
2036
2
323
40
262
907
7086
6920
155
472
162
6795
3971
516
3097
127
7608
2551
854
1422
1954
4783
431
6479
1258
1397
513
2080
1258
1548
1576
1875
1116
6050
3485
663
2527
5477
166
272
1470
257
2727
732
2353
5454
353
668
1719
1285
1121
30
465
1275
472
649
4481
5165
4776
251...

result:

ok 12503 numbers

Test #76:

score: 10
Accepted
time: 17ms
memory: 122728kb

input:

25000 12499 2
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 1 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...

output:

29
80
19
98
50
113
4
18
57
22
11
5
15
12
54
42
22
14
8
19
64
39
42
40
2
1
56
6
14
30
26
11
75
26
19
43
138
18
8
27
23
107
13
63
18
39
69
79
34
53
4
23
34
4
15
11
41
6
74
47
37
65
0
41
25
35
34
55
227
8
8
13
75
3
40
89
36
59
45
3
24
42
205
113
24
17
32
5
5
1
36
1
22
57
180
10
75
18
4
3
68
207
1
79
6
...

result:

ok 6223 numbers

Test #77:

score: 10
Accepted
time: 57ms
memory: 122732kb

input:

25000 3123 8
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...

output:

25
71
1
475
56
73
62
56
20
0
9
425
41
12
0
213
369
4
38
2
44
28
11
58
10
12
59
6
2
1
100
148
0
5
1
16
62
5
129
0
376
185
11
3
7
1
1180
976
13
0
125
2
13
1
16
21
20
236
6
2
310
4
3
650
5
1
0
373
108
17
15
52
16
40
182
28
117
43
9
20
0
46
47
19
12
235
310
127
11
17
159
5
259
122
26
0
30
12
63
25
12
65...

result:

ok 1572 numbers

Test #78:

score: 10
Accepted
time: 20ms
memory: 122712kb

input:

24997 45 496
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...

output:

1
0
1
0
1
0
0
0
1
0
0
1
1
1
1
1
1
1
218
1
0

result:

ok 21 numbers

Test #79:

score: 10
Accepted
time: 162ms
memory: 124812kb

input:

24997 12500 2
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 9...

output:

277
104
13
187
153
3061
566
1967
2176
14
1501
401
171
8
1674
1528
97
313
8
557
1905
232
17
39
88
564
385
32
24
178
45
9
542
947
36
2418
1840
2670
2690
280
2672
179
2
9
94
4
72
6
1272
75
2627
1057
835
1025
2026
1
1133
58
230
1344
382
242
0
2328
71
218
1425
5
33
95
53
645
22
76
25
1393
2
26
676
8
1693...

result:

ok 6313 numbers

Test #80:

score: 10
Accepted
time: 11ms
memory: 122844kb

input:

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

output:

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

result:

ok 1783 numbers

Subtask #9:

score: 0
Time Limit Exceeded

Dependency #8:

100%
Accepted

Test #81:

score: 10
Accepted
time: 1073ms
memory: 145992kb

input:

250000 13888 18
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...

output:

1
0
1
1
0
0
0
0
0
1
1
0
0
1
1
1
0
1
1
0
1
1
1
1
1
1
0
0
0
0
0
0
0
1
0
1
1
1
1
0
1
0
1
1
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 6992 numbers

Test #82:

score: 10
Accepted
time: 39ms
memory: 145156kb

input:

250000 501 499
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 ...

output:

0
0
0
1
1
1
1
1
1
1
1
0
0
1
0
1
1
0
0
1
1
1
0
0
1
1
1
0
0
1
1
0
1
0
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0
1
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
10
0
10
4
0
0
7
0
0
2
75
112
0
18
7
0
32
7
0
219
421
0
0
0
410
314
0
2
252
0
7
503
528
11
629
455
2
0
28
455
13
2
0
...

result:

ok 237 numbers

Test #83:

score: 10
Accepted
time: 33ms
memory: 147136kb

input:

250000 22 11183
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...

output:

1
0
1
0
1
1
1

result:

ok 7 numbers

Test #84:

score: 10
Accepted
time: 114ms
memory: 147252kb

input:

250000 25000 10
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 1 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 ...

output:

0
5
5
2
14
19
1
7
2
1
1
84
3
1
1
49
5
3
1
2
1
4
2
12
4
5
4
0
3
1
5
2
7
5
4
1
1
5
0
0
5
6
0
4
1
1
40
7
3
1
4
17
0
0
0
4
1
31
8
4
1
4
0
0
8
0
2
3
21
2
7
0
1
0
0
0
13
3
9
0
0
0
0
10
1
0
3
5
0
0
6
8
0
0
4
4
2
0
9
2
16
4
3
0
0
3
9
0
1
3
1
0
17
51
0
8
0
2
0
3
1
0
30
7
0
0
0
0
2
0
0
5
1
5
0
6
0
16
1
36
0
1...

result:

ok 12442 numbers

Test #85:

score: 10
Accepted
time: 19ms
memory: 145392kb

input:

250000 5 44600
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 ...

output:

1
1

result:

ok 2 number(s): "1 1"

Test #86:

score: 10
Accepted
time: 701ms
memory: 147060kb

input:

249999 125000 2
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...

output:

333
39
1273
1280
1946
808
56
49
214
816
301
1254
1106
52
425
485
157
368
1282
2018
563
394
1459
984
1036
564
1092
278
1731
29
98
506
778
1184
1268
2355
1494
474
187
581
393
253
347
941
545
953
610
639
556
348
82
127
329
180
634
721
927
262
602
994
811
2404
1832
480
234
369
320
1016
295
457
477
335
6...

result:

ok 62442 numbers

Test #87:

score: 0
Time Limit Exceeded

input:

249999 83333 3
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 ...

output:

4381
2
807
1364
18
926
14583
45
186
4745
797
871
2
3803
280
628
10
266
927
264
705
4853
80
891
20125
12395
76
6
3645
3227
277
6
0
80
1509
615
3455
52
140
33
552
7
25
304
10142
862
1817
1429
989
9
5473
158
9
4
3543
9591
2447
278
4626
280
6029
8
43
7657
6732
1073
58
3592
1687
44
2900
5613
2587
28
409
...

result:


Subtask #10:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

0%