QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#285362#7942. $K$ Subsequencesucup-team1303#AC ✓75ms16380kbC++141.6kb2023-12-16 18:07:072023-12-16 18:07:08

Judging History

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

  • [2023-12-16 18:07:08]
  • 评测
  • 测评结果:AC
  • 用时:75ms
  • 内存:16380kb
  • [2023-12-16 18:07:07]
  • 提交

answer

#include<bits/stdc++.h>

#define ll long long
#define mk make_pair
#define fi first
#define se second

using namespace std;

inline int read(){
	int x=0,f=1;char c=getchar();
	for(;(c<'0'||c>'9');c=getchar()){if(c=='-')f=-1;}
	for(;(c>='0'&&c<='9');c=getchar())x=x*10+(c&15);
	return x*f;
}

const int mod=998244353;
int ksm(int x,int y,int p=mod){
	int ans=1;
	for(int i=y;i;i>>=1,x=1ll*x*x%p)if(i&1)ans=1ll*ans*x%p;
	return ans%p;
}
int inv(int x,int p=mod){return ksm(x,p-2,p)%p;}
mt19937 rnd(time(0));
int randint(int l,int r){return rnd()%(r-l+1)+l;}
void add(int &x,int v){x+=v;if(x>=mod)x-=mod;}
void Mod(int &x){if(x>=mod)x-=mod;}
int cmod(int x){if(x>=mod)x-=mod;return x;}

void cmax(int &x,int v){x=max(x,v);}
void cmin(int &x,int v){x=min(x,v);}

struct Node{
	int x,y,id; // suffix , all , id
	Node(int X=0,int Y=0,int I=0):x(X),y(Y),id(I){}
	bool operator<(const Node &rhs)const{
		if(x!=rhs.x)return x<rhs.x;
		if(y!=rhs.y)return y<rhs.y;
		return id<rhs.id;
	}
};

void solve(){
	set<Node>S;
	int n=read(),k=read();
	vector<int>a(n+1);
	for(int i=1;i<=n;i++)a[i]=read();
	for(int i=1;i<=k;i++)S.insert(Node(0,0,i));
	for(int i=1;i<=n;i++){
		if(a[i]==1){
			auto [x,y,id]=*S.begin();
			S.erase(S.begin());
			cout<<id<<" ";
			x=max(0,x+a[i]);y=max(y,x);
			S.insert(Node(x,y,id));
		}
		else{
			auto [x,y,id]=*--S.end();
			S.erase(--S.end());
			cout<<id<<" ";
			x=max(0,x+a[i]);y=max(y,x);
			S.insert(Node(x,y,id));
		}
	}
	puts("");
}

signed main(void){

#ifndef ONLINE_JUDGE
	freopen("in.in","r",stdin);
#endif

	int tt=read();while(tt--)solve();

	return 0;
}

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

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3600kb

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:

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

result:

ok Correct (5 test cases)

Test #2:

score: 0
Accepted
time: 18ms
memory: 3672kb

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

result:

ok Correct (18434 test cases)

Test #3:

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

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:

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

result:

ok Correct (1 test case)

Test #4:

score: 0
Accepted
time: 23ms
memory: 3956kb

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:

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

result:

ok Correct (1 test case)

Test #5:

score: 0
Accepted
time: 23ms
memory: 4044kb

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:

136 1 2 3 4 5 5 6 6 4 7 7 8 9 9 8 10 11 12 13 14 14 15 15 13 16 16 17 18 18 17 19 19 12 20 20 21 22 23 24 25 26 26 25 24 23 27 27 22 21 11 10 3 2 1 28 29 30 30 31 32 33 33 34 35 36 37 38 38 37 39 39 40 40 36 41 42 43 44 44 45 45 43 42 41 46 47 47 46 35 34 48 48 49 50 51 52 53 53 52 54 55 56 57 58 59...

result:

ok Correct (1 test case)

Test #6:

score: 0
Accepted
time: 48ms
memory: 9584kb

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:

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

result:

ok Correct (1 test case)

Test #7:

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

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:

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

result:

ok Correct (1 test case)

Test #8:

score: 0
Accepted
time: 60ms
memory: 11668kb

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:

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

result:

ok Correct (2 test cases)

Test #9:

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

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:

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

result:

ok Correct (2 test cases)

Test #10:

score: 0
Accepted
time: 31ms
memory: 5752kb

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:

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

result:

ok Correct (2 test cases)

Test #11:

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

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: 17ms
memory: 3876kb

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: 23ms
memory: 3976kb

input:

3
509 3
-1 -1 1 1 -1 -1 1 1 -1 -1 -1 1 -1 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 17 18 19 20 21 22 23 23 24 25 26 26 25 24 27 28 29 30 31 32 33 33 32 31 30 34 34 29 28 27 35 35 36 36 37 38 38 39 39 40 41 41 40 42 43 44 45 46 47 47 46 48 49 49 50 51 5...

