QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#357611#7942. $K$ Subsequencesmcpqndq#AC ✓957ms14552kbC++171.1kb2024-03-19 02:39:322024-03-19 02:39:32

Judging History

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

  • [2024-03-19 02:39:32]
  • 评测
  • 测评结果:AC
  • 用时:957ms
  • 内存:14552kb
  • [2024-03-19 02:39:32]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define F first
#define S second
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int n,k;
int a[200'100];

vi solve(int cap){
	set<pii> pq;
	vi b(n);
	rep(i,0,k) pq.insert({cap,i+1});
	rep(i,0,n){
		if(a[i]==1){
			auto itr = prev(pq.end());
			if(itr->F == 0) return {};
			b[i]=itr->S;
			pii nex{itr->F - 1, itr->S};
			pq.erase(itr);
			pq.insert(nex);
		}else{ // a[i]==-1
			auto itr = pq.begin();
			pii nex{min(cap, itr->F + 1), itr->S};
			b[i]=itr->S;
			pq.erase(itr);
			pq.insert(nex);
		}
	}
	return b;
}

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);
	int tests;cin>>tests;
	while(tests--){
		cin>>n>>k;
		rep(i,0,n)cin>>a[i];
		int lo = -1;
		int hi = n;
		while(lo+1<hi){
			int m = lo+(hi-lo)/2;
			vi b = solve(m);
			if(sz(b)>0) hi=m;
			else lo=m;
		}
		vi b = solve(hi);
		// cout<<hi<<": ";
		rep(i,0,n)cout<<b[i]<<' ';
		cout<<'\n';
	}
}

这程序好像有点Bug,我给组数据试试?

详细

Test #1:

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

input:

5
3 2
1 -1 1
4 2
-1 1 1 -1
7 3
1 1 1 1 1 1 1
10 3
1 1 1 1 -1 -1 1 1 1 1
12 4
1 1 1 1 -1 -1 -1 -1 1 1 1 1

output:

2 2 2 
1 2 1 1 
3 2 1 3 2 1 3 
3 2 1 3 3 1 1 3 2 1 
4 3 2 1 1 2 3 4 4 3 2 1 

result:

ok Correct (5 test cases)

Test #2:

score: 0
Accepted
time: 43ms
memory: 3456kb

input:

18434
10 1
-1 1 1 -1 -1 1 -1 -1 1 1
10 2
-1 -1 -1 1 1 -1 1 1 1 1
10 2
1 -1 -1 -1 -1 1 1 -1 1 1
10 7
1 1 -1 1 -1 1 1 -1 -1 1
9 1
-1 1 -1 1 1 -1 1 -1 1
8 1
-1 -1 -1 -1 1 1 -1 -1
10 3
-1 -1 -1 1 1 1 1 -1 -1 -1
9 1
1 -1 -1 1 -1 -1 -1 -1 -1
10 10
-1 1 1 1 1 1 1 1 1 1
10 4
-1 1 -1 1 -1 1 1 -1 1 1
9 3
1 1 ...

output:

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

result:

ok Correct (18434 test cases)

Test #3:

score: 0
Accepted
time: 129ms
memory: 5332kb

input:

1
199996 3
1 -1 1 1 1 1 -1 -1 -1 1 1 -1 1 -1 1 1 -1 -1 1 1 1 1 -1 1 -1 -1 -1 1 -1 1 1 1 1 1 1 1 -1 -1 -1 1 -1 -1 1 1 -1 -1 -1 1 -1 1 1 -1 1 -1 -1 1 1 1 1 -1 1 1 1 1 1 1 1 1 -1 -1 -1 -1 1 1 -1 1 1 -1 1 -1 -1 -1 -1 -1 1 1 -1 -1 1 1 -1 1 -1 1 1 -1 1 1 1 -1 1 -1 1 1 1 -1 -1 -1 1 1 -1 -1 1 -1 -1 -1 -1 -1...

output:

3 3 3 2 1 3 3 1 2 2 1 1 1 1 1 3 3 1 1 3 2 1 1 1 1 2 3 3 3 3 2 1 3 2 1 3 3 1 2 2 2 3 3 2 2 3 1 1 1 1 3 3 3 3 1 1 3 2 1 1 1 3 2 1 3 2 1 3 3 1 2 3 3 2 2 2 1 1 1 1 2 3 1 2 2 1 1 2 2 1 1 1 1 1 3 3 3 2 1 1 1 1 1 3 2 2 3 1 1 3 3 1 1 1 2 3 1 2 3 3 2 1 1 1 3 2 1 3 2 2 2 2 2 1 3 3 1 2 3 3 3 3 3 3 2 2 3 3 3 3 ...

result:

ok Correct (1 test case)

Test #4:

score: 0
Accepted
time: 200ms
memory: 5396kb

input:

1
199998 152
-1 1 -1 -1 1 -1 -1 -1 -1 -1 -1 1 -1 -1 1 -1 -1 -1 1 -1 -1 1 -1 1 1 -1 -1 1 1 1 -1 -1 -1 1 -1 1 -1 1 1 -1 -1 -1 -1 -1 -1 -1 -1 1 -1 1 1 -1 -1 1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 -1 1 -1 1 1 1 1 -1 1 1 1 -1 -1 1 -1 -1 1 1 -1 -1 -1 -1 1 -1 -1 1 -1 1 1 -1 1 1 -1 -1 1 -1 -1 1 -1 1 -1 1 1 -1...

output:

1 152 152 1 152 152 1 1 1 1 1 152 152 1 152 152 1 1 152 152 1 152 152 152 151 151 152 152 151 150 150 151 152 152 152 152 152 152 151 151 152 1 1 1 1 1 1 152 152 152 151 151 152 152 151 151 151 151 151 151 151 151 151 151 151 151 151 151 152 152 152 152 151 150 149 149 149 148 147 147 148 148 148 14...

result:

ok Correct (1 test case)

Test #5:

score: 0
Accepted
time: 205ms
memory: 5152kb

input:

1
199996 136
-1 1 1 1 1 1 -1 1 -1 -1 1 -1 1 1 -1 -1 1 1 1 1 1 -1 1 -1 -1 1 -1 1 1 -1 -1 1 -1 -1 1 -1 1 1 1 1 1 1 -1 -1 -1 -1 1 -1 -1 -1 -1 -1 -1 -1 -1 1 1 1 -1 1 1 1 -1 1 1 1 1 1 -1 -1 1 -1 1 -1 -1 1 1 1 1 -1 1 -1 -1 -1 -1 1 1 -1 -1 -1 -1 1 -1 1 1 1 1 1 -1 -1 1 1 1 1 1 1 1 1 1 1 1 -1 -1 -1 1 1 1 1 1...

output:

1 136 135 134 133 132 132 132 132 133 133 133 133 132 132 133 133 132 131 130 129 129 129 129 130 130 130 130 129 129 130 130 130 131 131 131 131 130 129 128 127 126 126 127 128 129 129 129 130 131 132 133 134 135 136 136 135 134 134 134 133 132 132 132 131 130 129 128 128 129 129 129 129 129 130 13...

result:

ok Correct (1 test case)

Test #6:

score: 0
Accepted
time: 586ms
memory: 9184kb

input:

1
199998 86240
1 1 -1 1 1 1 1 1 1 -1 1 1 -1 1 -1 -1 -1 1 1 1 1 1 1 1 -1 1 1 1 1 1 -1 1 -1 -1 -1 -1 -1 -1 -1 -1 1 -1 -1 1 -1 -1 -1 -1 1 1 -1 -1 -1 1 1 -1 -1 1 1 -1 1 -1 1 -1 1 -1 1 1 1 1 1 -1 1 -1 1 -1 1 -1 -1 1 1 1 -1 -1 -1 -1 -1 -1 1 1 1 1 -1 -1 -1 1 1 -1 -1 1 -1 1 1 1 -1 -1 -1 1 -1 -1 -1 -1 1 1 -1...

output:

86240 86239 86239 86239 86238 86237 86236 86235 86234 86234 86234 86233 86233 86233 86233 86234 86235 86235 86234 86233 86232 86231 86230 86229 86229 86229 86228 86227 86226 86225 86225 86225 86225 86226 86227 86228 86229 86230 86231 86232 86232 86232 86233 86233 86233 86234 86235 86236 86236 86235 ...

result:

ok Correct (1 test case)

Test #7:

score: 0
Accepted
time: 957ms
memory: 14552kb

input:

1
199998 196586
1 -1 -1 -1 1 -1 1 -1 1 -1 -1 -1 1 -1 -1 -1 1 -1 -1 -1 -1 -1 1 -1 1 1 1 -1 -1 -1 1 -1 -1 -1 1 1 -1 1 -1 1 -1 1 1 1 -1 -1 -1 -1 1 -1 -1 -1 1 -1 -1 1 -1 -1 -1 1 1 1 1 1 -1 1 1 -1 1 1 1 1 -1 -1 -1 1 1 -1 -1 1 1 -1 -1 -1 1 -1 -1 -1 1 -1 -1 -1 1 -1 -1 1 -1 1 -1 -1 1 -1 1 -1 1 1 -1 -1 -1 -1...

output:

196586 196586 1 1 196586 196586 196586 196586 196586 196586 1 1 196586 196586 1 1 196586 196586 1 1 1 1 196586 196586 196586 196585 196584 196584 196585 196586 196586 196586 1 1 196586 196585 196585 196585 196585 196585 196585 196585 196584 196583 196583 196584 196585 196586 196586 196586 1 1 196586...

result:

ok Correct (1 test case)

Test #8:

score: 0
Accepted
time: 684ms
memory: 10280kb

input:

2
53064 32664
1 1 1 -1 1 1 1 -1 1 1 1 -1 -1 1 -1 -1 1 1 1 -1 -1 1 -1 1 1 1 -1 -1 -1 1 -1 -1 -1 -1 -1 1 -1 1 -1 -1 1 -1 -1 1 1 -1 -1 -1 -1 1 1 1 -1 1 -1 -1 -1 -1 1 1 1 1 -1 1 1 -1 1 -1 1 -1 -1 1 -1 1 -1 -1 1 -1 1 1 -1 1 1 -1 -1 -1 1 1 1 1 1 -1 1 1 -1 1 1 -1 -1 -1 -1 1 1 -1 -1 -1 1 -1 1 1 -1 -1 1 1 1 ...

output:

32664 32663 32662 32662 32662 32661 32660 32660 32660 32659 32658 32658 32659 32659 32659 32660 32660 32659 32658 32658 32659 32659 32659 32659 32658 32657 32657 32658 32659 32659 32659 32660 32661 32662 32663 32663 32663 32663 32663 32664 32664 32664 1 32664 32663 32663 32664 1 1 32664 32663 32662 ...

result:

ok Correct (2 test cases)

Test #9:

score: 0
Accepted
time: 110ms
memory: 4668kb

input:

2
86135 2
1 1 -1 -1 -1 1 1 -1 1 -1 -1 1 -1 1 -1 -1 -1 1 -1 1 1 1 1 -1 -1 1 -1 -1 1 1 1 -1 -1 1 1 -1 -1 -1 1 1 1 1 1 1 1 1 -1 -1 1 1 1 1 1 -1 1 -1 1 1 -1 1 -1 -1 1 -1 -1 -1 -1 1 -1 -1 1 1 1 -1 1 -1 1 1 -1 1 1 1 -1 1 -1 1 -1 1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 1 1 -1 1 -1 1 1 1 1 1 1 1 -1 1 -1 1 -1 1 -1 1...

output:

2 1 1 2 1 2 1 1 1 1 2 2 2 2 2 1 1 2 2 2 1 2 1 1 2 2 2 1 1 2 1 1 2 2 1 1 2 1 1 2 1 2 1 2 1 2 2 1 1 2 1 2 1 1 1 1 1 2 2 2 2 1 1 1 2 1 2 2 2 1 1 2 1 1 1 1 1 2 2 2 1 2 2 2 2 2 2 2 2 1 2 1 2 1 2 1 2 1 1 2 2 2 2 2 1 2 1 2 1 2 2 2 2 2 2 2 2 2 1 1 2 1 1 2 1 1 1 1 1 1 2 1 2 1 2 1 1 1 1 1 1 2 2 1 1 2 2 2 1 1 ...

result:

ok Correct (2 test cases)

Test #10:

score: 0
Accepted
time: 264ms
memory: 5640kb

input:

2
114819 248
-1 -1 -1 -1 -1 1 -1 1 -1 -1 1 -1 1 1 -1 1 -1 -1 1 -1 -1 1 -1 1 -1 1 -1 -1 -1 -1 -1 -1 -1 -1 1 -1 1 -1 -1 1 -1 1 1 1 1 -1 -1 -1 -1 1 1 1 1 1 -1 -1 1 -1 -1 -1 1 -1 -1 -1 1 -1 -1 1 1 -1 -1 -1 1 1 -1 -1 -1 1 -1 1 -1 -1 -1 1 1 -1 -1 -1 -1 1 1 1 -1 -1 -1 -1 1 -1 -1 -1 1 1 1 -1 -1 -1 -1 -1 1 -...

output:

1 1 1 1 1 248 248 248 248 1 248 248 248 247 247 247 247 248 248 248 1 248 248 248 248 248 248 1 1 1 1 1 1 1 248 248 248 248 1 248 248 248 247 246 245 245 246 247 248 248 247 246 245 244 244 245 245 245 246 247 247 247 248 1 248 248 1 248 247 247 248 1 248 247 247 248 1 248 248 248 248 1 1 248 247 24...

result:

ok Correct (2 test cases)

Test #11:

score: 0
Accepted
time: 280ms
memory: 6204kb

input:

2
51745 1
-1 1 1 -1 1 -1 -1 1 -1 1 -1 1 1 1 -1 -1 1 -1 1 1 1 1 1 -1 1 -1 -1 1 -1 -1 1 -1 1 1 -1 1 -1 1 1 -1 1 1 -1 1 1 1 -1 -1 1 -1 1 -1 -1 -1 1 -1 -1 1 1 -1 -1 1 1 -1 -1 -1 1 1 -1 1 -1 -1 1 1 1 -1 -1 1 -1 -1 1 -1 -1 -1 1 -1 -1 -1 1 -1 -1 1 -1 1 -1 -1 -1 -1 1 1 1 1 1 1 -1 -1 -1 -1 1 1 -1 1 1 -1 1 1 ...

output:

1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

result:

ok Correct (2 test cases)

Test #12:

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

input:

2
190655 1
1 -1 -1 -1 1 -1 -1 1 -1 -1 -1 -1 -1 -1 -1 1 -1 -1 -1 -1 -1 -1 1 1 1 -1 -1 1 1 -1 -1 -1 1 -1 -1 -1 1 1 -1 -1 1 -1 -1 1 1 1 1 1 -1 -1 1 -1 1 1 -1 1 1 -1 -1 -1 1 -1 -1 1 1 -1 -1 -1 1 1 1 -1 1 -1 -1 -1 1 1 1 -1 -1 -1 -1 -1 1 1 -1 1 -1 1 -1 1 -1 -1 -1 -1 1 1 -1 -1 -1 1 -1 -1 1 1 1 1 1 1 -1 -1 ...

output:

1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

result:

ok Correct (2 test cases)

Test #13:

score: 0
Accepted
time: 173ms
memory: 5060kb

input:

3
509 3
-1 -1 1 1 -1 -1 1 1 -1 -1 -1 1 -1 -1 -1 -1 -1 -1 -1 1 1 -1 -1 1 1 1 -1 1 -1 1 -1 -1 1 -1 1 -1 1 -1 -1 -1 1 -1 -1 -1 1 1 1 -1 -1 -1 -1 -1 1 -1 1 -1 -1 -1 -1 1 -1 -1 -1 1 -1 -1 1 -1 1 -1 -1 1 -1 1 1 -1 -1 -1 1 -1 1 1 -1 -1 1 1 -1 -1 1 -1 -1 1 1 1 -1 1 -1 1 -1 -1 -1 1 1 1 -1 1 1 1 1 -1 1 -1 1 -...

output:

1 1 3 2 2 3 3 2 2 3 1 3 3 1 1 1 1 1 1 3 2 2 3 3 2 1 1 1 1 1 1 2 2 2 2 2 2 2 3 1 3 3 1 1 3 2 1 1 2 3 1 1 3 3 3 3 1 1 1 3 3 1 1 3 3 1 3 3 3 3 1 3 3 3 2 2 3 1 3 3 3 2 2 3 3 2 2 3 3 3 1 3 2 1 1 1 1 1 1 2 3 3 2 1 1 1 3 2 1 1 1 1 1 1 1 3 2 2 3 1 2 3 3 3 1 2 2 1 3 3 1 2 2 2 2 2 3 1 1 1 1 3 2 1 3 3 1 2 2 2 ...

result:

ok Correct (3 test cases)

Test #14:

score: 0
Accepted
time: 126ms
memory: 4404kb

input:

4
25729 81
-1 -1 -1 -1 1 -1 -1 -1 -1 -1 -1 -1 -1 1 -1 1 -1 -1 -1 1 -1 -1 1 -1 1 1 1 -1 -1 1 1 -1 1 -1 -1 1 -1 -1 -1 1 -1 1 -1 -1 -1 -1 -1 -1 1 1 -1 -1 1 -1 1 1 1 1 1 1 -1 1 1 1 -1 -1 -1 1 1 1 1 1 1 1 -1 -1 -1 -1 1 -1 -1 -1 -1 1 -1 1 -1 1 1 -1 1 -1 1 1 -1 -1 1 1 1 1 1 1 -1 -1 1 1 -1 1 1 -1 -1 1 -1 1 ...

