QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#100551#5420. Inscryptionlgvc#AC ✓118ms13324kbC++231.9kb2023-04-26 18:21:392023-04-26 18:21:40

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-04-26 18:21:40]
  • 评测
  • 测评结果:AC
  • 用时:118ms
  • 内存:13324kb
  • [2023-04-26 18:21:39]
  • 提交

answer

//这回只花了114514min就打完了。
//真好。记得多手造几组。
#include <bits/stdc++.h>
//#define int long long
#define pai 3.141592653589793238462643383279502884197169399375105820
#define MOD 1000000007
#define eps 0.00000001
inline int min(int a,int b) {return a<b?a:b;}
inline int max(int a,int b) {return a>b?a:b;}
#define ULL unsigned long long
#define LL long long
#define INF 0x3f3f3f3f
#define INF_LL 0x3f3f3f3f3f3f3f3f
static char buf[1000000],*paa=buf,*pd=buf;
static char buf2[1000000],*pp=buf2;
#define getchar() paa==pd&&(pd=(paa=buf)+fread(buf,1,1000000,stdin),paa==pd)?EOF:*paa++
inline void pc(char ch){
	if(pp-buf2==1000000) fwrite(buf2,1,1000000,stdout),pp=buf2;
	*pp++=ch;
}
inline void pcc(){
	fwrite(buf2,1,pp-buf2,stdout);
	pp=buf2;
}
inline int read(void) {
	int w=1;
	register int x(0);register char c(getchar());
	while(c<'0'||c>'9') {if(c=='-') w=-1;c=getchar();}
	while(c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^48),c=getchar();
	return w*x;
}
void write(int x) {
	if(x<0) pc('-'),x=-x;
	static int sta[20];
	int top=0;
	do {
		sta[top++]=x%10,x/=10;
	} while(x);
	while(top) pc(sta[--top]+48);
}
void we(int x) {
	write(x);
	pc('\n');
}
inline bool cmp_xi(int a,int b) {return a<b;}
inline bool cmp_da(int a,int b) {return a>b;}
int T,N,a[1000009],su[1000009];
signed main(void) {
    //freopen("m.in","r",stdin);
    //freopen("m.out","w",stdout);
	T=read();
	while(T--) {
		N=read();
		int b=1,sq=1;
		bool ff=0;
		for(int i=1;i<=N;i++) {
			a[i]=read();
			if(a[i]==-1) b--;else b++,sq++;
			if(b==0) {
				ff=1;
			}
			su[i]=b;
		}
		if(ff) {
			printf("-1\n");
			continue;
		}
		int a1=sq,a2=b,mm=INF;
		for(int i=N;i>=1;i--) {
			mm=std::min(mm,su[i]);
			if(a[i]==0) {
				if(mm<=2) break;
				b-=2;
				mm-=2;
				sq--;
				if(1ll*a1*b<1ll*sq*a2) a1=sq,a2=b;
			}
		}
		int v=std::__gcd(a1,a2);
		a1/=v;
		a2/=v;
		printf("%d %d\n",a1,a2);
	}
    return 0;
}


Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 7544kb

input:

6
7
1 1 1 -1 1 1 -1
4
1 0 -1 0
4
0 -1 -1 0
1
0
2
0 0
1
-1

output:

3 2
3 1
-1
1 1
2 1
-1

result:

ok 6 lines

Test #2:

score: 0
Accepted
time: 118ms
memory: 8500kb

input:

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

result:

ok 1000000 lines

Test #3:

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

input:

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

output:

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

result:

ok 181249 lines

Test #4:

score: 0
Accepted
time: 10ms
memory: 8488kb

input:

19793
93
1 -1 1 1 -1 -1 1 0 0 0 0 1 1 -1 -1 -1 0 -1 -1 1 -1 0 0 0 0 1 0 -1 -1 1 -1 1 -1 1 -1 1 1 -1 1 0 1 0 -1 -1 0 1 1 0 -1 -1 0 1 1 0 -1 1 -1 -1 -1 0 0 0 1 -1 0 1 -1 0 0 0 1 0 -1 1 -1 -1 1 -1 0 1 -1 0 -1 -1 1 0 0 0 0 0 0 -1 -1
36
0 1 1 -1 1 -1 0 1 1 1 0 -1 1 1 -1 0 1 1 1 1 0 1 -1 -1 1 -1 1 0 -1 0 ...