result:

ok Correct (4 test cases)

Test #15:

score: 0
Accepted
time: 38ms
memory: 6552kb

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:

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

result:

ok Correct (5 test cases)

Test #16:

score: 0
Accepted
time: 23ms
memory: 4112kb

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:

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

result:

ok Correct (6 test cases)

Test #17:

score: 0
Accepted
time: 18ms
memory: 3972kb

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: 27ms
memory: 5060kb

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:

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

result:

ok Correct (8 test cases)

Test #19:

score: 0
Accepted
time: 23ms
memory: 4464kb

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: 39ms
memory: 6796kb

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:

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

result:

ok Correct (10 test cases)

Test #21:

score: 0
Accepted
time: 23ms
memory: 3896kb

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:

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

result:

ok Correct (100 test cases)

Test #22:

score: 0
Accepted
time: 26ms
memory: 3936kb

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

result:

ok Correct (101 test cases)

Test #23:

score: 0
Accepted
time: 26ms
memory: 4144kb

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:

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

result:

ok Correct (102 test cases)

Test #24:

score: 0
Accepted
time: 24ms
memory: 3920kb

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:

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

result:

ok Correct (103 test cases)

Test #25:

score: 0
Accepted
time: 25ms
memory: 3840kb

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:

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

result:

ok Correct (104 test cases)

Test #26:

score: 0
Accepted
time: 27ms
memory: 3864kb

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:

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

result:

ok Correct (105 test cases)

Test #27:

score: 0
Accepted
time: 25ms
memory: 3712kb

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:

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

result:

ok Correct (1000 test cases)

Test #28:

score: 0
Accepted
time: 22ms
memory: 4012kb

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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5 6 1 1 6 5 4 3 3 3 3 3 3 4 4 3 3 4 5 6 6 6 1 1 6 5 4 4 5 6 1 2 3 4 4 4 4 3 2 2 2 1 6 5 5 6 6 5 4 3 3 3 3 4 5 6 6 6 1 2 2 2 2 1 6 5 5 5 4 3 3 3 2 2 2 1 6 1 1 6 1 1 1 2 3 4 4 3 ...

result:

ok Correct (1002 test cases)

Test #30:

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

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:

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

result:

ok Correct (1003 test cases)

Test #31:

score: 0
Accepted
time: 26ms
memory: 3704kb

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:

257 1 2 3 4 5 6 6 5 7 8 8 7 4 9 9 3 10 10 11 11 2 1 12 13 14 15 16 17 17 18 19 19 20 20 21 21 22 23 23 24 24 25 26 27 27 28 29 29 28 30 30 31 32 32 31 26 33 33 34 34 35 35 36 37 38 38 39 40 41 41 40 42 43 43 42 39 44 45 46 47 48 49 50 50 49 51 52 53 54 55 56 57 58 58 57 56 59 59 60 60 61 62 62 61 55...

result:

ok Correct (1004 test cases)

Test #32:

score: 0
Accepted
time: 25ms
memory: 3828kb

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:

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

result:

ok Correct (1005 test cases)

Test #33:

score: 0
Accepted
time: 24ms
memory: 3920kb

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:

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

result:

ok Correct (9995 test cases)

Test #34:

score: 0
Accepted
time: 24ms
memory: 3688kb

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

result:

ok Correct (9996 test cases)

Test #35:

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

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:

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

result:

ok Correct (9997 test cases)

Test #36:

score: 0
Accepted
time: 24ms
memory: 3712kb

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 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2 3 3 2 
1 1 2 2 2 2 1 2 2 2 2 2 2 1 2 1 2 1 1 2 2 1 2 2 2 2 1 1 1 2 1 1 2 2 2 1 1 1 1 2 2 2 2 2 2 1 2 2 1 2 1 2 2 1 1 1 1 2 2 1 2 1 2 2 1 1 2 1 2 2 2 2 ...

result:

ok Correct (9999 test cases)

Test #38:

score: 0
Accepted
time: 24ms
memory: 3772kb

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:

3 1 1 2 2 2 3 3 1 1 1 1 3 3 1 
3 1 2 
2 2 2 2 1 1 2 2 2 2 2 1 1 2 2 1 1 2 1 1 1 1 2 1 1 1 2 2 1 2 1 1 1 2 
1 2 2 
2 2 1 2 1 1 2 2 1 1 2 1 1 2 1 1 1 2 1 2 2 2 2 2 2 
1 1 1 1 1 1 1 1 1 1 1 
2 2 2 1 1 2 2 2 2 2 2 2 1 2 1 2 2 1 2 2 2 2 2 1 1 2 2 2 1 
1 1 1 2 
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