QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#628593#5438. Half Mixed523555337AC ✓647ms61680kbC++141.9kb2024-10-10 21:08:282024-10-10 21:08:28

Judging History

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

  • [2024-10-10 21:08:28]
  • 评测
  • 测评结果:AC
  • 用时:647ms
  • 内存:61680kb
  • [2024-10-10 21:08:28]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
#define ll long long
#define ull unsigned long long
#define mp make_pair
#define pb push_back
#define se second
#define fi first
#define ret(i,a,b) for(int i = (a);i<=(b);++i)
const int N=1e5+5;
const int M=1e6+5;
const ll inf=1e18;
const ll mod=998244353;
ll ksm(ll a,ll b)
{
	ll ret=1;
	while(b)
	{
		if(b&1) ret=ret*a%mod;
		a=a*a%mod;
		b>>=1;
	}
	return ret;
}
inline int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9')
	{
        if(ch=='-')
            f=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9')
	{
        x=(x<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
    return x*f;
}
ll n,m,k;
ll p[M],ans[M];
void work()
{
	ll tot=m;
	ll anss=(m*m-m)/2;
	while(tot)
	{
		ll t=sqrt(anss);
		while(tot-t>anss-t*t) t--;
		anss-=t*t;
		tot-=t;
		ans[++k]=t;
		if(tot==anss)
		{
			ret(i,1,tot)
			{
				ans[++k]=1;
			}
			break;
		}
	}
	return ;
}
void solve()
{
	cin>>n>>m;
	k=0;
	if((n*(n+1)/2)%2==1&&(m*(m+1)/2)%2==1)
	{
		cout<<"No\n";
		return ;
	}
	bool swaped=0;
	if(n*(n+1)%4==0)
	{
		swap(n,m);
		swaped=1;
	}
	work();
	cout<<"Yes\n";
	if(!swaped)
	{
		vector<vector<int>> y(n+1,vector<int>(m+1));
		int w=0;
		int tot=0;
		ret(i,1,k)
		{
			ret(j,1,ans[i])
			{
				++tot;
				ret(x,1,n)
				{
					y[x][tot]=w;
				}
			}
			w=1-w;
		}
		ret(i,1,n)
		{
			ret(j,1,m)
			  cout<<y[i][j]<<" ";
			cout<<endl;
		}
	}
	else
	{
		vector<vector<int>> y(m+1,vector<int>(n+1));
		int w=0;
		int tot=0;
		ret(i,1,k)
		{
			ret(j,1,ans[i])
			{
				++tot;
				ret(x,1,n)
				{
					y[tot][x]=w;
				}
			}
			w=1-w;
		}
		ret(i,1,m)
		{
			ret(j,1,n)
			  cout<<y[i][j]<<" ";
			cout<<endl;
		}
	}
	return ;
}
int main()
{
	ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
	int _=1;
	cin>>_;
	while(_--) solve();
	return 0;
}



詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 3632kb

input:

2
2 3
1 1

output:

Yes
0 1 0 
0 1 0 
No

result:

ok OK, Accepted. (2 test cases)

Test #2:

score: 0
Accepted
time: 172ms
memory: 3692kb

input:

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

output:

No
No
No
Yes
0 1 0 
No
Yes
0 
1 
0 
Yes
0 0 1 0 
Yes
0 1 0 
0 1 0 
Yes
0 0 
1 1 
0 0 
Yes
0 
0 
1 
0 
No
Yes
0 0 1 0 
0 0 1 0 
Yes
0 0 0 
1 1 1 
0 0 0 
Yes
0 0 
0 0 
1 1 
0 0 
No
No
No
Yes
0 0 0 0 
1 1 1 1 
0 0 0 0 
Yes
0 0 0 
0 0 0 
1 1 1 
0 0 0 
No
No
Yes
0 0 0 0 1 1 0 
No
Yes
0 0 0 0 0 
1 1 1 1 1...

result:

ok OK, Accepted. (5382 test cases)

Test #3:

score: 0
Accepted
time: 162ms
memory: 3820kb

input:

1177
50 50
50 51
51 50
50 52
51 51
52 50
50 53
51 52
52 51
53 50
50 54
51 53
52 52
53 51
54 50
50 55
51 54
52 53
53 52
54 51
55 50
50 56
51 55
52 54
53 53
54 52
55 51
56 50
50 57
51 56
52 55
53 54
54 53
55 52
56 51
57 50
50 58
51 57
52 56
53 55
54 54
55 53
56 52
57 51
58 50
50 59
51 58
52 57
53 56
5...

output:

No
Yes
0 0 0 0 0 0 0 0 0 0 0 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 1 1 1 1 1 0 0 1 1 0 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 1 1 1 1 1 1 0 0 1 1 0 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 1 1 1 1 1 1 0 0 1...

result:

ok OK, Accepted. (1177 test cases)

Test #4:

score: 0
Accepted
time: 150ms
memory: 3868kb

input:

420
100 100
100 101
101 100
100 102
101 101
102 100
100 103
101 102
102 101
103 100
100 104
101 103
102 102
103 101
104 100
100 105
101 104
102 103
103 102
104 101
105 100
100 106
101 105
102 104
103 103
104 102
105 101
106 100
100 107
101 106
102 105
103 104
104 103
105 102
106 101
107 100
100 108
...

output:

Yes
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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 OK, Accepted. (420 test cases)

Test #5:

score: 0
Accepted
time: 148ms
memory: 6380kb

input:

6
900 900
900 901
901 900
900 902
901 901
902 900

output:

Yes
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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 OK, Accepted. (6 test cases)

Test #6:

score: 0
Accepted
time: 607ms
memory: 3740kb

input:

3152
10 1
11 1
12 1
13 1
14 1
15 1
16 1
17 1
18 1
19 1
20 1
21 1
22 1
23 1
24 1
25 1
26 1
27 1
28 1
29 1
30 1
31 1
32 1
33 1
34 1
35 1
36 1
37 1
38 1
39 1
40 1
41 1
42 1
43 1
44 1
45 1
46 1
47 1
48 1
49 1
50 1
51 1
52 1
53 1
54 1
55 1
56 1
57 1
58 1
59 1
60 1
61 1
62 1
63 1
64 1
65 1
66 1
67 1
68 1
...

output:

No
Yes
0 
0 
0 
0 
0 
0 
0 
1 
1 
0 
1 
Yes
0 
0 
0 
0 
0 
0 
0 
1 
1 
1 
1 
0 
No
No
Yes
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
1 
0 
1 
0 
1 
Yes
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
1 
1 
1 
1 
0 
0 
No
No
Yes
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
1 
1 
1 
1 
1 
0 
1 
Yes
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
1 
...

result:

ok OK, Accepted. (3152 test cases)

Test #7:

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

input:

3152
1 10
1 11
1 12
1 13
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30
1 31
1 32
1 33
1 34
1 35
1 36
1 37
1 38
1 39
1 40
1 41
1 42
1 43
1 44
1 45
1 46
1 47
1 48
1 49
1 50
1 51
1 52
1 53
1 54
1 55
1 56
1 57
1 58
1 59
1 60
1 61
1 62
1 63
1 64
1 65
1 66
1 67
1 68
...

output:

No
Yes
0 0 0 0 0 0 0 1 1 0 1 
Yes
0 0 0 0 0 0 0 1 1 1 1 0 
No
No
Yes
0 0 0 0 0 0 0 0 0 0 1 0 1 0 1 
Yes
0 0 0 0 0 0 0 0 0 0 1 1 1 1 0 0 
No
No
Yes
0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 0 1 
Yes
0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 0 0 1 
No
No
Yes
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 0 1 0 
Yes
0 0 0 0 ...

result:

ok OK, Accepted. (3152 test cases)

Test #8:

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

input:

3064
100 1
101 1
102 1
103 1
104 1
105 1
106 1
107 1
108 1
109 1
110 1
111 1
112 1
113 1
114 1
115 1
116 1
117 1
118 1
119 1
120 1
121 1
122 1
123 1
124 1
125 1
126 1
127 1
128 1
129 1
130 1
131 1
132 1
133 1
134 1
135 1
136 1
137 1
138 1
139 1
140 1
141 1
142 1
143 1
144 1
145 1
146 1
147 1
148 1
1...

output:

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

result:

ok OK, Accepted. (3064 test cases)

Test #9:

score: 0
Accepted
time: 90ms
memory: 3848kb

input:

3064
1 100
1 101
1 102
1 103
1 104
1 105
1 106
1 107
1 108
1 109
1 110
1 111
1 112
1 113
1 114
1 115
1 116
1 117
1 118
1 119
1 120
1 121
1 122
1 123
1 124
1 125
1 126
1 127
1 128
1 129
1 130
1 131
1 132
1 133
1 134
1 135
1 136
1 137
1 138
1 139
1 140
1 141
1 142
1 143
1 144
1 145
1 146
1 147
1 148
1...

output:

Yes
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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 1 1 1 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 
No
No
Yes
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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 OK, Accepted. (3064 test cases)

Test #10:

score: 0
Accepted
time: 599ms
memory: 3792kb

input:

2316
1000 1
1001 1
1002 1
1003 1
1004 1
1005 1
1006 1
1007 1
1008 1
1009 1
1010 1
1011 1
1012 1
1013 1
1014 1
1015 1
1016 1
1017 1
1018 1
1019 1
1020 1
1021 1
1022 1
1023 1
1024 1
1025 1
1026 1
1027 1
1028 1
1029 1
1030 1
1031 1
1032 1
1033 1
1034 1
1035 1
1036 1
1037 1
1038 1
1039 1
1040 1
1041 1
1...

output:

Yes
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
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 OK, Accepted. (2316 test cases)

Test #11:

score: 0
Accepted
time: 85ms
memory: 3684kb

input:

2316
1 1000
1 1001
1 1002
1 1003
1 1004
1 1005
1 1006
1 1007
1 1008
1 1009
1 1010
1 1011
1 1012
1 1013
1 1014
1 1015
1 1016
1 1017
1 1018
1 1019
1 1020
1 1021
1 1022
1 1023
1 1024
1 1025
1 1026
1 1027
1 1028
1 1029
1 1030
1 1031
1 1032
1 1033
1 1034
1 1035
1 1036
1 1037
1 1038
1 1039
1 1040
1 1041
1...

output:

Yes
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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 OK, Accepted. (2316 test cases)

Test #12:

score: 0
Accepted
time: 575ms
memory: 3752kb

input:

488
10000 1
10001 1
10002 1
10003 1
10004 1
10005 1
10006 1
10007 1
10008 1
10009 1
10010 1
10011 1
10012 1
10013 1
10014 1
10015 1
10016 1
10017 1
10018 1
10019 1
10020 1
10021 1
10022 1
10023 1
10024 1
10025 1
10026 1
10027 1
10028 1
10029 1
10030 1
10031 1
10032 1
10033 1
10034 1
10035 1
10036 1
...

output:

Yes
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
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 OK, Accepted. (488 test cases)

Test #13:

score: 0
Accepted
time: 97ms
memory: 3756kb

input:

488
1 10000
1 10001
1 10002
1 10003
1 10004
1 10005
1 10006
1 10007
1 10008
1 10009
1 10010
1 10011
1 10012
1 10013
1 10014
1 10015
1 10016
1 10017
1 10018
1 10019
1 10020
1 10021
1 10022
1 10023
1 10024
1 10025
1 10026
1 10027
1 10028
1 10029
1 10030
1 10031
1 10032
1 10033
1 10034
1 10035
1 10036
...

output:

Yes
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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 OK, Accepted. (488 test cases)

Test #14:

score: 0
Accepted
time: 647ms
memory: 9040kb

input:

49
100000 1
100001 1
100002 1
100003 1
100004 1
100005 1
100006 1
100007 1
100008 1
100009 1
100010 1
100011 1
100012 1
100013 1
100014 1
100015 1
100016 1
100017 1
100018 1
100019 1
100020 1
100021 1
100022 1
100023 1
100024 1
100025 1
100026 1
100027 1
100028 1
100029 1
100030 1
100031 1
100032 1
...

output:

Yes
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
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 OK, Accepted. (49 test cases)

Test #15:

score: 0
Accepted
time: 95ms
memory: 6512kb

input:

49
1 100000
1 100001
1 100002
1 100003
1 100004
1 100005
1 100006
1 100007
1 100008
1 100009
1 100010
1 100011
1 100012
1 100013
1 100014
1 100015
1 100016
1 100017
1 100018
1 100019
1 100020
1 100021
1 100022
1 100023
1 100024
1 100025
1 100026
1 100027
1 100028
1 100029
1 100030
1 100031
1 100032
...

output:

Yes
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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 OK, Accepted. (49 test cases)

Test #16:

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

input:

5
999990 1
999991 1
999992 1
999993 1
999994 1

output:

No
Yes
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
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 OK, Accepted. (5 test cases)

Test #17:

score: 0
Accepted
time: 75ms
memory: 17300kb

input:

5
1 999990
1 999991
1 999992
1 999993
1 999994

output:

No
Yes
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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 OK, Accepted. (5 test cases)

Test #18:

score: 0
Accepted
time: 252ms
memory: 13656kb

input:

8
115932 8
2 500000
89071 11
14 71428
13088 76
3050 32
10 48
3 1

output:

Yes
0 0 0 0 0 0 0 0 
0 0 0 0 0 0 0 0 
0 0 0 0 0 0 0 0 
0 0 0 0 0 0 0 0 
0 0 0 0 0 0 0 0 
0 0 0 0 0 0 0 0 
0 0 0 0 0 0 0 0 
0 0 0 0 0 0 0 0 
0 0 0 0 0 0 0 0 
0 0 0 0 0 0 0 0 
0 0 0 0 0 0 0 0 
0 0 0 0 0 0 0 0 
0 0 0 0 0 0 0 0 
0 0 0 0 0 0 0 0 
0 0 0 0 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 OK, Accepted. (8 test cases)

Test #19:

score: 0
Accepted
time: 202ms
memory: 10044kb

input:

8
271 3690
14724 67
78 12820
46 21739
3 333333
8 1693
4 1
1 1

output:

Yes
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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 OK, Accepted. (8 test cases)

Test #20:

score: 0
Accepted
time: 348ms
memory: 39840kb

input:

9
632823 1
87 11494
68574 14
156 6410
779 1283
14381 28
24 211
5 2
1 4

output:

Yes
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
0 
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 OK, Accepted. (9 test cases)

Test #21:

score: 0
Accepted
time: 268ms
memory: 34108kb

input:

8
1479 676
514419 1
60 16666
525 1904
190106 5
32 16740
5 1
2 1

output:

Yes
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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 OK, Accepted. (8 test cases)

Test #22:

score: 0
Accepted
time: 120ms
memory: 9876kb

input:

8
3 333333
3041 328
52793 18
1769 565
46 21739
5049 10
17 135
3 5

output:

Yes
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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 OK, Accepted. (8 test cases)

Test #23:

score: 0
Accepted
time: 208ms
memory: 8092kb

input:

8
8071 123
18 55555
46 21739
5962 167
11318 88
19 823
6 1
2 1

output:

Yes
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
0 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 OK, Accepted. (8 test cases)

Test #24:

score: 0
Accepted
time: 105ms
memory: 10088kb

input:

8
19 52631
106233 9
40645 24
20089 49
3 333333
11847 7
13 88
1 1

output:

Yes
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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 OK, Accepted. (8 test cases)

Test #25:

score: 0
Accepted
time: 116ms
memory: 7444kb

input:

8
44054 22
628 1592
36 27777
67690 14
674 1483
52 1612
23 1
3 5

output:

No
Yes
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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 OK, Accepted. (8 test cases)

Test #26:

score: 0
Accepted
time: 235ms
memory: 15672kb

input:

10
103 9708
4 250000
31291 31
228086 4
164393 6
28461 4
34 514
15 2
2 1
1 1

output:

Yes
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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 OK, Accepted. (10 test cases)

Test #27:

score: 0
Accepted
time: 141ms
memory: 14288kb

input:

8
10 100000
485 2061
131387 7
58622 17
2 500000
81746 1
27 88
1 10

output:

Yes
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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 OK, Accepted. (8 test cases)

Test #28:

score: 0
Accepted
time: 208ms
memory: 23500kb

input:

9
4 250000
328199 3
3194 313
87 11494
20 50000
205 76
4 30
2 1
1 1

output:

Yes
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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 OK, Accepted. (9 test cases)

Test #29:

score: 0
Accepted
time: 235ms
memory: 13572kb

input:

6
2 500000
222 4504
78 12820
130399 7
207 4830
3 29183

output:

Yes
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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 OK, Accepted. (6 test cases)

Test #30:

score: 0
Accepted
time: 136ms
memory: 14184kb

input:

7
573234 1
150240 6
2 500000
194 5154
2192 456
5809 90
2 1544

output:

No
Yes
0 0 0 0 0 0 
0 0 0 0 0 0 
0 0 0 0 0 0 
0 0 0 0 0 0 
0 0 0 0 0 0 
0 0 0 0 0 0 
0 0 0 0 0 0 
0 0 0 0 0 0 
0 0 0 0 0 0 
0 0 0 0 0 0 
0 0 0 0 0 0 
0 0 0 0 0 0 
0 0 0 0 0 0 
0 0 0 0 0 0 
0 0 0 0 0 0 
0 0 0 0 0 0 
0 0 0 0 0 0 
0 0 0 0 0 0 
0 0 0 0 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 OK, Accepted. (7 test cases)

Test #31:

score: 0
Accepted
time: 328ms
memory: 19800kb

input:

8
217556 4
102 9803
45863 21
290059 3
23220 43
14 21293
7 1
1 1

output:

Yes
0 0 0 0 
0 0 0 0 
0 0 0 0 
0 0 0 0 
0 0 0 0 
0 0 0 0 
0 0 0 0 
0 0 0 0 
0 0 0 0 
0 0 0 0 
0 0 0 0 
0 0 0 0 
0 0 0 0 
0 0 0 0 
0 0 0 0 
0 0 0 0 
0 0 0 0 
0 0 0 0 
0 0 0 0 
0 0 0 0 
0 0 0 0 
0 0 0 0 
0 0 0 0 
0 0 0 0 
0 0 0 0 
0 0 0 0 
0 0 0 0 
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 OK, Accepted. (8 test cases)

Test #32:

score: 0
Accepted
time: 270ms
memory: 17200kb

input:

11
82568 12
68775 14
1115 896
433 2309
245967 4
4727 13
601 3
168 2
4 9
2 1
1 1

output:

Yes
0 0 0 0 0 0 0 0 0 0 0 0 
0 0 0 0 0 0 0 0 0 0 0 0 
0 0 0 0 0 0 0 0 0 0 0 0 
0 0 0 0 0 0 0 0 0 0 0 0 
0 0 0 0 0 0 0 0 0 0 0 0 
0 0 0 0 0 0 0 0 0 0 0 0 
0 0 0 0 0 0 0 0 0 0 0 0 
0 0 0 0 0 0 0 0 0 0 0 0 
0 0 0 0 0 0 0 0 0 0 0 0 
0 0 0 0 0 0 0 0 0 0 0 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 OK, Accepted. (11 test cases)

Test #33:

score: 0
Accepted
time: 607ms
memory: 61680kb

input:

5
1 999999
1 1000000
999999 1
1000000 1
1000 1000

output:

Yes
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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 OK, Accepted. (5 test cases)