QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#404549#5707. Viruseszhaohaikun57 741ms8344kbC++202.4kb2024-05-04 08:03:152024-05-04 08:03:16

Judging History

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

  • [2024-05-04 08:03:16]
  • 评测
  • 测评结果:57
  • 用时:741ms
  • 内存:8344kb
  • [2024-05-04 08:03:15]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long 
int g,n,m;
int s[105][2];
int tot=1;
int fail[105];
bool qq[105];
void ins(string w){
	int now=1;
	for(int i=0;i<w.size();i++){
		if(!s[now][w[i]-'0'])s[now][w[i]-'0']=++tot;
		now=s[now][w[i]-'0'];
	}
	qq[now]=1;
	return ;
}
void build(){
	queue<int> e;
	for(int i=0;i<2;i++){
		if(s[1][i])e.push(s[1][i]),fail[s[1][i]]=1;
		else s[1][i]=1;
	}
	while(!e.empty()){
		int w=e.front();e.pop();
		qq[w]|=qq[fail[w]];
		for(int i=0;i<2;i++){
			if(s[w][i])fail[s[w][i]]=s[fail[w]][i],e.push(s[w][i]);
			else s[w][i]=s[fail[w]][i];
		}
	}
	return ;
}
int a[105];
int len[105];
int b[105][105];
struct nd{
	int x,y,z,v;
	bool operator<(const nd&a)const{
		return v>a.v;
	}
};
priority_queue<nd> e;
int c[105][105][105];
int f[105][105];
signed main(){
	cin>>g>>n>>m;
	for(int i=1;i<=n;i++){
		cin>>a[i];int k;cin>>k;len[i]=k;
		for(int j=1;j<=k;j++){
			cin>>b[i][j];
		}
	}
	for(int i=1;i<=m;i++){
		int l;cin>>l;string w;
		while(l--){
			char ch;cin>>ch;w+=ch;
		}
		ins(w);
	}
	build();
	for(int i=0;i<g;i++){
		for(int j=1;j<=tot;j++){
			for(int p=1;p<=tot;p++)c[i][j][p]=-1;
		}
	}
	for(int i=0;i<=1;i++){
		for(int j=1;j<=tot;j++){
	        int p=s[j][i];
			if(!qq[i] and !qq[p]){
				c[i][j][p]=1;
				e.push((nd){i,j,p,1});
			}
		}
	}
	while(!e.empty()){
		nd w=e.top();e.pop();
		if(w.v!=c[w.x][w.y][w.z])continue;
		for(int i=1;i<=n;i++){
			for(int _=1;_<=tot;_++){
				if(qq[_])continue;
			    for(int j=0;j<=len[i];j++){
				    for(int p=1;p<=tot;p++)f[j][p]=-1;
			    }
				f[0][_]=0;
				for(int j=0;j<len[i];j++){
					for(int p=1;p<=tot;p++){
						if(qq[p])continue;
						if(f[j][p]==-1)continue;
						for(int q=1;q<=tot;q++){
							if(qq[q])continue;
							if(c[b[i][j+1]][p][q]==-1)continue;
							int v=f[j][p]+c[b[i][j+1]][p][q];
							if(f[j+1][q]==-1 or f[j+1][q]>v)f[j+1][q]=v;
						}
					}
				}
				for(int j=1;j<=tot;j++){
					int v=f[len[i]][j];
					if(v==-1)continue;
					if(qq[j])continue;
					if(c[a[i]][_][j]==-1 or v<c[a[i]][_][j]){
						c[a[i]][_][j]=v;
						e.push((nd){a[i],_,j,v});
					}
				}
			}
		}
	}
	for(int i=2;i<g;i++){
		int ans=-1;
		for(int j=1;j<=tot;j++){
			if(qq[j])continue;
			if(c[i][1][j]==-1)continue;
			if(ans==-1 or ans > c[i][1][j])ans=c[i][1][j];
		}
		if(ans==-1)cout<<"YES"<<endl;
		else cout<<"NO "<<ans<<endl;
	}
	return 0;
}

详细

Subtask #1:

score: 11
Accepted

Test #1:

score: 11
Accepted
time: 1ms
memory: 3712kb

input:

35 66 0
2 2 1 1
2 1 2
3 2 2 2
3 1 3
4 2 3 3
4 1 4
5 2 4 4
5 1 5
6 2 5 5
6 1 6
7 2 6 6
7 1 7
8 2 7 7
8 1 8
9 2 8 8
9 1 9
10 2 9 9
10 1 10
11 2 10 10
11 1 11
12 2 11 11
12 1 12
13 2 12 12
13 1 13
14 2 13 13
14 1 14
15 2 14 14
15 1 15
16 2 15 15
16 1 16
17 2 16 16
17 1 17
18 2 17 17
18 1 18
19 2 18 18
...

output:

NO 2
NO 4
NO 8
NO 16
NO 32
NO 64
NO 128
NO 256
NO 512
NO 1024
NO 2048
NO 4096
NO 8192
NO 16384
NO 32768
NO 65536
NO 131072
NO 262144
NO 524288
NO 1048576
NO 2097152
NO 4194304
NO 8388608
NO 16777216
NO 33554432
NO 67108864
NO 134217728
NO 268435456
NO 536870912
NO 1073741824
NO 2147483648
NO 4294967...