output:

24 1
19 1
12 1
47 4
12 1
22 1
23 3
14 1
11 2
46 1
-1
-1
-1
26 3
-1
-1
13 1
2 1
-1
33 4
41 2
-1
43 2
-1
-1
-1
-1
25 1
7 1
-1
-1
-1
-1
-1
11 2
2 1
-1
27 4
-1
31 1
14 1
20 1
-1
5 3
38 1
24 1
-1
2 1
23 2
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
18 1
50 1
37 1
19 2
-1
21 1
-1
-1
14 1
15 2
30 1
-1
13 3
-1
-...

result:

ok 19793 lines

Test #5:

score: 0
Accepted
time: 9ms
memory: 7972kb

input:

1987
350
-1 1 0 0 0 -1 0 1 -1 1 0 0 -1 1 1 -1 1 1 -1 -1 -1 -1 0 1 1 0 1 0 0 0 -1 0 1 -1 1 0 1 -1 -1 1 0 1 1 1 -1 0 0 0 1 0 1 0 0 1 -1 1 0 1 0 1 -1 1 0 1 -1 -1 0 -1 1 0 -1 1 1 1 -1 -1 -1 0 0 0 0 -1 -1 -1 -1 -1 0 1 1 -1 -1 1 0 1 -1 0 0 -1 -1 1 0 0 -1 0 -1 1 1 0 -1 1 -1 0 -1 1 -1 1 1 -1 0 0 1 -1 1 0 1 ...

output:

-1
-1
182 3
57 2
205 2
262 3
428 3
25 1
333 2
-1
469 1
440 3
176 3
-1
-1
-1
175 2
-1
44 1
-1
-1
-1
-1
-1
-1
135 1
-1
-1
-1
-1
-1
-1
-1
470 3
158 5
215 1
-1
-1
-1
-1
55 1
-1
-1
-1
241 1
175 11
-1
393 1
224 5
45 1
165 1
209 1
-1
488 1
15 1
-1
-1
-1
-1
-1
312 5
-1
-1
-1
-1
78 1
211 2
-1
-1
172 1
458 1
...

result:

ok 1987 lines

Test #6:

score: 0
Accepted
time: 7ms
memory: 8748kb

input:

188
5255
1 0 -1 -1 1 0 0 0 -1 0 -1 1 0 -1 1 0 -1 0 -1 0 0 0 0 -1 -1 0 0 1 -1 1 0 -1 0 -1 -1 1 0 1 -1 1 -1 1 0 1 1 1 -1 1 1 1 -1 0 -1 -1 0 0 1 1 0 0 -1 -1 0 1 0 0 1 0 -1 -1 1 -1 -1 1 0 -1 1 0 0 -1 1 -1 -1 -1 1 1 -1 0 1 1 -1 -1 1 0 -1 -1 -1 0 1 1 1 -1 0 1 -1 1 -1 0 1 0 -1 1 0 0 1 0 0 -1 1 1 -1 1 1 -1 ...

output:

2629 2
-1
-1
2154 1
1205 2
2907 1
-1
3373 2
4531 4
-1
3399 2
-1
-1
-1
-1
470 3
-1
1737 1
-1
-1
1475 2
4915 3
705 7
-1
2269 2
4587 2
-1
2021 1
-1
2990 7
-1
-1
-1
-1
848 1
1533 1
-1
-1
595 1
-1
-1
-1
1553 4
-1
225 4
-1
-1
-1
1697 3
494 1
-1
2433 1
-1
-1
-1
-1
-1
-1
931 3
-1
3211 1
1119 1
1382 1
1591 1...

result:

ok 188 lines

Test #7:

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

input:

19
48437
-1 1 1 -1 0 0 -1 1 -1 1 -1 -1 -1 -1 -1 0 1 0 1 -1 -1 1 -1 -1 1 1 1 0 1 -1 0 0 -1 -1 0 0 1 0 0 1 1 1 1 0 -1 0 -1 1 1 -1 -1 0 1 1 0 0 0 1 0 -1 0 -1 1 0 0 0 -1 1 1 -1 0 0 0 0 -1 0 -1 0 -1 0 1 0 -1 1 0 1 -1 1 0 1 1 0 0 1 -1 -1 0 1 -1 0 1 1 -1 1 -1 0 -1 -1 1 0 -1 1 0 1 0 0 1 1 0 1 1 -1 0 -1 0 1 ...

output:

-1
-1
-1
3841 5
11848 1
24812 1
-1
46995 2
13406 1
-1
18922 5
-1
-1
-1
10079 4
-1
-1
2267 3
48220 1

result:

ok 19 lines

Test #8:

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

input:

1
1000000
-1 0 0 -1 0 -1 0 1 -1 1 1 0 1 -1 0 1 -1 1 0 1 -1 1 1 0 -1 1 -1 1 -1 0 1 -1 -1 -1 0 0 -1 -1 -1 -1 -1 0 -1 0 0 1 1 -1 0 0 -1 -1 0 -1 -1 1 -1 0 1 -1 0 0 1 1 1 -1 -1 1 0 -1 -1 1 -1 1 -1 1 1 1 0 0 1 1 0 -1 1 1 0 0 1 0 -1 -1 -1 -1 0 -1 1 0 0 0 1 -1 -1 1 0 0 0 0 0 1 -1 0 0 -1 -1 0 1 -1 -1 -1 1 -1...

output:

-1

result:

ok single line: '-1'

Test #9:

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

input:

95250
18
1 1 0 1 1 -1 1 1 1 0 -1 1 1 1 1 0 1 1
10
1 1 1 1 1 1 1 1 1 1
18
1 1 1 0 -1 -1 1 1 1 1 1 -1 1 1 1 1 1 -1
14
1 1 1 1 1 -1 1 1 1 0 1 0 1 1
18
1 1 1 1 -1 1 1 -1 1 1 1 1 1 1 1 0 -1 -1
15
1 1 1 1 1 1 -1 1 1 1 1 1 1 1 1
18
-1 1 0 1 1 1 1 0 1 1 1 1 1 1 0 1 1 1
9
0 1 1 1 -1 1 1 1 1
9
1 1 1 1 1 1 1 1...

output:

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

result:

ok 95250 lines

Test #10:

score: 0
Accepted
time: 21ms
memory: 8484kb

input:

95470
18
0 0 -1 0 0 0 0 0 0 0 0 -1 0 -1 0 0 0 0
1
0
6
0 1 -1 0 0 0
2
-1 -1
11
-1 0 1 0 -1 1 0 0 0 0 0
9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3 1
9 4
1 1
5 1
2 1
11 1
12 5
7 4
3 1
3 1
3 1
7 4
5 2
13 7
5 1
7 2
2 1
5 2
1 1
-1
6 5
4 1
1 1
1 ...

result:

ok 95283 lines

Test #12:

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

input:

94921
4
1 1 0 1
8
1 1 1 1 1 -1 1 1
6
-1 -1 1 1 1 1
7
0 1 1 1 1 1 1
19
1 1 1 1 1 1 1 -1 1 1 1 1 0 -1 1 1 1 1 1
18
1 1 1 1 1 -1 1 0 1 1 1 1 -1 -1 1 1 -1 1
2
1 -1
15
1 1 1 -1 1 1 1 1 -1 1 1 1 0 0 1
4
1 -1 1 1
18
1 1 1 1 1 1 0 0 1 1 1 1 -1 0 1 1 1 1
19
1 1 1 1 1 -1 -1 1 1 1 1 1 1 1 1 1 -1 1 1
5
1 1 1 1 ...

output:

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

result:

ok 94921 lines

Test #13:

score: 0
Accepted
time: 17ms
memory: 8500kb

input:

95421
15
0 0 0 -1 0 0 0 0 0 0 -1 -1 0 0 0
20
0 -1 -1 0 0 0 0 0 0 0 0 -1 0 0 0 0 1 0 0 0
15
1 -1 0 0 -1 0 0 0 0 0 -1 0 0 -1 0
14
0 0 0 1 1 0 0 0 0 0 0 -1 -1 0
4
1 0 0 -1
8
0 0 0 0 1 0 0 0
7
0 0 1 -1 0 0 0
2
-1 0
3
0 0 0
9
-1 0 0 0 0 0 0 0 0
7
0 0 0 0 0 0 0
8
0 0 0 -1 0 0 0 -1
17
0 -1 0 0 1 0 0 -1 0 -...

output:

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

result:

ok 95421 lines

Test #14:

score: 0
Accepted
time: 12ms
memory: 12828kb

input:

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

output:

833396 666791

result:

ok single line: '833396 666791'

Test #15:

score: 0
Accepted
time: 12ms
memory: 12604kb

input:

1
1000000
0 0 0 -1 0 -1 -1 0 -1 0 0 0 1 0 0 0 0 0 -1 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 -1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 -1 1 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 1 0 ...

output:

500001 1

result:

ok single line: '500001 1'

Test #16:

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

input:

1
1000000
1 0 1 0 0 1 1 1 0 1 1 -1 0 1 0 -1 0 1 1 1 0 1 1 1 1 1 -1 1 0 0 -1 1 1 1 0 1 0 1 0 -1 1 0 0 1 1 0 -1 1 0 1 0 0 1 1 1 -1 0 0 1 1 1 0 1 1 0 0 -1 0 1 0 0 0 0 1 1 0 0 1 1 -1 0 1 0 1 0 0 1 0 0 1 0 0 1 0 1 1 -1 0 1 1 1 1 0 0 0 0 0 1 -1 1 0 0 0 0 1 1 1 1 0 1 1 1 0 1 0 0 1 0 1 0 1 1 1 0 1 0 0 1 1 1...

output:

500013 25

result:

ok single line: '500013 25'

Test #17:

score: 0
Accepted
time: 6ms
memory: 12560kb

input:

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

output:

769505 539009

result:

ok single line: '769505 539009'

Test #18:

score: 0
Accepted
time: 9ms
memory: 12424kb

input:

1
1000000
1 0 0 0 0 0 -1 0 -1 0 0 -1 0 0 0 -1 0 0 -1 0 0 0 -1 -1 0 1 0 0 0 0 0 0 -1 -1 -1 -1 0 1 0 0 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 0 0 0 0 0 -1 -1 0 0 0 0 0 0 -1 -1 0 0 -1 0 -1 0 -1 0 0 0 0 0 0 0 0 -1 0 0 1 0 0 1 1 0 0 1 0 -1 0 0 0 -1 0 -1 0 0 -1 0 0 -1 0 0 -1 0 -1 0 0 -1 -1 -1 1 0 0 0 0 0 0 -1 0 ...

output:

500002 3

result:

ok single line: '500002 3'

Test #19:

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

input:

95013
14
0 0 -1 0 -1 0 0 0 -1 0 -1 0 0 -1
17
0 0 0 0 -1 0 0 0 0 0 -1 0 0 -1 0 0 0
13
0 0 0 0 0 0 -1 0 0 0 -1 0 -1
6
0 -1 0 0 0 0
20
0 0 0 -1 0 -1 0 0 0 -1 -1 0 -1 -1 0 -1 -1 -1 -1 0
17
-1 0 0 0 0 0 -1 0 0 0 -1 -1 0 0 0 -1 0
2
0 0
9
0 0 -1 0 -1 0 0 0 0
18
0 -1 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0
7
0 0 0...

output:

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

result:

ok 95013 lines

Test #20:

score: 0
Accepted
time: 6ms
memory: 8724kb

input:

95166
13
1 -1 1 1 1 1 1 1 1 1 1 1 1
15
1 1 -1 -1 1 1 -1 1 1 1 -1 1 -1 1 1
3
1 1 -1
9
1 -1 1 1 1 -1 1 1 1
14
-1 -1 -1 1 -1 1 1 1 -1 1 -1 1 -1 1
2
1 1
7
1 -1 -1 -1 1 -1 1
6
1 1 -1 1 -1 -1
6
1 -1 -1 1 1 -1
11
-1 1 1 1 -1 1 -1 1 1 -1 1
10
1 1 1 1 -1 1 1 1 1 1
3
-1 1 -1
4
1 -1 1 1
13
1 1 1 1 1 -1 1 -1 1 ...