output:

1 1 1 1 81 81 1 1 1 1 1 1 1 81 81 81 81 1 1 81 81 1 81 81 81 80 79 79 80 80 79 79 79 79 80 80 80 81 1 81 81 81 81 1 1 1 1 1 81 80 80 81 81 81 81 80 79 78 77 76 76 76 75 74 74 75 76 76 75 74 73 72 71 70 70 71 72 73 73 73 74 75 76 76 76 76 76 76 75 75 75 75 75 74 74 75 75 74 73 72 71 70 70 71 71 70 70...

result:

ok Correct (4 test cases)

Test #15:

score: 0
Accepted
time: 314ms
memory: 6024kb

input:

5
7824 2
-1 -1 -1 -1 1 1 1 1 -1 1 1 1 -1 1 -1 -1 1 1 -1 -1 -1 1 -1 1 -1 1 -1 1 1 -1 1 1 1 1 -1 1 1 -1 1 1 1 -1 1 -1 -1 -1 1 -1 -1 -1 1 -1 -1 1 -1 -1 -1 1 -1 -1 -1 -1 -1 -1 -1 1 1 -1 -1 1 1 1 1 -1 1 -1 -1 1 -1 1 -1 1 -1 1 -1 -1 1 1 -1 1 -1 1 -1 1 1 1 1 -1 1 -1 -1 -1 -1 -1 1 1 -1 1 -1 1 -1 1 1 1 -1 -1...

output:

1 1 1 1 2 1 2 1 1 1 2 1 1 1 1 2 2 1 1 2 1 1 1 1 1 1 1 1 2 2 2 1 2 1 1 1 2 2 2 1 2 2 2 2 1 2 2 2 1 2 2 2 1 1 1 2 1 1 1 2 1 2 1 1 1 2 1 1 2 2 1 2 1 1 1 1 2 2 2 2 2 2 2 2 2 1 1 2 2 2 2 2 2 2 1 2 1 1 1 1 2 1 2 1 1 2 2 2 2 2 2 2 1 2 2 1 2 2 2 1 1 2 2 2 2 1 2 1 1 1 2 1 2 2 2 2 1 2 2 1 2 1 2 1 1 2 2 1 2 1 ...

result:

ok Correct (5 test cases)

Test #16:

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

input:

6
7149 4795
-1 -1 1 -1 -1 1 1 -1 1 1 1 1 -1 1 -1 -1 -1 -1 -1 -1 -1 1 -1 -1 1 -1 -1 1 -1 -1 -1 -1 1 1 1 1 -1 1 -1 1 1 1 -1 -1 1 -1 1 1 1 -1 1 1 1 1 -1 1 -1 1 -1 1 -1 1 1 1 1 1 1 1 1 -1 1 -1 -1 -1 -1 -1 -1 -1 -1 -1 1 1 -1 1 1 -1 -1 -1 -1 1 1 1 -1 1 1 -1 1 -1 1 -1 1 1 -1 1 -1 -1 -1 1 1 1 1 1 1 -1 -1 -1...

output:

1 1 4795 4795 1 4795 4794 4794 4794 4793 4792 4791 4791 4791 4791 4792 4793 4794 4795 1 1 4795 4795 1 4795 4795 1 4795 4795 1 1 1 4795 4794 4793 4792 4792 4792 4792 4792 4791 4790 4790 4791 4791 4791 4791 4790 4789 4789 4789 4788 4787 4786 4786 4786 4786 4786 4786 4786 4786 4786 4785 4784 4783 4782 ...

result:

ok Correct (6 test cases)

Test #17:

score: 0
Accepted
time: 111ms
memory: 4664kb

input:

7
16819 1
1 1 1 1 1 1 -1 -1 -1 1 1 1 -1 1 1 1 -1 1 1 -1 -1 -1 1 1 1 1 -1 1 1 -1 1 -1 1 1 -1 -1 1 1 -1 1 -1 1 -1 1 1 -1 -1 1 -1 -1 -1 1 -1 1 -1 -1 -1 -1 -1 -1 -1 1 -1 1 1 -1 -1 1 -1 1 -1 1 1 -1 -1 -1 1 -1 -1 -1 -1 1 -1 1 -1 1 -1 -1 -1 1 1 1 1 1 1 -1 1 -1 1 -1 1 1 1 1 -1 -1 1 1 1 -1 1 -1 -1 1 -1 -1 1 ...

output:

1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

result:

ok Correct (7 test cases)

Test #18:

score: 0
Accepted
time: 231ms
memory: 4932kb

input:

8
29021 106
-1 -1 -1 -1 1 -1 1 -1 1 -1 1 1 1 -1 -1 1 1 1 1 1 -1 -1 1 1 -1 -1 -1 1 1 -1 -1 -1 -1 -1 -1 1 1 -1 1 1 1 -1 -1 -1 1 1 1 1 1 1 1 1 -1 1 -1 1 -1 -1 1 -1 1 -1 1 -1 1 1 -1 1 1 -1 1 -1 -1 -1 1 1 1 1 -1 -1 -1 -1 1 -1 1 -1 -1 1 1 -1 -1 -1 1 -1 1 1 -1 1 1 1 -1 1 -1 1 1 -1 -1 -1 1 -1 -1 -1 1 -1 -1 ...

output:

1 1 1 1 106 106 106 106 106 106 106 105 104 104 105 105 104 103 102 101 101 102 102 101 101 102 103 103 102 102 103 104 105 106 1 106 105 105 105 104 103 103 104 105 105 104 103 102 101 100 99 98 98 98 98 98 98 99 99 99 99 99 99 99 99 98 98 98 97 97 97 97 98 99 99 98 97 96 96 97 98 99 99 99 99 99 10...