result:

ok 33 lines

Test #2:

score: 11
Accepted
time: 0ms
memory: 3524kb

input:

4 23 0
2 1 0
2 1 1
2 2 0 0
2 2 0 1
2 2 1 0
2 2 1 1
3 1 2
3 3 0 0 0
3 3 0 0 1
3 3 0 1 0
3 3 0 1 1
3 3 1 0 0
3 3 0 0 1
3 3 1 1 0
3 3 1 1 1
3 4 0 0 0 3
3 4 0 0 1 3
3 4 0 1 0 3
3 4 0 1 1 3
3 4 1 0 0 3
3 4 0 0 1 3
3 4 1 1 0 3
3 4 1 1 1 3

output:

NO 1
NO 1

result:

ok 2 lines

Test #3:

score: 11
Accepted
time: 0ms
memory: 4048kb

input:

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

output:

YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
...

result:

ok 98 lines

Test #4:

score: 11
Accepted
time: 1ms
memory: 3852kb

input:

15 30 0
2 4 1 1 0 0
3 4 1 1 1 0
4 4 1 0 0 0
5 4 3 4 0 2
6 1 8
7 3 2 0 4
8 1 9
9 1 10
10 1 13
11 4 7 0 7 10
12 2 0 7
13 1 6
14 4 1 12 13 10
3 5 1 12 6 10 9
3 3 4 11 0
14 4 6 9 0 14
2 4 14 10 3 0
3 3 0 9 14
2 3 14 0 2
14 4 3 3 9 0
14 3 10 0 6
2 4 7 0 8 2
3 4 8 1 4 5
14 4 14 4 0 13
4 4 11 1 13 14
14 3 ...

output:

NO 4
NO 4
NO 4
NO 13
YES
NO 9
YES
YES
YES
YES
NO 10
YES
YES

result:

ok 13 lines

Test #5:

score: 11
Accepted
time: 1ms
memory: 3696kb

input:

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

output:

NO 1
NO 2
NO 4
NO 8
NO 16
NO 32
NO 64
NO 128
NO 256
NO 512
NO 1024
NO 2048
NO 4096
NO 8192
NO 16384
NO 32768
NO 65536
NO 131072
NO 262144
NO 524288
NO 1048576
NO 2097152
NO 4194304
NO 8388608
NO 16777216
NO 33554432
NO 67108864
NO 134217728
NO 268435456
NO 536870912
NO 1073741824
NO 2147483648
NO 42...

result:

ok 49 lines

Test #6:

score: 11
Accepted
time: 0ms
memory: 3620kb

input:

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

output:

NO 4
NO 4
NO 4
NO 3
NO 10
NO 9
NO 14
NO 25
NO 18
NO 8
NO 51
NO 27

result:

ok 12 lines

Test #7:

score: 11
Accepted
time: 0ms
memory: 3776kb

input:

7 24 0
2 4 0 0 1 0
3 4 1 1 1 1
4 4 0 0 1 1
5 3 1 0 2
6 4 1 4 2 0
5 4 5 2 6 0
2 5 5 4 1 5 3
3 5 1 4 2 3 2
2 4 3 3 6 0
4 3 2 5 0
5 5 3 4 5 4 1
6 5 5 5 4 1 5
6 3 4 0 4
6 4 3 4 5 0
5 3 4 1 3
3 3 4 6 0
5 5 4 1 2 3 5
2 5 6 1 2 6 3
2 3 1 4 5
3 5 2 0 5 6 4
2 5 6 3 0 5 6
2 3 1 4 3
3 5 6 2 5 0 2
3 5 6 4 1 5 4

output:

NO 4
NO 4
NO 4
NO 6
NO 9

result:

ok 5 lines

Test #8:

score: 11
Accepted
time: 1ms
memory: 3552kb

input:

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

output:

NO 4
NO 4
NO 4
NO 4
NO 9
NO 9
NO 18
NO 32

result:

ok 8 lines

Test #9:

score: 11
Accepted
time: 1ms
memory: 3748kb

input:

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

output:

NO 4
NO 4
NO 4
NO 13
NO 9
NO 9

result:

ok 6 lines

Test #10:

score: 11
Accepted
time: 0ms
memory: 3764kb

input:

11 27 0
2 4 0 0 1 1
3 4 0 1 0 1
4 4 0 1 1 0
5 4 0 1 1 3
6 3 2 4 1
7 3 6 4 1
8 4 1 5 3 6
9 3 6 1 5
10 3 9 0 9
10 5 8 5 6 1 9
3 3 1 8 2
5 4 5 9 1 8
6 3 3 0 2
9 5 9 3 0 3 8
10 4 0 9 8 9
5 4 10 5 0 7
6 3 9 1 3
6 5 1 9 5 4 10
6 4 5 8 0 5
7 3 0 2 8
8 3 5 2 1
10 3 1 3 7
10 3 0 2 3
10 5 0 8 3 9 2
7 3 0 2 10...

output:

NO 4
NO 4
NO 4
NO 7
NO 9
NO 14
NO 12
NO 17
NO 9

result:

ok 9 lines

Test #11:

score: 11
Accepted
time: 1ms
memory: 3548kb

input:

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

output:

NO 4
NO 4
NO 4
NO 10
NO 15
NO 20
NO 26
NO 9

result:

ok 8 lines

Test #12:

score: 11
Accepted
time: 1ms
memory: 3784kb

input:

19 25 0
2 4 1 1 1 1
3 4 0 1 1 0
4 4 0 0 0 0
5 4 3 4 1 0
6 3 4 5 0
7 3 1 3 3
8 4 3 3 5 0
9 3 6 0 4
10 4 7 6 8 0
11 4 9 1 7 6
12 4 1 9 11 7
13 3 8 11 0
14 4 1 10 12 9
15 4 12 14 13 1
16 4 1 11 13 15
17 3 14 0 16
18 3 16 1 14
15 5 6 8 9 3 0
5 5 14 0 3 16 10
15 5 3 15 1 8 9
18 5 14 15 0 15 14
2 4 0 2 5 ...

output:

NO 4
NO 4
NO 4
NO 10
NO 15
NO 9
NO 19
NO 9
NO 44
NO 34
NO 53
NO 54
NO 107
NO 48
NO 137
NO 245
NO 245

result:

ok 17 lines

Test #13:

score: 11
Accepted
time: 0ms
memory: 3776kb

input:

6 25 0
2 4 1 1 1 0
3 4 0 1 1 0
4 4 1 0 1 0
5 4 4 1 1 1
4 3 2 1 5
3 5 5 2 1 5 4
2 4 4 4 2 0
2 3 1 3 5
2 3 2 0 4
5 3 3 1 4
5 5 1 4 5 5 4
2 3 3 0 3
5 3 0 5 3
3 5 4 4 1 4 3
2 5 3 2 5 0 2
3 5 1 3 2 2 3
2 4 2 0 2 3
4 3 4 0 2
4 5 5 1 2 2 3
4 5 2 2 2 1 5
4 3 5 4 0
4 5 5 1 5 5 5
4 3 2 4 1
2 3 5 1 2
5 5 1 5 5...

output:

NO 4
NO 4
NO 4
NO 7

result:

ok 4 lines

Test #14:

score: 11
Accepted
time: 1ms
memory: 3836kb

input:

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

output:

NO 4
NO 4
NO 4
NO 6
NO 13
NO 15
NO 27
NO 24

result:

ok 8 lines

Test #15:

score: 11
Accepted
time: 0ms
memory: 3620kb

input:

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

output:

NO 4
NO 4
NO 4
NO 6
NO 7
NO 9
NO 13
NO 14

result:

ok 8 lines

Test #16:

score: 11
Accepted
time: 0ms
memory: 3680kb

input:

33 62 0
2 2 32 32
2 1 2
3 2 30 30
3 1 3
4 2 27 27
4 1 4
5 2 2 2
5 1 5
6 2 28 28
6 1 6
7 2 16 16
7 1 7
8 2 25 25
8 1 8
9 2 18 18
9 1 9
10 2 15 15
10 1 10
11 2 5 5
11 1 11
12 2 22 22
12 1 12
13 2 24 24
13 1 13
14 2 29 29
14 1 14
15 2 12 12
15 1 15
16 2 6 6
16 1 16
17 2 7 7
17 1 17
18 2 3 3
18 1 18
19 ...

output:

NO 512
NO 8192
NO 2147483648
NO 1024
NO 33554432
NO 134217728
NO 2097152
NO 32768
NO 524288
NO 2048
NO 131072
NO 128
NO 4
NO 262144
NO 67108864
NO 268435456
NO 16384
NO 4194304
NO 16
NO 536870912
NO 65536
NO 32
NO 64
NO 1048576
NO 8
NO 1073741824
NO 16777216
NO 2
NO 4096
NO 8388608
NO 256

result:

ok 31 lines

Test #17:

score: 11
Accepted
time: 1ms
memory: 3668kb

input:

25 46 0
2 3 22 22 22
2 1 2
3 3 21 21 21
3 1 3
4 3 14 14 14
4 1 4
5 3 4 4 4
5 1 5
6 3 19 19 19
6 1 6
7 3 20 20 20
7 1 7
8 3 10 10 10
8 1 8
9 3 11 11 11
9 1 9
10 3 16 16 16
10 1 10
11 3 6 6 6
11 1 11
12 3 17 17 17
12 1 12
13 3 12 12 12
13 1 13
14 3 23 23 23
14 1 14
15 3 7 7 7
15 1 15
16 3 18 18 18
16 ...

output:

NO 3486784401
NO 9
NO 243
NO 729
NO 1594323
NO 31381059609
NO 59049
NO 14348907
NO 19683
NO 4782969
NO 129140163
NO 387420489
NO 81
NO 94143178827
NO 6561
NO 43046721
NO 2187
NO 531441
NO 10460353203
NO 3
NO 1162261467
NO 27
NO 177147

result:

ok 23 lines

Test #18:

score: 11
Accepted
time: 0ms
memory: 3784kb

input:

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

output:

NO 125
NO 6103515625
NO 244140625
NO 625
NO 9765625
NO 3125
NO 25
NO 15625
NO 1220703125
NO 78125
NO 5
NO 390625
NO 1953125
NO 48828125

result:

ok 14 lines

Test #19:

score: 11
Accepted
time: 0ms
memory: 3660kb

input:

12 20 0
2 7 8 8 8 8 8 8 8
2 1 2
3 7 2 2 2 2 2 2 2
3 1 3
4 7 9 9 9 9 9 9 9
4 1 4
5 7 3 3 3 3 3 3 3
5 1 5
6 7 1 1 1 1 1 1 1
6 1 6
7 7 10 10 10 10 10 10 10
7 1 7
8 7 6 6 6 6 6 6 6
8 1 8
9 7 7 7 7 7 7 7 7
9 1 9
10 7 11 11 11 11 11 11 11
10 1 10
11 7 5 5 5 5 5 5 5
11 1 11

output:

NO 343
NO 2401
NO 282475249
NO 16807
NO 7
NO 5764801
NO 49
NO 40353607
NO 823543
NO 117649

result:

ok 10 lines

Test #20:

score: 11
Accepted
time: 1ms
memory: 3984kb

input:

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

output:

NO 1
YES
YES
NO 1
NO 1
NO 1
NO 1
YES
YES
YES
NO 1
YES
NO 1
YES
YES
NO 1
YES
NO 1
NO 1
NO 1
YES
NO 1
YES
YES
YES
NO 1
YES
NO 1
NO 1
NO 1
NO 1
NO 1
YES
YES
NO 1
YES
YES
YES
NO 1
YES
NO 1
YES
YES
YES
NO 1
YES
YES
YES
NO 1
YES
YES
NO 1
NO 1
YES
YES
YES
YES
NO 1
YES
NO 1
YES
NO 1
YES
NO 1
YES
YES
NO 1
NO...

result:

ok 100 lines

Subtask #2:

score: 14
Accepted

Test #21:

score: 14
Accepted
time: 143ms
memory: 5908kb

input:

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

output:

NO 2
NO 4
NO 8
NO 16
NO 32
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES

result:

ok 50 lines

Test #22:

score: 14
Accepted
time: 2ms
memory: 4076kb

input:

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

output:

YES
YES
YES
YES
NO 4
YES
YES
NO 4
NO 4
YES
YES
NO 4
YES
YES
YES
YES

result:

ok 16 lines

Test #23:

score: 14
Accepted
time: 67ms
memory: 8344kb

input:

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

output:

YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
...

result:

ok 98 lines

Test #24:

score: 14
Accepted
time: 2ms
memory: 3904kb

input:

15 13 11
2 4 1 0 0 1
3 4 1 0 1 0
4 4 1 1 1 1
5 2 1 0
6 1 6
7 3 3 0 6
8 4 6 6 3 0
9 3 4 1 4
10 4 1 6 9 6
11 3 9 1 7
12 2 11 0
13 3 12 11 0
14 3 13 1 12
3 0 0 1
4 1 1 1 1
3 1 1 0
5 0 1 0 1 0
5 0 1 1 1 0
4 0 0 1 1
4 1 1 0 0
5 1 0 0 0 0
5 1 1 0 1 1
5 1 1 0 1 0
5 1 0 1 0 1

output:

YES
NO 4
YES
NO 2
YES
YES
YES
YES
YES
YES
YES
YES
YES

result:

ok 13 lines

Test #25:

score: 14
Accepted
time: 741ms
memory: 5960kb

input:

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

output:

NO 1
NO 2
NO 4
NO 8
NO 16
NO 32
NO 64
NO 128
NO 256
NO 512
NO 1024
NO 2048
NO 4096
NO 8192
NO 16384
NO 32768
NO 65536
NO 131072
NO 262144
NO 524288
NO 1048576
NO 2097152
NO 4194304
NO 8388608
NO 16777216
NO 33554432
NO 67108864
NO 134217728
NO 268435456
NO 536870912
NO 1073741824
NO 2147483648
NO 42...

result:

ok 49 lines

Test #26:

score: 14
Accepted
time: 27ms
memory: 4396kb

input:

20 18 7
2 3 0 1 0
3 3 0 0 0
4 3 1 0 1
5 4 3 0 3 0
6 4 5 3 5 0
7 4 5 0 3 2
8 3 1 4 3
9 3 7 0 8
10 3 5 6 0
11 5 0 8 9 6 7
12 5 11 8 10 1 10
13 4 9 0 12 10
14 5 1 11 13 13 12
15 3 11 14 0
16 3 1 15 14
17 4 15 1 12 13
18 5 16 0 13 14 15
19 5 1 14 16 18 14
5 1 1 1 1 1
8 0 1 0 1 1 1 1 1
5 0 0 1 0 0
8 0 0 ...

output:

NO 3
NO 3
NO 3
NO 8
NO 20
NO 15
NO 7
YES
NO 29
YES
YES
YES
YES
YES
YES
YES
YES
YES

result:

ok 18 lines

Test #27:

score: 14
Accepted
time: 14ms
memory: 3960kb

input:

12 10 7
2 3 0 0 0
3 4 0 1 0 1
4 3 1 0 0
5 5 4 0 0 4 2
6 4 0 2 5 1
7 4 2 0 2 6
8 3 1 7 3
9 3 8 6 1
10 4 0 7 9 5
11 3 6 1 7
5 1 1 1 1 1
7 0 0 0 0 0 0 1
6 0 1 1 1 1 0
6 1 1 1 0 1 0
7 1 0 0 1 0 1 0
6 0 0 1 1 1 1
8 0 0 1 0 0 1 0 0

output:

NO 3
NO 4
NO 3
NO 11
NO 16
YES
YES
YES
YES
YES

result:

ok 10 lines

Test #28:

score: 14
Accepted
time: 20ms
memory: 4132kb

input:

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

output:

NO 3
NO 3
NO 4
NO 7
NO 3
NO 15
YES
YES
NO 11
NO 42
YES
YES
YES
YES
YES

result:

ok 15 lines

Test #29:

score: 14
Accepted
time: 2ms
memory: 3756kb

input:

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

output:

NO 3
NO 4
NO 3
NO 10

result:

ok 4 lines

Test #30:

score: 14
Accepted
time: 22ms
memory: 4248kb

input:

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

output:

NO 3
NO 3
NO 3
NO 5
YES
YES
NO 14
NO 9
YES
NO 24
YES
YES

result:

ok 12 lines

Test #31:

score: 14
Accepted
time: 16ms
memory: 3948kb

input:

13 11 6
2 3 0 0 0
3 4 0 0 0 0
4 4 1 1 0 0
5 4 1 1 4 2
6 5 4 3 1 0 1
7 4 3 6 1 6
8 4 7 7 7 0
9 3 8 1 4
10 5 5 9 7 0 6
11 4 10 0 8 6
12 4 8 10 0 10
8 0 0 0 1 1 1 0 1
7 0 0 0 0 1 0 0
8 1 0 1 1 0 0 0 0
7 1 0 1 1 1 1 0
7 1 1 0 1 0 1 1
8 0 0 1 1 0 0 0 1

output:

NO 3
NO 4
NO 4
NO 9
NO 11
YES
YES
YES
YES
YES
YES

result:

ok 11 lines

Test #32:

score: 14
Accepted
time: 21ms
memory: 4016kb

input:

12 10 7
2 3 0 1 1
3 4 0 1 0 0
4 4 0 1 0 0
5 5 2 4 4 2 1
6 3 1 4 2
7 3 3 1 6
8 5 4 4 0 6 3
9 3 1 4 8
10 5 8 8 7 5 0
11 4 7 0 9 8
6 0 1 1 0 0 0
6 0 0 0 1 1 1
7 1 0 1 0 1 0 0
8 1 1 0 0 0 1 0 1
5 0 1 0 1 1
6 1 1 1 1 1 0
8 0 1 0 0 1 1 1 1

output:

NO 3
NO 4
NO 4
YES
NO 8
NO 13
NO 21
NO 26
YES
YES

result:

ok 10 lines

Test #33:

score: 14
Accepted
time: 22ms
memory: 4064kb

input:

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

output:

NO 3
NO 3
NO 3
NO 10
NO 8
YES
NO 24
NO 53
NO 19
NO 44
YES
YES
YES
YES

result:

ok 14 lines

Test #34:

score: 14
Accepted
time: 19ms
memory: 4156kb

input:

15 13 7
2 3 0 1 0
3 3 1 0 0
4 4 0 1 1 1
5 3 0 4 0
6 3 4 3 0
7 5 6 2 4 1 6
8 3 5 1 6
9 3 4 4 1
10 4 1 6 7 8
11 4 8 1 7 8
12 5 10 7 1 11 11
13 4 10 1 10 10
14 3 10 1 12
8 0 0 0 1 0 1 0 1
8 1 0 1 0 0 0 0 1
8 1 0 0 0 1 1 0 1
7 1 0 0 1 1 0 1
6 0 0 1 1 1 0
6 1 1 0 0 1 1
7 0 0 1 1 0 0 1

output:

NO 3
NO 3
NO 4
YES
NO 8
NO 24
YES
NO 9
YES
YES
YES
YES
YES

result:

ok 13 lines

Test #35:

score: 14
Accepted
time: 8ms
memory: 3804kb

input:

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

output:

NO 4
NO 3
NO 3
NO 7
NO 15
YES
NO 23

result:

ok 7 lines

Test #36:

score: 14
Accepted
time: 695ms
memory: 5872kb

input:

50 48 1
2 2 40 40
3 2 37 37
4 2 26 26
5 2 8 8
6 2 44 44
7 2 32 32
8 2 18 18
9 2 14 14
10 2 7 7
11 2 38 38
12 2 10 10
13 2 36 36
14 2 28 28
15 2 25 25
16 2 49 49
17 2 48 48
18 2 47 47
19 2 6 6
20 2 11 11
21 2 20 20
22 2 31 31
23 2 35 35
24 2 5 5
25 2 41 41
26 2 34 34
27 2 9 9
28 2 29 29
29 2 17 17
30...

