QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#50620#4884. Battleship: New RulesQingyuAC ✓286ms7836kbC++233.0kb2022-09-28 00:36:392022-09-28 00:36:42

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-09-28 00:36:42]
  • 评测
  • 测评结果:AC
  • 用时:286ms
  • 内存:7836kb
  • [2022-09-28 00:36:39]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

void answer(int x, int y) {
    if (x >= 0 || y >= 0) {
        x++, y++;
    }
    cout << "! " << x << " " << y << endl;
    int ans;
    cin >> ans;
    if (ans != 1) {
        exit(0);
    }
}

vector<vector<int>> cache;

int ask(int x, int y) {
    if (x >= (int)cache.size() || y >= (int)cache.size() || x < 0 || y < 0) {
        return 0;
    }
    if (cache[x][y] != -1) {
        return cache[x][y];
    }
    cout << "? " << x + 1 << " " << y + 1 << endl;
    int ans;
    cin >> ans;
    if (ans == -1) {
        exit(0);
    }
    cache[x][y] = ans;
    return ans;
}

vector<vector<bool>> used;

void color4(int x, int y) {
    for (int dx = 0; dx < 2; dx++) {
        for (int dy = 0; dy < 2; dy++) {
            used[x + dx][y + dy] = true;
        }
    }
}

bool upd(int x, int y) {
    bool res = true;
    for (int dx = 0; dx < 2; dx++) {
        for (int dy = 0; dy < 2; dy++) {
            if (ask(x - dx, y - dy) == 1) {
                color4(x - dx, y - dy);
                res = false;
            }
        }
    }
    return res;
}

pair<int, int> func(int x1, int y1, int x2, int y2) {
    if (x2 - x1 == 1 && y2 - y1 == 1) {
        return make_pair(x1, y1);
    }
    tuple<int, int, int, int> r1, r2;
    if (x2 - x1 >= y2 - y1) {
        int mid = (x1 + x2) / 2;
        for (int i = y1; i < y2; i++) {
            if (upd(mid, i)) {
                return make_pair(mid, i);
            }
        }
        r1 = make_tuple(x1, y1, mid, y2);
        r2 = make_tuple(mid + 1, y1, x2, y2);
    } else {
        int mid = (y1 + y2) / 2;
        for (int i = x1; i < x2; i++) {
            if (upd(i, mid)) {
                return make_pair(i, mid);
            }
        }
        r1 = make_tuple(x1, y1, x2, mid);
        r2 = make_tuple(x1, mid + 1, x2, y2);
    }
    int s1 = 0;
    for (int i = get<0>(r1); i < get<2>(r1); i++) {
        for (int j = get<1>(r1); j < get<3>(r1); j++) {
            if (!used[i][j]) {
                s1++;
            }
        }
    }
    if (s1 % 2 == 1) {
        return func(get<0>(r1), get<1>(r1), get<2>(r1), get<3>(r1));
    } else {
        return func(get<0>(r2), get<1>(r2), get<2>(r2), get<3>(r2));
    }
}

void solve(int n) {
    used.clear();
    used.reserve(n + 1);
    for (int i = 0; i < n + 1; i++) {
        used.emplace_back(vector<bool>(n + 1, false));
    }
    pair<int, int> t = func(0, 0, n + 1, n + 1);
    answer(t.first - 1, t.second - 1);
}

void solve_full(int n) {
    if (n % 2 == 1) {
        answer(-1, -1);
        return;
    }
    cache.clear();
    cache.reserve(n);
    for (int i = 0; i < n; i++) {
        cache.emplace_back(vector<int>(n, -1));
    }
    solve(n);
}

int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    int t;
    cin >> t;
    while (t--) {
        int n;
        cin >> n;
        solve_full(n);
    }

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

2
3
1
4
1
0
0
0
0
0
1

output:

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

result:

ok max_C=1.50, avg_C=0.75 (2 test cases)