result:

ok Correct (8 test cases)

Test #19:

score: 0
Accepted
time: 147ms
memory: 4196kb

input:

9
37136 1
-1 1 -1 -1 -1 -1 1 -1 1 -1 -1 1 1 1 1 1 1 1 -1 1 1 -1 1 1 1 -1 -1 1 1 1 1 -1 1 -1 1 -1 -1 1 -1 1 -1 -1 -1 -1 -1 1 -1 1 -1 1 1 -1 -1 1 -1 -1 1 1 1 1 1 -1 -1 -1 -1 -1 -1 -1 1 1 1 -1 -1 1 1 -1 1 1 1 1 1 1 -1 -1 -1 -1 -1 1 1 1 -1 1 -1 -1 -1 1 -1 -1 1 -1 1 1 1 1 1 -1 -1 1 -1 -1 1 1 1 1 -1 1 -1 ...

output:

1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

result:

ok Correct (9 test cases)

Test #20:

score: 0
Accepted
time: 323ms
memory: 6332kb

input:

10
5543 1596
1 1 1 -1 1 1 1 -1 -1 -1 1 1 -1 -1 -1 1 -1 1 -1 -1 1 -1 -1 -1 -1 -1 -1 -1 1 1 -1 1 -1 -1 -1 1 1 -1 1 -1 -1 -1 1 -1 1 1 -1 -1 1 1 1 1 1 -1 -1 1 1 -1 1 1 -1 1 -1 1 1 -1 -1 -1 1 -1 1 -1 -1 1 -1 -1 -1 1 -1 -1 1 -1 -1 1 -1 1 -1 -1 1 -1 -1 -1 -1 -1 -1 1 1 1 1 -1 -1 -1 -1 1 1 1 1 -1 -1 -1 -1 1 ...

output:

1596 1595 1594 1594 1594 1593 1592 1592 1593 1594 1594 1593 1593 1594 1595 1595 1595 1595 1595 1596 1596 1596 1 1 1 1 1 1 1596 1595 1595 1595 1595 1596 1 1596 1595 1595 1595 1595 1596 1 1596 1596 1596 1595 1595 1596 1596 1595 1594 1593 1592 1592 1593 1593 1592 1592 1592 1591 1591 1591 1591 1591 1590...

result:

ok Correct (10 test cases)

Test #21:

score: 0
Accepted
time: 117ms
memory: 3736kb

input:

100
2336 29
-1 -1 -1 1 -1 1 1 -1 -1 -1 1 -1 -1 1 1 1 1 1 1 -1 -1 1 1 -1 1 -1 -1 -1 1 -1 -1 1 1 1 1 -1 1 1 -1 1 -1 1 1 1 -1 -1 -1 -1 -1 1 1 -1 1 1 -1 -1 1 1 -1 -1 1 1 -1 -1 1 -1 -1 -1 1 -1 -1 -1 1 1 1 1 1 -1 -1 1 -1 -1 -1 -1 -1 -1 1 -1 1 1 1 1 1 -1 1 1 1 -1 1 1 1 -1 1 -1 1 -1 1 1 1 1 1 -1 1 -1 -1 -1 ...

output:

1 1 1 29 29 29 28 28 29 1 29 29 1 29 28 27 26 25 24 24 25 25 24 24 24 24 25 26 26 26 27 27 26 25 24 24 24 23 23 23 23 23 22 21 21 22 23 24 25 25 24 24 24 23 23 24 24 23 23 24 24 23 23 24 24 24 25 26 26 26 27 28 28 27 26 25 24 24 25 25 25 26 27 28 29 1 29 29 29 28 27 26 25 25 25 24 23 23 23 22 21 21 ...

result:

ok Correct (100 test cases)

Test #22:

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

input:

101
92 1
1 1 -1 1 1 -1 -1 -1 -1 -1 1 -1 -1 1 -1 1 1 -1 1 -1 1 1 1 1 -1 -1 -1 1 -1 -1 -1 -1 -1 1 -1 -1 -1 -1 -1 -1 1 -1 -1 -1 -1 -1 1 1 -1 1 -1 -1 1 -1 -1 1 -1 -1 -1 -1 -1 1 -1 1 -1 -1 -1 -1 1 1 -1 1 1 -1 1 1 1 1 -1 -1 1 1 1 1 1 1 1 1 1 1 -1 -1
2647 2314
-1 1 -1 -1 1 1 1 -1 1 1 1 1 -1 1 -1 -1 1 -1 -1...

output:

1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 
1 2314 2314 1 2314 2313 2312 2312 2312 2311 2310 2309 2309 2309 2309 2310 2310 2310 2311 2312 2312 2312 2313 2314 2...

result:

ok Correct (101 test cases)

Test #23:

score: 0
Accepted
time: 138ms
memory: 3696kb

input:

102
8381 7064
-1 -1 1 1 -1 -1 1 -1 1 1 1 1 1 -1 -1 1 -1 1 -1 1 1 1 -1 -1 -1 1 -1 1 1 1 1 -1 -1 -1 -1 1 1 1 -1 -1 1 1 -1 1 -1 1 -1 -1 1 -1 -1 1 -1 1 1 -1 -1 1 1 1 -1 -1 -1 1 1 1 1 1 1 -1 -1 1 -1 1 -1 -1 -1 -1 1 1 -1 1 1 -1 -1 1 -1 -1 1 -1 -1 -1 1 -1 -1 1 -1 1 1 -1 -1 1 1 1 1 -1 -1 1 1 1 -1 1 -1 -1 -1...

output:

1 1 7064 7063 7063 7064 7064 7064 7064 7063 7062 7061 7060 7060 7061 7061 7061 7061 7061 7061 7060 7059 7059 7060 7061 7061 7061 7061 7060 7059 7058 7058 7059 7060 7061 7061 7060 7059 7059 7060 7060 7059 7059 7059 7059 7059 7059 7060 7060 7060 7061 7061 7061 7061 7060 7060 7061 7061 7060 7059 7059 7...

