QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#76608#4884. Battleship: New RulesLG_MonkeyAC ✓246ms11444kbC++142.5kb2023-02-10 22:05:002023-02-10 22:05:02

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-02-10 22:05:02]
  • 评测
  • 测评结果:AC
  • 用时:246ms
  • 内存:11444kb
  • [2023-02-10 22:05:00]
  • 提交

answer

/*NE Write and AFO here*/
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define pii pair<int, int>
#define mp make_pair
int n, a[1010][1010]; 
pii dfs(int x1, int y1, int X2, int Y2) {
	int x2 = X2 - 1, y2 = Y2 - 1; 
	if (x1 == X2 && y1 == Y2) {
		if (a[x1 - 1][y1] == 1 || a[x1 - 1][y1 - 1] == 1 || a[x1][y1] == 1 || a[x1][y1 - 1]) return mp(-1, -1);
		return mp(x1, y1);
	}
	int cnt = (x2 - x1 + 2) * (y2 - y1 + 2) + 88888888886;
	for (int i = y1; i <= y2; ) {
		if (a[x2 + 1][i] != 1) {
			i++; continue;
		}
		int j = i;
		while (j < y2 && a[x2 + 1][j + 1] == 1) j++;
		cnt -= j - i + 2; i = j + 1;
	} 
	for (int i = y1; i <= y2; ) {
		if (a[x1 - 1][i] != 1) {
			i++; continue;
		}
		int j = i;
		while (j < y2 && a[x1 - 1][j + 1] == 1) j++;
		cnt -= j - i + 2; i = j + 1;
	} 
	for (int i = x1; i <= x2; ) {
		if (a[i][y1 - 1] != 1) {
			i++; continue;
		}
		int j = i;
		while (j < x2 && a[j + 1][y1 - 1] == 1) j++;
		cnt -= j - i + 2; i = j + 1;
	} 
	for (int i = x1; i <= x2; ) {
		if (a[i][y2 + 1] != 1) {
			i++; continue;
		}
		int j = i;
		while (j < x2 && a[j + 1][y2 + 1] == 1) j++;
		cnt -= j - i + 2; i = j + 1;
	} 
	if (a[x1 - 1][y1 - 1] == 1 && a[x1 - 1][y1] != 1 && a[x1][y1 - 1] != 1) cnt--;
	if (a[x2 + 1][y1 - 1] == 1 && a[x2 + 1][y1] != 1 && a[x2][y1 - 1] != 1) cnt--;
	if (a[x1 - 1][y2 + 1] == 1 && a[x1 - 1][y2] != 1 && a[x1][y2 + 1] != 1) cnt--;
	if (a[x2 + 1][y2 + 1] == 1 && a[x2 + 1][y2] != 1 && a[x2][y2 + 1] != 1) cnt--;
	if (cnt % 2 == 0) return mp(-1, -1);
	if (x2 - x1 > y2 - y1) {
		int mid = (x1 + x2) >> 1;
		for (int j = y1; j <= y2; j++) {
			if (a[mid][j] == -1) {
				cout << "? " << mid << " " << j << endl; int x; cin >> x; a[mid][j] = x;
			}
		}
		pii la = dfs(x1, y1, mid, Y2), ra = dfs(mid + 1, y1, X2, Y2);
		if (la.first == -1) return ra; else if (ra.first != -1) while (1); else return la;
	} else {
		int mid = (y1 + y2) >> 1;
		for (int j = x1; j <= x2; j++) {
			if (a[j][mid] == -1) {
				cout << "? " << j << " " << mid << endl; int x; cin >> x; a[j][mid] = x;
			}
		}
		pii la = dfs(x1, y1, X2, mid), ra = dfs(x1, mid + 1, X2, Y2);
		if (la.first == -1) return ra; else if (ra.first != -1) while (1); else return la;
	}
}
signed main() {
	int T;
	cin >> T;
	while (T--) {
		cin >> n;
		if (n & 1) {
			cout << "! -1 -1" << endl; int x; cin >> x; continue;
		}
		memset(a, -1, sizeof a);
		pii ans = dfs(1, 1, n + 1, n + 1);
		cout << "! " << ans.first - 1 << " " << ans.second - 1 << endl; int x; cin >> x;
	}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:

! -1 -1
? 1 2
? 2 2
? 3 2
? 4 2
? 2 3
? 2 4
? 3 3
? 4 3
! 2 2

result:

ok max_C=2.00, avg_C=1.00 (2 test cases)

Test #2:

score: 0
Accepted
time: 63ms
memory: 11436kb

input:

100
4
1
0
0
0
0
1
0
1
1
4
1
0
0
0
0
1
0
1
1
4
0
0
0
1
0
0
0
0
1
4
0
0
0
1
0
0
0
0
1
4
1
0
0
0
0
1
0
1
1
4
1
0
0
0
0
1
0
1
1
4
1
0
0
0
0
1
0
1
1
4
0
0
0
1
0
0
0
0
1
4
0
0
0
1
0
0
0
0
1
4
0
0
0
1
0
0
0
0
1
4
0
0
0
1
0
0
0
0
1
4
1
0
0
0
0
1
0
1
1
4
0
0
0
1
0
0
0
0
1
4
1
0
0
0
0
1
0
1
1
4
1
0
0
0
0
1
0
...

output:

? 1 2
? 2 2
? 3 2
? 4 2
? 2 3
? 2 4
? 3 3
? 4 3
! 2 2
? 1 2
? 2 2
? 3 2
? 4 2
? 2 3
? 2 4
? 3 3
? 4 3
! 2 2
? 1 2
? 2 2
? 3 2
? 4 2
? 2 3
? 2 4
? 3 3
? 4 3
! 2 2
? 1 2
? 2 2
? 3 2
? 4 2
? 2 3
? 2 4
? 3 3
? 4 3
! 2 2
? 1 2
? 2 2
? 3 2
? 4 2
? 2 3
? 2 4
? 3 3
? 4 3
! 2 2
? 1 2
? 2 2
? 3 2
? 4 2
? 2 3
...

result:

ok max_C=2.00, avg_C=2.00 (100 test cases)

Test #3:

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

input:

100
10
1
0
0
0
0
0
0
1
0
1
0
0
0
1
0
0
0
0
0
0
1
0
1
10
1
0
1
0
1
0
1
0
1
1
1
0
1
0
1
1
0
1
0
1
0
0
0
0
0
1
10
1
0
1
0
1
0
0
0
0
1
0
0
0
0
1
1
0
1
1
0
0
0
0
1
10
1
0
1
0
1
0
1
1
0
1
1
1
1
0
1
0
0
0
0
1
0
0
0
0
1
10
1
0
1
1
1
1
0
1
0
1
0
0
0
0
0
1
0
0
0
0
1
0
1
1
10
1
0
1
0
0
0
0
0
1
1
1
0
1
0
1
1
0
...

output:

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

result:

ok max_C=2.60, avg_C=2.37 (100 test cases)

Test #4:

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

input:

100
49
1
49
1
49
1
49
1
49
1
49
1
49
1
49
1
49
1
49
1
49
1
49
1
49
1
49
1
49
1
49
1
49
1
49
1
49
1
49
1
49
1
49
1
49
1
49
1
49
1
49
1
49
1
49
1
49
1
49
1
49
1
49
1
49
1
49
1
49
1
49
1
49
1
49
1
49
1
49
1
49
1
49
1
49
1
49
1
49
1
49
1
49
1
49
1
49
1
49
1
49
1
49
1
49
1
49
1
49
1
49
1
49
1
49
1
49
1
4...

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...

result:

ok max_C=0.00, avg_C=0.00 (100 test cases)

Test #5:

score: 0
Accepted
time: 246ms
memory: 11224kb

input:

100
50
1
0
1
1
1
0
1
0
1
0
1
0
1
0
1
0
1
0
0
0
1
0
0
0
1
0
1
0
1
1
1
0
1
0
1
1
1
1
0
1
0
1
0
1
0
0
0
1
0
1
1
1
1
1
1
1
0
1
0
1
0
1
0
1
0
1
1
0
1
0
1
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
1
0
1
0
1
0
1
0
1
1
0
1
0
0
0
0
1
0
1
0
1
1
1
0
1
0
1
0
1
0
1
0
1
1
0
1
1
0
0
0
0
1
0
0
0
0
1
0
1
50
1
0
0
0
0
...

output:

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

result:

ok max_C=2.88, avg_C=2.77 (100 test cases)

Test #6:

score: 0
Accepted
time: 103ms
memory: 11444kb

input:

100
31
1
23
1
62
1
0
1
0
1
0
0
0
0
0
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
1
1
1
1
1
1
1
1
1
1
1
1
0
1
0
0
0
1
0
1
1
0
1
0
1
1
1
1
1
1
1
0
1
0
1
0
1
0
0
0
0
0
0
0
0
1
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0...

output:

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

result:

ok max_C=2.93, avg_C=1.26 (100 test cases)

Test #7:

score: 0
Accepted
time: 196ms
memory: 11260kb

input:

100
50
1
0
0
0
0
0
0
0
0
0
0
0
1
0
1
0
1
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
1
0
1
0
1
1
1
1
1
1
1
1
1
1
1
1
0
1
0
1
1
1
1
0
1
0
1
0
1
0
1
1
1
1
1
0
1
0
1
0
1
0
1
0
1
1
1
1
1
1
1
0
0
0
0
0
1
0
0
0
0
0
0
0
0
1
0
1
0
0
0
0
0
0
0
0
0
1
0
1
0
0
0
0
1
0
1
0
0
0
0
1
0
1
0
1
0
1
0
0
1
0
1
1
1
0
1
0
0
1
0
0
1
50
...

output:

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

result:

ok max_C=2.88, avg_C=2.80 (100 test cases)

Test #8:

score: 0
Accepted
time: 184ms
memory: 11416kb

input:

100
50
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
0
0
0
0
0
0
0
1
0
1
0
0
0
0
0
1
0
1
0
0
0
1
0
0
0
0
0
1
1
0
1
0
1
0
1
1
0
1
0
0
0
1
0
1
0
1
1
1
0
1
0
1
1
0
0
0
0
0
0
0
0
0
0
1
0
1
0
1
0
1
1
1
0
1
0
1
0
1
0
1
0
0
0
0
0
1
0
1
1
0
1
1
1
1
1
1
1
0
1
1
1
1
1
0
1
0
0
0
0
1
1
0
1
0
0
1
50
1
0
0
0
0
0
0
...

output:

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

result:

ok max_C=2.88, avg_C=2.79 (100 test cases)

Test #9:

score: 0
Accepted
time: 73ms
memory: 11316kb

input:

10
500
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
1
1
1
1
1
1
1
0
1
1
1
0
1
0
1
0
1
0
1
1
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
0
0
1
0
1
0
1
0
1
0
1
0
0
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
0
0
1
0
1
0
1
0
1
0
0
0
1
0
0
0
0
0
1
0
1
0
1
0
1
0
0
0
0
0
1
0
1
0
0
0...

output:

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

result:

ok max_C=2.97, avg_C=2.96 (10 test cases)

Test #10:

score: 0
Accepted
time: 65ms
memory: 11436kb

input:

10
597
1
1000
1
0
1
0
0
0
0
0
1
0
0
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
0
0
0
0
1
0
1
0
0
0
1
0
1
0
1
0
1
0
0
0
1
0
0
0
0
0
0
0
0
0
0
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
0
0
0
0
0
1
0
0
0
0
0
1
0
0
0
0
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
0
0
1
0
0
0
0
0
0
0
1
0
0
0
1
1
1
1
1
0
1
0
1
0
...

output:

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

result:

ok max_C=2.98, avg_C=1.76 (10 test cases)

Test #11:

score: 0
Accepted
time: 0ms
memory: 3296kb

input:

5
999
1
999
1
999
1
999
1
999
1

output:

! -1 -1
! -1 -1
! -1 -1
! -1 -1
! -1 -1

result:

ok max_C=0.00, avg_C=0.00 (5 test cases)

Test #12:

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

input:

5
1000
1
0
1
0
1
0
1
0
1
0
1
0
1
1
1
0
1
0
0
0
0
0
0
0
1
0
1
0
0
0
0
0
0
0
1
0
0
0
0
0
1
0
0
0
1
0
1
0
1
0
1
0
1
0
1
0
1
1
1
1
1
1
1
0
1
1
1
1
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
1
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
0
0
1
0
1
0
1
0
1
0
1
0
1...

output:

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

result:

ok max_C=2.98, avg_C=2.98 (5 test cases)

Test #13:

score: 0
Accepted
time: 121ms
memory: 11256kb

input:

5
1000
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
0
0
1
0
1
0
1
0
1
1
1
1
1
0
1
0
1
0
1
0
0
0
0
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
0
0
0
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
0
0
0
0
0
0
1
0
0
0
1
0
1
0
1
0
1
0
0
0
1
0
1
0
1
0
1
0
1
0
0
0
1
0
1
0
1
0
0
0
1
0
1
0
1
0
1...

output:

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

result:

ok max_C=2.98, avg_C=2.98 (5 test cases)

Test #14:

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

input:

5
1000
1
1
0
1
0
1
0
1
0
0
0
0
0
1
0
1
0
1
0
1
1
1
0
1
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
1
0
0
0
0
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
0
0
0
0
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
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
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
1
0...

output:

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

result:

ok max_C=2.98, avg_C=2.98 (5 test cases)

Test #15:

score: 0
Accepted
time: 112ms
memory: 11440kb

input:

5
1000
1
0
1
0
0
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
0
0
1
0
1
0
1
0
0
0
1
0
1
0
0
0
0
0
0
0
1
0
0
0
0
0
1
0
1
0
0
0
0
0
1
0
1
0
0
0
1
0
0
0
1
0
1
0
1
0
0
0
1
0
1
0
1
0
0
0
1
0
1
0
1
0
1
0
0
0
0
0
1
0
0
0
1
0
1
0
1
0
0
0
1
0
1
0
1
0
0
0
1
0
1
0
1
0
1
0
0
0
1
0
1
0
0
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
0
0
0...

output:

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

result:

ok max_C=2.98, avg_C=2.98 (5 test cases)

Test #16:

score: 0
Accepted
time: 114ms
memory: 11316kb

input:

5
1000
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
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
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
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 500
? 2 500
? 3 500
? 4 500
? 5 500
? 6 500
? 7 500
? 8 500
? 9 500
? 10 500
? 11 500
? 12 500
? 13 500
? 14 500
? 15 500
? 16 500
? 17 500
? 18 500
? 19 500
? 20 500
? 21 500
? 22 500
? 23 500
? 24 500
? 25 500
? 26 500
? 27 500
? 28 500
? 29 500
? 30 500
? 31 500
? 32 500
? 33 500
? 34 500
? 3...

result:

ok max_C=2.98, avg_C=2.98 (5 test cases)

Test #17:

score: 0
Accepted
time: 99ms
memory: 11444kb

input:

5
1000
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
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:

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

result:

ok max_C=2.98, avg_C=2.98 (5 test cases)

Test #18:

score: 0
Accepted
time: 81ms
memory: 11224kb

input:

5
1000
1
0
1
0
1
0
0
0
1
0
0
0
1
0
1
0
0
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
0
0
0
0
0
0
0
0
0
0
0
1
0
1
0
1
0
1
0
0
0
1
0
1
0
1
0
0
0
1
0
1
0
1
0
0
0
1
1
1
0
1
0
1
0
1
0
1
0
0
0
1
0
1
0
1
0
1
0
1
0
1
0
0
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
0
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0...

output:

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

result:

ok max_C=2.98, avg_C=2.98 (5 test cases)

Test #19:

score: 0
Accepted
time: 80ms
memory: 11260kb

input:

5
1000
1
0
1
0
1
0
1
0
1
1
1
1
0
1
1
0
1
0
1
0
1
0
0
0
1
0
1
0
1
1
0
1
0
1
0
1
1
0
1
1
1
1
0
1
0
1
0
1
1
1
1
1
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
0
0
1
0
1
0
0
0
1
0
0
0
1
0
1
0
1
0
1
1
1
0
1
0
1
0
1
0
1
0
1
0
1
0
0
0
0
0
0
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
1
0
1
1
1
1
1
1
0
1
1
1
0
1...

output:

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

result:

ok max_C=2.98, avg_C=2.98 (5 test cases)

Test #20:

score: 0
Accepted
time: 101ms
memory: 11276kb

input:

5
1000
1
0
1
0
1
1
1
1
1
1
1
0
1
0
0
0
1
1
1
0
0
0
1
0
1
1
1
0
1
0
1
1
1
1
1
1
0
1
1
1
0
1
0
1
0
1
1
1
1
0
1
0
1
1
1
1
0
1
1
1
1
1
1
1
1
0
1
0
1
0
1
0
1
0
1
1
1
0
1
0
1
0
1
0
1
1
1
0
1
1
1
1
1
0
1
0
1
1
1
0
1
0
1
0
1
0
1
0
1
0
1
1
1
0
1
0
1
0
1
0
1
0
1
1
1
0
1
0
1
1
0
1
1
1
1
0
1
0
1
0
1
0
1
1
1
0
1...

output:

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

result:

ok max_C=2.98, avg_C=2.98 (5 test cases)