Test #2:

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

input:

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

output:

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

result:

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

Test #3:

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

input:

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

output:

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

result:

ok max_C=3.90, avg_C=3.23 (100 test cases)

Test #4:

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

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: 176ms
memory: 3664kb

input:

100
50
1
1
0
0
0
1
0
0
1
1
0
0
1
1
0
0
1
0
0
0
1
0
0
0
1
1
0
0
1
1
0
0
1
0
0
0
1
0
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
0
1
1
0
0
1
1
0
0
1
1
0
0
1
1
0
0
0
1
0
1
0
0
0
1
0
0
0
1
0
0
1
0
0
0
1
1
0
1
0
0
0
1
0
1
0
1
0
0
0
1
0
0
0
1
0
1
0
1
0
1
0
0
0
1
0
0
0
1
0
0
1
1
0
0
1
0
0
0
1
1
0
0
1...

output:

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

result:

ok max_C=5.36, avg_C=4.96 (100 test cases)

Test #6:

score: 0
Accepted
time: 128ms
memory: 3924kb

input:

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

output:

! -1 -1
! -1 -1
? 32 1
? 31 1
? 32 2
? 31 2
? 32 3
? 31 3
? 32 4
? 31 4
? 32 5
? 31 5
? 32 6
? 31 6
? 32 7
? 31 7
? 32 8
? 31 8
? 32 9
? 31 9
? 32 10
? 31 10
? 32 11
? 31 11
? 32 12
? 31 12
? 32 13
? 31 13
? 32 14
? 31 14
? 32 15
? 31 15
? 32 16
? 31 16
? 32 17
? 31 17
? 32 18
? 31 18
? 32 19
? 31 1...

result:

ok max_C=5.71, avg_C=2.26 (100 test cases)

Test #7:

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

input:

100
50
1
1
0
0
1
0
0
0
0
1
0
0
1
1
0
0
1
1
0
0
1
1
0
0
1
1
0
0
0
1
0
1
0
0
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
0
1
1
0
0
1
1
0
0
1
1
0
0
0
1
0
1
0
1
0
1
0
1
0
0
0
1
0
0
0
1
0
0
1
1
0
0
1
1
1
0
0
0
1
0
0
0
1
0
0
0
1
1
0
0
1
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
0
1...

output:

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

result:

ok max_C=5.36, avg_C=5.21 (100 test cases)

Test #8:

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

input:

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

output:

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

result:

ok max_C=5.36, avg_C=5.07 (100 test cases)

Test #9:

score: 0
Accepted
time: 269ms
memory: 4608kb

input:

10
500
1
1
0
0
1
1
0
0
1
1
0
0
1
1
0
0
1
1
0
0
1
1
0
0
1
1
0
0
0
1
0
0
1
1
0
0
1
1
0
0
0
1
0
0
1
1
0
0
1
0
0
0
1
0
0
0
1
0
0
0
1
1
0
0
1
1
0
0
1
1
0
0
1
0
0
0
1
1
0
0
1
0
0
0
1
1
0
0
1
0
0
0
1
0
0
0
0
1
0
0
0
1
0
0
1
0
0
0
1
0
0
0
1
1
0
0
1
1
0
0
0
1
0
0
1
1
0
0
0
1
0
0
1
1
0
0
1
1
0
0
1
1
0
0
0
1
0...

output:

? 251 1
? 250 1
? 251 2
? 250 2
? 251 3
? 250 3
? 251 4
? 250 4
? 251 5
? 250 5
? 251 6
? 250 6
? 251 7
? 250 7
? 251 8
? 250 8
? 251 9
? 250 9
? 251 10
? 250 10
? 251 11
? 250 11
? 251 12
? 250 12
? 251 13
? 250 13
? 251 14
? 250 14
? 251 15
? 250 15
? 251 16
? 250 16
? 251 17
? 250 17
? 251 18
? 2...