result:

ok Correct (102 test cases)

Test #24:

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

input:

103
1976 404
1 -1 -1 1 -1 -1 -1 -1 1 1 1 -1 1 1 -1 -1 1 -1 1 -1 1 -1 -1 1 1 1 1 -1 -1 1 1 1 -1 1 -1 -1 1 -1 1 -1 1 -1 1 1 1 1 1 1 -1 -1 1 -1 -1 1 1 1 1 1 1 -1 -1 1 1 1 1 -1 -1 -1 1 -1 1 -1 1 1 1 1 -1 1 -1 -1 -1 -1 1 -1 -1 1 -1 -1 -1 1 -1 -1 -1 1 -1 1 1 -1 1 1 -1 1 -1 1 -1 -1 -1 -1 -1 -1 1 1 1 1 -1 -...

output:

404 404 1 404 404 1 1 1 404 403 402 402 402 401 401 402 402 402 402 402 402 402 403 403 402 401 400 400 401 401 400 399 399 399 399 400 400 400 400 400 400 400 400 399 398 397 396 395 395 396 396 396 397 397 396 395 394 393 392 392 393 393 392 391 390 390 391 392 392 392 392 392 392 391 390 389 389 ...

result:

ok Correct (103 test cases)

Test #25:

score: 0
Accepted
time: 132ms
memory: 3736kb

input:

104
3135 3
1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 1 1 -1 -1 1 1 1 -1 -1 -1 -1 1 1 -1 1 -1 -1 -1 -1 -1 -1 1 1 -1 -1 -1 1 1 -1 -1 1 1 -1 -1 -1 1 -1 1 1 -1 -1 -1 -1 1 -1 -1 -1 1 -1 1 -1 1 -1 1 -1 -1 1 1 -1 -1 1 -1 -1 -1 -1 1 -1 1 1 1 1 1 1 -1 1 -1 -1 1 1 1 1 1 1 1 1 -1 -1 1 1 1 1 1 1 -1 1 1 1 1 -1 1 -1 1 1 -1...

output:

3 3 1 1 1 1 1 1 1 1 1 3 2 2 3 3 2 1 1 2 3 1 3 2 2 2 2 3 1 1 1 1 3 2 2 3 1 3 2 2 3 3 2 2 3 1 3 3 3 2 2 3 1 1 3 3 1 1 3 3 3 3 3 3 3 3 1 3 2 2 3 3 3 1 1 1 3 3 3 2 1 3 2 1 1 1 1 2 2 1 3 2 1 3 2 1 1 2 2 1 3 2 1 3 3 3 2 1 3 3 3 3 3 2 2 3 1 1 3 2 1 1 1 3 2 2 3 3 3 3 2 1 3 3 3 2 2 3 1 2 2 1 1 1 3 2 1 1 1 3 ...

result:

ok Correct (104 test cases)

Test #26:

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

input:

105
1344 10
1 1 1 -1 1 -1 1 -1 -1 -1 -1 -1 1 1 1 1 1 -1 1 1 1 -1 1 -1 1 1 1 1 1 -1 -1 -1 1 1 -1 -1 -1 1 -1 -1 1 -1 -1 -1 1 -1 1 1 -1 1 -1 1 1 -1 1 -1 -1 -1 -1 -1 -1 -1 -1 1 -1 1 -1 -1 -1 1 -1 -1 1 -1 1 1 1 -1 1 -1 1 1 1 1 -1 1 1 1 -1 1 -1 -1 -1 1 -1 1 1 -1 1 -1 1 1 1 -1 1 -1 1 -1 -1 1 1 -1 -1 1 1 -1...

output:

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

result:

ok Correct (105 test cases)

Test #27:

score: 0
Accepted
time: 86ms
memory: 3652kb

input:

1000
1284 8
1 1 1 1 -1 1 -1 -1 -1 -1 1 1 -1 -1 1 1 1 1 -1 1 -1 1 1 -1 1 1 1 1 -1 -1 1 -1 1 -1 1 1 1 -1 1 -1 -1 1 -1 -1 -1 1 1 1 -1 -1 1 1 -1 -1 -1 -1 1 1 1 -1 1 1 -1 -1 1 -1 -1 1 1 1 1 -1 1 -1 1 1 1 -1 1 1 1 -1 1 1 -1 1 -1 1 -1 -1 -1 1 1 -1 1 1 1 1 1 -1 -1 -1 1 -1 -1 -1 1 -1 1 -1 -1 -1 -1 1 1 1 1 -1...

output:

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

result:

ok Correct (1000 test cases)

Test #28:

score: 0
Accepted
time: 84ms
memory: 3536kb

input:

1001
151 3
1 1 -1 1 -1 1 -1 1 1 -1 1 1 1 1 1 1 1 -1 1 1 -1 -1 1 1 -1 1 -1 1 -1 1 1 -1 1 1 -1 -1 1 -1 -1 1 1 -1 -1 1 -1 -1 1 1 -1 -1 -1 -1 -1 1 1 1 1 -1 -1 1 1 -1 -1 -1 1 -1 -1 -1 -1 -1 1 1 -1 1 -1 -1 -1 -1 1 1 -1 -1 -1 -1 -1 1 1 1 -1 1 -1 1 -1 -1 -1 -1 -1 -1 1 -1 -1 -1 -1 1 -1 1 1 -1 1 1 -1 -1 -1 -1...

output:

3 2 2 2 2 2 2 2 1 1 1 3 2 1 3 2 1 1 1 3 3 1 1 3 3 3 3 3 3 3 2 2 2 1 1 2 2 2 3 3 2 2 3 3 3 1 1 3 3 1 2 3 1 1 3 2 1 1 2 2 1 1 2 3 3 3 1 2 3 1 1 3 3 3 3 1 2 3 3 2 2 3 1 1 1 3 2 1 1 1 1 1 1 2 3 1 1 1 3 3 1 1 1 3 3 3 2 2 2 1 1 2 3 1 1 3 3 3 2 2 2 2 3 3 3 3 3 1 1 1 3 3 1 3 3 3 3 1 3 2 2 3 1 3 3 3 3 3 3 3 ...