output:

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

result:

ok 95166 lines

Test #21:

score: 0
Accepted
time: 17ms
memory: 8512kb

input:

94880
2
1 0
16
0 1 1 1 0 0 0 1 1 1 0 0 1 1 0 1
6
1 1 0 1 1 1
4
0 0 1 1
19
1 0 0 1 0 0 0 0 1 1 0 0 1 1 0 1 0 0 0
8
0 0 0 0 0 1 0 1
8
0 1 0 1 0 0 0 1
10
1 1 0 1 0 1 0 0 1 1
11
0 0 1 1 1 0 1 1 0 1 0
12
0 1 1 1 0 0 1 1 0 0 0 0
4
0 1 1 0
9
1 0 1 0 0 1 0 0 1
17
0 0 1 0 0 0 1 0 1 1 1 0 0 1 0 0 1
20
0 0 1 1...

output:

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

result:

ok 94880 lines

Test #22:

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

input:

94941
6
0 0 0 0 0 0
4
0 0 0 0
19
0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1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
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 95248 lines

Test #24:

score: 0
Accepted
time: 16ms
memory: 12708kb

input:

1
1000000
0 0 0 0 0 0 0 0 0 0 0 0 -1 0 -1 0 0 0 -1 0 0 0 0 0 -1 0 0 0 -1 -1 0 -1 -1 0 -1 -1 0 0 -1 0 0 0 -1 0 0 0 -1 0 0 0 0 -1 0 0 0 0 0 0 -1 -1 0 0 0 0 0 -1 0 -1 0 0 0 0 0 0 -1 -1 0 0 -1 0 0 0 0 -1 0 0 0 0 0 -1 -1 0 0 0 -1 -1 0 -1 -1 -1 0 0 0 -1 0 0 0 0 0 0 0 -1 0 0 0 0 0 -1 0 -1 0 0 0 0 0 0 -1 0 ...

output:

500001 1

result:

ok single line: '500001 1'

Test #25:

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

input:

1
1000000
1 -1 1 1 -1 1 1 -1 -1 1 1 1 1 1 1 1 1 1 -1 -1 1 1 -1 1 1 1 -1 -1 -1 1 1 1 -1 1 1 -1 1 1 1 -1 -1 -1 -1 -1 1 1 1 1 1 -1 1 1 1 1 -1 -1 1 1 1 1 -1 1 1 1 1 -1 1 1 1 1 1 1 1 1 1 -1 1 1 1 1 -1 1 1 1 1 1 1 1 1 1 1 -1 1 -1 1 1 1 -1 1 1 -1 -1 -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:

667168 334335

result:

ok single line: '667168 334335'

Test #26:

score: 0
Accepted
time: 8ms
memory: 13276kb

input:

1
1000000
1 1 0 0 0 0 1 0 0 1 0 1 1 1 1 1 0 0 0 0 1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 1 1 0 0 1 0 1 1 1 1 0 0 0 0 0 1 1 1 0 1 0 0 0 0 0 1 0 0 1 1 1 1 1 0 1 1 1 0 0 0 1 1 1 1 1 1 0 0 0 0 1 1 1 0 1 0 0 1 0 1 0 0 1 1 0 1 0 1 1 0 1 0 0 0 1 0 1 1 0 1 0 0 1 1 1 0 1 1 0 0 0 1 1 1 1 0 1 0 0 1 1 0 0 0 0 0 1 0 1 1 ...

output:

500603 1205

result:

ok single line: '500603 1205'

Test #27:

score: 0
Accepted
time: 3ms
memory: 12392kb

input:

1
1000000
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

output:

500001 1

result:

ok single line: '500001 1'

Test #28:

score: 0
Accepted
time: 5ms
memory: 13324kb

input:

1
1000000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 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

result:

ok single line: '1 1'