output:

NO 4
NO 68719476736
NO 35184372088832
NO 65536
NO 140737488355328
NO 8388608
NO 32768
NO 8589934592
NO 16777216
NO 524288
NO 33554432
NO 4398046511104
NO 4294967296
NO 128
NO 1099511627776
NO 536870912
NO 16384
NO 281474976710656
NO 1048576
NO 2097152
NO 4096
NO 512
NO 131072
NO 64
NO 17592186044416...

result:

ok 48 lines

Test #37:

score: 14
Accepted
time: 393ms
memory: 5100kb

input:

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

output:

NO 68630377364883
NO 27
NO 729
NO 531441
NO 94143178827
NO 19683
NO 22876792454961
NO 4782969
NO 43046721
NO 129140163
NO 387420489
NO 3486784401
NO 177147
NO 10460353203
NO 1594323
NO 7625597484987
NO 847288609443
NO 59049
NO 81
NO 205891132094649
NO 14348907
NO 282429536481
NO 2187
NO 617673396283...

result:

ok 31 lines

Test #38:

score: 14
Accepted
time: 199ms
memory: 4448kb

input:

20 18 1
2 5 19 19 19 19 19
3 5 5 5 5 5 5
4 5 10 10 10 10 10
5 5 12 12 12 12 12
6 5 1 1 1 1 1
7 5 6 6 6 6 6
8 5 3 3 3 3 3
9 5 15 15 15 15 15
10 5 9 9 9 9 9
11 5 8 8 8 8 8
12 5 13 13 13 13 13
13 5 17 17 17 17 17
14 5 16 16 16 16 16
15 5 2 2 2 2 2
16 5 11 11 11 11 11
17 5 7 7 7 7 7
18 5 4 4 4 4 4
19 5 ...

output:

NO 1220703125
NO 78125
NO 762939453125
NO 15625
NO 5
NO 25
NO 390625
NO 30517578125
NO 152587890625
NO 1953125
NO 3125
NO 625
NO 48828125
NO 6103515625
NO 9765625
NO 125
NO 3814697265625
NO 244140625

result:

ok 18 lines

Test #39:

score: 14
Accepted
time: 1ms
memory: 3700kb

input:

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

output:

YES

result:

ok single line: 'YES'

Test #40:

score: 14
Accepted
time: 156ms
memory: 4480kb

input:

20 18 1
2 3 12 12 12
3 5 16 16 16 16 16
4 5 18 18 18 18 18
5 2 10 10
6 3 14 14 14
7 3 8 8 8
8 3 13 13 13
9 3 1 1 1
10 4 3 3 3 3
11 3 19 19 19
12 2 7 7
13 2 4 4
14 2 11 11
15 3 9 9 9
16 3 6 6 6
17 4 2 2 2 2
18 2 15 15
19 4 17 17 17 17
49 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1...

output:

NO 9720
NO 41990400
NO 90
NO 335923200
NO 2799360
NO 1620
NO 540
NO 3
NO 167961600
NO 466560
NO 3240
NO 180
NO 933120
NO 9
NO 8398080
NO 38880
NO 18
NO 155520

result:

ok 18 lines

Test #41:

score: 14
Accepted
time: 0ms
memory: 3540kb

input:

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

output:

YES

result:

ok single line: 'YES'

Test #42:

score: 14
Accepted
time: 0ms
memory: 3592kb

input:

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

output:

YES

result:

ok single line: 'YES'

Subtask #3:

score: 0
Time Limit Exceeded

Test #43:

score: 25
Accepted
time: 1ms
memory: 3736kb

input:

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

output:

NO 2
NO 4
NO 6
NO 10
NO 14
NO 22
NO 30
NO 46
NO 62
NO 94
NO 126
NO 190
NO 254
NO 382
NO 510
NO 766
NO 1022
NO 1534
NO 2046
NO 3070

result:

ok 20 lines

Test #44:

score: 25
Accepted
time: 602ms
memory: 3832kb

input:

4 23 1
2 1 0
2 1 1
2 2 0 0
2 2 0 1
2 2 1 0
2 2 1 1
3 1 2
3 3 0 0 0
3 3 0 0 1
3 3 0 1 0
3 3 0 1 1
3 3 1 0 0
3 3 0 0 1
3 3 1 1 0
3 3 1 1 1
3 4 0 0 0 3
3 4 0 0 1 3
3 4 0 1 0 3
3 4 0 1 1 3
3 4 1 0 0 3
3 4 0 0 1 3
3 4 1 1 0 3
3 4 1 1 1 3
50 0 0 0 1 0 1 0 1 0 1 1 0 0 1 0 1 1 1 0 0 0 1 0 1 1 1 0 0 1 0 1 1 ...

output:

NO 1
NO 1

result:

ok 2 lines

Test #45:

score: 25
Accepted
time: 68ms
memory: 6048kb

input:

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

output:

YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES

result:

ok 48 lines

Test #46:

score: 25
Accepted
time: 1ms
memory: 3700kb

input:

15 28 1
2 4 1 0 1 1
3 4 1 0 1 0
4 4 0 0 0 1
5 1 7
6 4 4 3 1 4
7 1 8
8 1 5
9 4 4 1 4 8
10 3 8 1 9
11 2 6 1
12 2 1 7
13 3 10 1 11
14 2 9 0
9 5 4 8 10 7 0
9 5 10 1 14 14 13
11 5 5 0 6 5 13
13 4 2 2 1 11
3 3 6 8 0
13 4 9 10 9 1
11 5 0 12 6 11 2
9 4 10 0 13 4
11 3 4 1 8
10 5 14 11 9 5 1
10 5 13 8 2 1 9
9...

output:

YES
NO 4
NO 4
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES

result:

ok 13 lines

Test #47:

score: 0
Time Limit Exceeded

input:

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

output:


result:


Subtask #4:

score: 32
Accepted

Test #70:

score: 32
Accepted
time: 1ms
memory: 3812kb

input:

6 6 2
2 2 0 1
3 3 2 0 0
3 2 1 3
4 4 0 3 1 2
5 2 2 1
5 1 5
2 1 1
5 0 0 1 0 0

output:

NO 2
NO 4
NO 9
YES

result:

ok 4 lines

Test #71:

score: 32
Accepted
time: 1ms
memory: 3760kb

input:

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

output:

NO 2
NO 3
NO 6
NO 10
NO 14
NO 22
NO 30
NO 46
NO 62
NO 94
NO 126
NO 190
NO 254
NO 382
NO 510
NO 766
NO 1022
NO 1534
NO 2046
NO 3070

result:

ok 20 lines

Test #72:

score: 32
Accepted
time: 0ms
memory: 3572kb

input:

7 10 4
2 1 0
2 1 1
3 2 0 2
3 2 1 2
4 2 0 3
4 2 1 3
5 2 0 4
5 2 1 4
6 2 0 5
6 2 1 5
2 0 0
2 0 1
2 1 0
2 1 1

output:

NO 1
YES
YES
YES
YES

result:

ok 5 lines

Test #73:

score: 32
Accepted
time: 1ms
memory: 4128kb

input:

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

output:

YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES

result:

ok 48 lines

Test #74:

score: 32
Accepted
time: 1ms
memory: 3660kb

input:

15 28 3
2 4 1 1 0 0
3 4 0 1 0 1
4 4 1 0 1 0
5 1 9
6 2 0 2
7 3 2 1 6
8 4 3 7 6 1
9 1 5
10 3 8 0 5
11 4 6 8 1 9
12 2 11 0
13 2 11 1
14 2 10 1
13 4 5 0 11 12
7 4 7 0 4 13
12 5 14 13 1 4 13
6 5 0 11 5 3 6
8 4 4 8 1 14
3 4 8 1 2 8
11 3 6 4 0
14 3 6 1 11
8 4 11 1 5 7
2 4 2 0 6 8
6 5 5 6 9 1 5
13 3 9 14 0
...

output:

NO 17
NO 4
NO 4
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES

result:

ok 13 lines

Test #75:

score: 32
Accepted
time: 1ms
memory: 4036kb

input:

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

output:

NO 1
NO 2
NO 4
NO 8
NO 16
NO 32
NO 64
NO 128
NO 256
NO 512
NO 1024
NO 2048
NO 4096
NO 8192
NO 16384
NO 32768
NO 65536
NO 131072
NO 262144
NO 524288
NO 1048576
NO 2097152
NO 4194304
NO 8388608
NO 16777216
NO 33554432
NO 67108864
NO 134217728
NO 268435456
NO 536870912
NO 1073741824
NO 2147483648
NO 42...

result:

ok 49 lines

Test #76:

score: 32
Accepted
time: 1ms
memory: 3688kb

input:

12 25 3
2 3 0 0 1
3 3 0 1 1
4 4 0 1 1 0
5 5 0 4 3 2 4
6 5 5 5 5 2 1
7 4 1 4 6 4
8 5 3 7 7 0 5
9 5 7 8 8 0 7
10 3 7 6 1
11 3 6 1 10
3 3 0 10 10
4 3 1 8 9
11 3 7 7 1
7 3 3 9 1
11 5 0 3 10 3 5
8 4 5 6 7 0
3 5 2 2 2 2 2
9 3 11 1 8
8 5 6 0 2 10 11
11 5 4 0 11 4 6
2 3 8 1 9
4 3 11 3 0
8 3 1 5 3
2 5 5 9 8 ...

output:

NO 3
NO 15
YES
YES
YES
YES
YES
YES
YES
YES

result:

ok 10 lines

Test #77:

score: 32
Accepted
time: 1ms
memory: 3876kb

input:

15 24 2
2 4 1 0 0 1
3 4 0 0 1 1
4 3 0 0 1
5 4 2 0 1 12
6 5 5 5 3 5 0
7 4 6 0 3 3
8 4 7 4 1 3
9 5 0 5 8 7 7
10 5 1 9 6 9 9
11 3 0 9 6
12 5 7 0 11 7 11
13 3 0 12 8
14 4 0 9 11 9
3 5 1 13 3 12 2
12 4 1 4 4 8
5 3 1 2 14
12 4 1 8 14 10
2 4 1 4 4 13
6 4 4 0 1 4
11 3 4 11 1
12 3 6 0 2
6 5 1 6 2 2 7
3 4 2 1...