result:

ok Correct (1001 test cases)

Test #29:

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

input:

1002
182 6
1 1 1 1 -1 -1 1 -1 -1 1 1 -1 1 1 -1 1 1 1 1 1 -1 -1 -1 -1 1 -1 1 1 1 -1 -1 1 1 1 1 -1 1 1 -1 -1 -1 -1 -1 1 -1 -1 1 1 -1 -1 -1 1 -1 1 -1 -1 -1 1 1 1 -1 1 1 1 1 -1 -1 -1 -1 -1 1 -1 1 -1 1 1 -1 -1 1 1 1 1 -1 1 1 -1 -1 -1 -1 1 1 1 1 1 1 1 -1 1 -1 -1 -1 1 -1 -1 -1 -1 1 1 -1 -1 -1 -1 1 -1 1 1 1...

output:

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

result:

ok Correct (1002 test cases)

Test #30:

score: 0
Accepted
time: 86ms
memory: 3556kb

input:

1003
95 16
1 -1 -1 1 1 1 -1 -1 -1 -1 -1 1 1 1 -1 -1 -1 -1 1 1 1 -1 1 -1 1 1 -1 -1 -1 -1 1 -1 1 -1 -1 -1 1 -1 -1 1 -1 1 -1 -1 1 -1 -1 1 -1 -1 -1 1 1 1 -1 1 1 1 -1 -1 -1 -1 1 1 -1 1 1 1 1 1 -1 -1 1 1 -1 -1 -1 1 -1 -1 -1 -1 -1 1 -1 -1 -1 1 1 1 1 -1 -1 1 1
526 3
1 -1 -1 1 1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1...

output:

16 16 1 16 15 14 14 15 16 1 1 16 15 14 14 15 16 1 16 15 14 14 14 14 14 13 13 14 15 16 16 16 16 16 1 1 16 16 1 16 16 16 16 1 16 16 1 16 16 1 1 16 15 14 14 14 13 12 12 13 14 15 15 14 14 14 13 12 11 10 10 11 11 10 10 11 12 12 12 13 14 15 16 16 16 1 1 16 15 14 13 13 14 14 13 
3 3 1 3 2 2 3 1 1 1 1 1 1 1...

result:

ok Correct (1003 test cases)

Test #31:

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

input:

1004
322 257
-1 1 1 1 1 1 1 -1 -1 1 1 -1 -1 -1 1 -1 -1 1 -1 1 -1 -1 -1 1 1 1 1 1 1 -1 1 1 -1 1 -1 1 -1 1 1 -1 1 -1 1 1 1 -1 1 1 -1 -1 1 -1 1 1 -1 -1 -1 1 -1 1 -1 1 -1 1 1 1 -1 1 1 1 -1 -1 1 1 -1 -1 -1 1 1 1 1 1 1 1 -1 -1 1 1 1 1 1 1 1 1 -1 -1 -1 1 -1 1 -1 1 1 -1 -1 -1 1 -1 1 1 1 1 -1 -1 1 -1 -1 1 -1...

output:

1 257 256 255 254 253 252 252 253 253 252 252 253 254 254 254 255 255 255 255 255 256 257 257 256 255 254 253 252 252 252 251 251 251 251 251 251 251 250 250 250 250 250 249 248 248 248 247 247 248 248 248 248 247 247 248 249 249 249 249 249 249 249 249 248 247 247 247 246 245 245 246 246 245 245 24...

result:

ok Correct (1004 test cases)

Test #32:

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

input:

1005
508 4
1 -1 -1 -1 1 1 1 1 1 1 1 -1 1 1 1 -1 1 -1 1 -1 1 1 -1 1 -1 -1 1 -1 -1 1 -1 -1 1 1 -1 1 1 -1 1 -1 -1 -1 -1 1 -1 -1 1 1 1 1 -1 1 -1 1 -1 1 1 1 -1 -1 -1 -1 1 1 -1 1 -1 1 -1 1 -1 1 -1 1 1 1 -1 -1 1 -1 -1 -1 -1 1 1 -1 -1 -1 -1 1 -1 1 -1 1 1 -1 -1 1 -1 -1 1 1 -1 -1 1 -1 -1 -1 1 1 1 -1 -1 1 1 1 ...

output:

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

result:

ok Correct (1005 test cases)

Test #33:

score: 0
Accepted
time: 56ms
memory: 3492kb

input:

9995
9 7
-1 1 -1 -1 -1 1 -1 -1 1
1 1
-1
7 1
-1 -1 -1 -1 1 -1 -1
25 1
1 1 1 1 1 1 1 -1 -1 -1 -1 1 -1 -1 1 1 1 -1 1 -1 1 1 -1 -1 -1
24 22
1 -1 1 -1 1 -1 1 1 1 -1 1 1 1 1 -1 1 1 -1 1 -1 -1 1 -1 -1
6 3
1 -1 1 1 -1 -1
6 4
-1 1 -1 -1 -1 1
14 9
-1 -1 1 -1 1 -1 1 1 1 1 1 1 1 -1
24 3
1 -1 -1 -1 1 1 -1 1 1 1 ...

output:

1 7 7 1 1 7 7 1 7 
1 
1 1 1 1 1 1 1 
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 
22 22 22 22 22 22 22 21 20 20 20 19 18 17 17 17 16 16 16 16 17 17 17 18 
3 3 3 2 2 3 
1 4 4 1 1 4 
1 1 9 9 9 9 9 8 7 6 5 4 3 3 
3 3 1 1 3 2 2 2 1 3 2 1 1 1 3 2 2 3 1 2 3 3 3 3 
1 1 1 8 8 1 8 8 8 8 8 7 7 7 6 6 6 6...