result:

ok max_C=5.89, avg_C=5.86 (10 test cases)

Test #10:

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

input:

10
597
1
1000
1
1
0
0
1
1
0
0
1
1
0
0
0
1
0
0
0
1
0
0
0
1
0
0
0
1
0
1
0
1
0
0
1
1
0
0
1
1
0
0
1
1
0
0
0
1
0
0
1
1
0
0
1
1
0
0
1
1
0
0
0
1
0
0
1
0
0
0
1
0
0
0
1
0
0
0
0
1
0
0
1
1
0
0
1
0
1
0
1
0
0
0
0
1
0
0
1
1
0
0
1
1
0
0
1
1
0
0
0
1
0
0
1
0
1
0
1
0
0
0
1
1
0
0
0
1
0
0
1
0
0
0
1
0
0
0
1
1
0
0
1
1
0
...

output:

! -1 -1
? 501 1
? 500 1
? 501 2
? 500 2
? 501 3
? 500 3
? 501 4
? 500 4
? 501 5
? 500 5
? 501 6
? 500 6
? 501 7
? 500 7
? 501 8
? 500 8
? 501 9
? 500 9
? 501 10
? 500 10
? 501 11
? 500 11
? 501 12
? 500 12
? 501 13
? 500 13
? 501 14
? 500 14
? 501 15
? 500 15
? 501 16
? 500 16
? 501 17
? 500 17
? 50...

result:

ok max_C=5.93, avg_C=3.40 (10 test cases)

Test #11:

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

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: 271ms
memory: 7684kb

input:

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

output:

? 501 1
? 500 1
? 501 2
? 500 2
? 501 3
? 500 3
? 501 4
? 500 4
? 501 5
? 500 5
? 501 6
? 500 6
? 501 7
? 500 7
? 501 8
? 500 8
? 501 9
? 500 9
? 501 10
? 500 10
? 501 11
? 500 11
? 501 12
? 500 12
? 501 13
? 500 13
? 501 14
? 500 14
? 501 15
? 500 15
? 501 16
? 500 16
? 501 17
? 500 17
? 501 18
? 5...

result:

ok max_C=5.93, avg_C=5.92 (5 test cases)

Test #13:

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

input:

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

output:

? 501 1
? 500 1
? 501 2
? 500 2
? 501 3
? 500 3
? 501 4
? 500 4
? 501 5
? 500 5
? 501 6
? 500 6
? 501 7
? 500 7
? 501 8
? 500 8
? 501 9
? 500 9
? 501 10
? 500 10
? 501 11
? 500 11
? 501 12
? 500 12
? 501 13
? 500 13
? 501 14
? 500 14
? 501 15
? 500 15
? 501 16
? 500 16
? 501 17
? 500 17
? 501 18
? 5...

result:

ok max_C=5.94, avg_C=5.93 (5 test cases)

Test #14:

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

input:

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

output:

? 501 1
? 500 1
? 501 2
? 500 2
? 501 3
? 500 3
? 501 4
? 500 4
? 501 5
? 500 5
? 501 6
? 500 6
? 501 7
? 500 7
? 501 8
? 500 8
? 501 9
? 500 9
? 501 10
? 500 10
? 501 11
? 500 11
? 501 12
? 500 12
? 501 13
? 500 13
? 501 14
? 500 14
? 501 15
? 500 15
? 501 16
? 500 16
? 501 17
? 500 17
? 501 18
? 5...

result:

ok max_C=5.93, avg_C=5.89 (5 test cases)

Test #15:

score: 0
Accepted
time: 254ms
memory: 7676kb

input:

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

output:

? 501 1
? 500 1
? 501 2
? 500 2
? 501 3
? 500 3
? 501 4
? 500 4
? 501 5
? 500 5
? 501 6
? 500 6
? 501 7
? 500 7
? 501 8
? 500 8
? 501 9
? 500 9
? 501 10
? 500 10
? 501 11
? 500 11
? 501 12
? 500 12
? 501 13
? 500 13
? 501 14
? 500 14
? 501 15
? 500 15
? 501 16
? 500 16
? 501 17
? 500 17
? 501 18
? 5...

result:

ok max_C=5.93, avg_C=5.83 (5 test cases)

Test #16:

score: 0
Accepted
time: 186ms
memory: 7836kb

input:

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

output:

? 501 1
? 500 1
? 501 2
? 500 2
? 501 3
? 500 3
? 501 4
? 500 4
? 501 5
? 500 5
? 501 6
? 500 6
? 501 7
? 500 7
? 501 8
? 500 8
? 501 9
? 500 9
? 501 10
? 500 10
? 501 11
? 500 11
? 501 12
? 500 12
? 501 13
? 500 13
? 501 14
? 500 14
? 501 15
? 500 15
? 501 16
? 500 16
? 501 17
? 500 17
? 501 18
? 5...

result:

ok max_C=5.93, avg_C=5.91 (5 test cases)

Test #17:

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

input:

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

output:

? 501 1
? 500 1
? 501 2
? 500 2
? 501 3
? 500 3
? 501 4
? 500 4
? 501 5
? 500 5
? 501 6
? 500 6
? 501 7
? 500 7
? 501 8
? 500 8
? 501 9
? 500 9
? 501 10
? 500 10
? 501 11
? 500 11
? 501 12
? 500 12
? 501 13
? 500 13
? 501 14
? 500 14
? 501 15
? 500 15
? 501 16
? 500 16
? 501 17
? 500 17
? 501 18
? 5...

result:

ok max_C=5.93, avg_C=5.41 (5 test cases)

Test #18:

score: 0
Accepted
time: 207ms
memory: 7756kb

input:

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

output:

? 501 1
? 500 1
? 501 2
? 500 2
? 501 3
? 500 3
? 501 4
? 500 4
? 501 5
? 500 5
? 501 6
? 500 6
? 501 7
? 500 7
? 501 8
? 500 8
? 501 9
? 500 9
? 501 10
? 500 10
? 501 11
? 500 11
? 501 12
? 500 12
? 501 13
? 500 13
? 501 14
? 500 14
? 501 15
? 500 15
? 501 16
? 500 16
? 501 17
? 500 17
? 501 18
? 5...

result:

ok max_C=5.93, avg_C=5.92 (5 test cases)

Test #19:

score: 0
Accepted
time: 223ms
memory: 7780kb

input:

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

output:

? 501 1
? 500 1
? 501 2
? 500 2
? 501 3
? 500 3
? 501 4
? 500 4
? 501 5
? 500 5
? 501 6
? 500 6
? 501 7
? 500 7
? 501 8
? 500 8
? 501 9
? 500 9
? 501 10
? 500 10
? 501 11
? 500 11
? 501 12
? 500 12
? 501 13
? 500 13
? 501 14
? 500 14
? 501 15
? 500 15
? 501 16
? 500 16
? 501 17
? 500 17
? 501 18
? 5...

result:

ok max_C=5.93, avg_C=5.89 (5 test cases)

Test #20:

score: 0
Accepted
time: 286ms
memory: 7836kb

input:

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

output:

? 501 1
? 500 1
? 501 2
? 500 2
? 501 3
? 500 3
? 501 4
? 500 4
? 501 5
? 500 5
? 501 6
? 500 6
? 501 7
? 500 7
? 501 8
? 500 8
? 501 9
? 500 9
? 501 10
? 500 10
? 501 11
? 500 11
? 501 12
? 500 12
? 501 13
? 500 13
? 501 14
? 500 14
? 501 15
? 500 15
? 501 16
? 500 16
? 501 17
? 500 17
? 501 18
? 5...

result:

ok max_C=5.93, avg_C=5.92 (5 test cases)