output:

NO 4
YES
NO 3
NO 19
NO 8
YES
YES
YES
YES
YES
NO 13
YES
YES

result:

ok 13 lines

Test #78:

score: 32
Accepted
time: 1ms
memory: 3684kb

input:

8 24 3
2 4 0 1 1 0
3 4 1 0 0 0
4 3 0 1 0
5 4 0 2 4 1
6 3 2 0 3
7 3 3 3 1
4 3 7 4 0
3 5 2 6 1 7 3
2 5 0 5 2 2 3
3 4 4 0 3 5
7 4 7 7 4 1
2 5 3 5 5 1 7
2 4 5 2 0 7
6 3 1 6 6
2 3 1 5 4
6 4 5 5 1 3
4 3 1 6 2
7 5 5 4 5 0 6
5 4 4 1 4 1
2 5 5 0 2 3 4
4 5 0 7 2 3 5
6 4 6 2 7 1
2 5 2 7 1 6 5
2 5 6 1 2 7 7
3 0...

output:

NO 12
NO 4
NO 3
NO 8
YES
YES

result:

ok 6 lines

Test #79:

score: 32
Accepted
time: 11ms
memory: 3748kb

input:

11 25 2
2 4 0 0 0 1
3 4 1 0 0 1
4 4 1 1 0 1
5 4 3 0 4 4
6 4 3 3 2 1
7 3 5 3 1
8 3 6 1 5
9 4 6 8 1 5
7 3 2 6 0
3 4 0 8 6 4
5 3 0 3 4
7 5 5 5 9 0 4
9 4 1 3 7 6
4 3 5 8 0
5 3 9 1 2
6 4 4 1 2 7
6 4 8 1 6 2
8 3 7 8 1
9 4 1 9 5 3
3 4 3 8 3 0
3 5 3 5 5 0 6
6 5 3 8 5 0 2
5 4 4 7 4 0
7 4 6 2 0 2
10 2 2 4
5 0...

output:

NO 4
NO 4
NO 4
NO 27
NO 13
NO 18
NO 41
NO 36
NO 142

result:

ok 9 lines

Test #80:

score: 32
Accepted
time: 1ms
memory: 3624kb

input:

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

output:

NO 4
NO 4
YES
NO 6
NO 12
YES
NO 23

result:

ok 7 lines

Test #81:

score: 32
Accepted
time: 1ms
memory: 3960kb

input:

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

output:

NO 4
YES
YES
YES
NO 6
YES
YES
YES
YES
YES
YES
YES
YES
YES

result:

ok 14 lines

Test #82:

score: 32
Accepted
time: 1ms
memory: 3648kb

input:

13 25 2
2 4 1 1 0 1
3 4 1 0 1 0
4 4 1 0 1 0
5 3 3 0 0
6 4 3 0 2 5
7 3 0 6 5
8 3 4 1 4
9 4 5 1 7 8
10 3 9 0 9
11 3 0 8 8
12 4 10 1 11 7
9 5 7 1 11 4 10
5 4 2 1 6 2
9 3 1 4 12
8 5 9 7 1 12 3
5 5 7 7 3 0 4
11 4 6 1 11 6
10 5 1 12 7 5 9
5 5 11 3 0 7 3
12 3 8 5 1
2 4 0 10 4 2
7 3 1 10 10
11 3 12 0 4
7 3 ...

output:

NO 4
NO 4
NO 4
NO 6
NO 15
YES
NO 9
YES
YES
YES
YES

result:

ok 11 lines

Test #83:

score: 32
Accepted
time: 12ms
memory: 3732kb

input:

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

output:

NO 4
NO 4
NO 4
NO 77
NO 6
NO 18
NO 13
NO 31

result:

ok 8 lines

Test #84:

score: 32
Accepted
time: 1ms
memory: 3772kb

input:

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

output:

NO 4
NO 4
NO 4
NO 6
NO 12
NO 25
YES
YES
YES
YES
YES
YES

result:

ok 12 lines

Test #85:

score: 32
Accepted
time: 8ms
memory: 3992kb

input:

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

output:

NO 4
NO 4
NO 4
NO 9
NO 245
NO 28
NO 42
NO 259
NO 117
NO 352
NO 146
NO 146

result:

ok 12 lines

Test #86:

score: 32
Accepted
time: 3ms
memory: 4060kb

input:

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

output:

NO 1
NO 5
NO 13
NO 29
NO 61
NO 125
NO 253
NO 509
NO 1021
NO 2045
NO 4093
NO 8189
NO 16381
NO 32765
NO 65533
NO 131069
NO 262141
NO 524285
NO 1048573
NO 2097149
NO 4194301
NO 8388605
NO 16777213
NO 33554429
NO 67108861
NO 134217725
NO 268435453
NO 536870909
NO 1073741821
NO 2147483645
NO 4294967293
N...

result:

ok 47 lines

Subtask #5:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Dependency #3:

0%