result:

ok Correct (9995 test cases)

Test #34:

score: 0
Accepted
time: 51ms
memory: 3608kb

input:

9996
27 1
1 1 -1 -1 -1 -1 -1 -1 -1 1 1 1 -1 -1 -1 -1 1 -1 1 -1 -1 -1 1 1 -1 1 1
7 2
1 1 1 1 -1 -1 1
22 3
-1 -1 1 1 -1 -1 -1 1 1 1 -1 -1 -1 -1 -1 1 -1 1 1 -1 -1 1
37 4
-1 -1 -1 1 -1 1 -1 -1 -1 1 1 -1 1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 1 1 1 1 1 -1 1 1 1
7 1
-1 1 -1 -1 1 1 1
29 1
-1 -1 1 -1 1 -1 1...

output:

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

result:

ok Correct (9996 test cases)

Test #35:

score: 0
Accepted
time: 56ms
memory: 3796kb

input:

9997
15 9
-1 1 1 -1 1 1 -1 1 -1 1 1 1 1 1 1
1 1
1
37 20
-1 1 -1 -1 1 -1 -1 1 -1 -1 -1 1 -1 1 1 -1 1 1 -1 -1 -1 -1 1 1 -1 1 -1 -1 -1 1 -1 1 1 1 1 1 -1
64 2
-1 -1 -1 -1 -1 1 1 1 1 1 1 1 1 -1 -1 -1 -1 -1 -1 1 1 -1 -1 -1 -1 -1 1 -1 1 -1 1 1 1 1 -1 1 -1 -1 -1 1 1 -1 -1 1 1 -1 -1 1 -1 -1 -1 -1 1 1 -1 -1 -...

output:

1 9 8 8 8 7 7 7 7 7 6 5 4 3 2 
1 
1 20 20 1 20 20 1 20 20 1 1 20 20 20 19 19 19 18 18 19 20 1 20 19 19 19 19 20 1 20 20 20 19 18 17 16 16 
1 1 1 1 1 2 1 2 1 2 1 2 1 1 2 1 2 1 2 2 1 1 2 1 2 1 2 2 2 2 2 1 2 1 1 1 1 2 1 1 2 2 1 1 2 2 1 1 1 2 1 1 2 1 1 2 1 2 2 2 2 2 2 1 
2 1 2 1 1 1 2 1 2 1 1 1 2 2 1 2 ...

result:

ok Correct (9997 test cases)

Test #36:

score: 0
Accepted
time: 55ms
memory: 3604kb

input:

9998
28 3
-1 1 1 -1 -1 -1 -1 -1 1 1 1 -1 -1 1 -1 1 -1 -1 -1 -1 -1 -1 -1 1 1 1 1 1
12 2
-1 -1 -1 1 -1 -1 1 -1 1 1 -1 1
8 6
-1 1 1 -1 1 1 1 1
3 1
1 1 -1
12 1
1 -1 1 1 1 -1 1 -1 -1 1 1 -1
3 1
1 -1 -1
77 3
-1 -1 1 1 1 -1 1 -1 1 1 1 1 1 1 1 -1 -1 -1 1 -1 -1 1 -1 -1 1 1 -1 1 -1 1 1 -1 -1 -1 -1 -1 1 -1 1 -...

output:

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

result:

ok Correct (9998 test cases)

Test #37:

score: 0
Accepted
time: 51ms
memory: 3492kb

input:

9999
65 2
-1 -1 1 1 -1 -1 -1 1 -1 -1 -1 1 1 -1 -1 -1 -1 1 -1 1 1 -1 -1 1 -1 1 1 1 -1 -1 1 1 1 1 -1 1 -1 1 -1 1 -1 -1 -1 1 1 -1 -1 -1 -1 1 1 1 1 -1 -1 1 -1 1 1 1 1 1 1 1 1
12 3
1 1 1 1 -1 -1 -1 -1 1 1 -1 -1
75 2
1 -1 1 -1 -1 -1 1 1 -1 1 -1 1 -1 -1 -1 1 1 1 -1 1 -1 1 1 -1 1 -1 -1 1 -1 -1 -1 1 1 -1 1 1...

output:

1 1 2 1 1 2 1 2 2 1 1 2 1 1 2 1 1 2 2 2 1 1 2 2 2 2 1 2 2 1 1 2 1 2 2 2 2 2 2 2 2 1 2 2 1 1 2 1 2 2 1 2 1 1 2 2 2 2 1 2 1 2 1 2 1 
3 2 1 3 3 1 2 3 3 2 2 3 
2 2 2 2 1 1 2 1 1 1 1 1 1 2 1 2 1 2 2 2 2 2 1 1 1 1 2 2 2 1 2 2 1 1 1 2 2 2 2 1 1 1 1 1 1 2 1 1 2 1 2 1 1 2 2 2 2 1 1 2 1 2 1 1 2 2 1 2 1 1 1 1 ...

result:

ok Correct (9999 test cases)

Test #38:

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

input:

10000
15 3
-1 1 -1 1 -1 -1 1 -1 1 -1 1 -1 -1 -1 1
3 3
-1 1 1
34 2
-1 -1 -1 -1 1 -1 1 -1 -1 -1 -1 1 -1 -1 -1 1 -1 -1 1 -1 1 -1 -1 1 -1 1 1 -1 -1 -1 1 -1 1 1
3 2
1 1 -1
25 2
-1 -1 1 1 1 -1 1 -1 1 -1 -1 -1 1 1 1 -1 1 1 1 1 -1 1 -1 1 -1
11 1
1 -1 -1 -1 -1 -1 1 -1 -1 -1 1
29 2
-1 -1 -1 1 -1 1 -1 -1 -1 -1...

output:

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

result:

ok Correct (10000 test cases)

Extra Test:

score: 0
Extra Test Passed