QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#117729#4884. Battleship: New Ruleshos_lyricAC ✓64ms11748kbC++145.9kb2023-07-02 01:03:572023-07-02 01:04:00

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-02 01:04:00]
  • 评测
  • 测评结果:AC
  • 用时:64ms
  • 内存:11748kb
  • [2023-07-02 01:03:57]
  • 提交

answer

#include <cassert>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

using Int = long long;

template <class T1, class T2> ostream &operator<<(ostream &os, const pair<T1, T2> &a) { return os << "(" << a.first << ", " << a.second << ")"; };
template <class T> ostream &operator<<(ostream &os, const vector<T> &as) { const int sz = as.size(); os << "["; for (int i = 0; i < sz; ++i) { if (i >= 256) { os << ", ..."; break; } if (i > 0) { os << ", "; } os << as[i]; } return os << "]"; }
template <class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cerr << *i << " "; cerr << endl; }
template <class T> bool chmin(T &t, const T &f) { if (t > f) { t = f; return true; } return false; }
template <class T> bool chmax(T &t, const T &f) { if (t < f) { t = f; return true; } return false; }


int N;
#ifdef LOCAL
int secret[1010][1010];
#endif

int cache[1010][1010];
int A(int x, int y) {
  assert(1 <= x); assert(x <= N);
  assert(1 <= y); assert(y <= N);
  int &ret = cache[x][y];
  if (!~ret) {
    printf("? %d %d\n", x, y);
    fflush(stdout);
#ifdef LOCAL
ret=secret[x][y];
#else
    scanf("%d", &ret);
    if (!(ret == 0 || ret == 1)) {
      exit(0);
    }
#endif
  }
  return ret;
}

void Answer(int x, int y) {
  printf("! %d %d\n", x, y);
  fflush(stdout);
#ifdef LOCAL
if(!(x==-1&&y==-1)){
 assert(1<=x);assert(x<N);
 assert(1<=y);assert(y<N);
 for(int dx=0;dx<2;++dx)for(int dy=0;dy<2;++dy)assert(!secret[x+dx][y+dy]);
}
#else
  int verdict;
  scanf("%d", &verdict);
  if (verdict != 1) {
    exit(0);
  }
#endif
}

int f[1010][1010];

int main() {
  int numCases;
  scanf("%d", &numCases);
  for (; numCases--; ) {
    scanf("%d", &N);
#ifdef LOCAL
for(int x=0;x<=N+1;++x)for(int y=0;y<=N+1;++y)secret[x][y]=0;
for(int x=1;x<=N;++x){
 static char buf[1010];
 scanf("%s",buf);
cerr<<buf<<endl;
 for(int y=1;y<=N;++y)secret[x][y]=buf[y-1]-'0';
}
int numAnss=0;
for(int x=0;x<=N;++x)for(int y=0;y<=N;++y){
 int cnt=0;
 for(int dx=0;dx<2;++dx)for(int dy=0;dy<2;++dy)cnt+=secret[x+dx][y+dy];
 if(cnt==0)++numAnss;
}
assert(numAnss==((N%2!=0)?0:1));
#endif
    
    for (int x = 0; x <= N + 1; ++x) for (int y = 0; y <= N + 1; ++y) {
      cache[x][y] = -1;
    }
    
    if (N % 2 != 0) {
      Answer(-1, -1);
    } else {
      /*
        (x-1,y-1)-(x-1,y  )
            |  (x,y)  |    
        (x  ,y-1)-(x  ,y  )
      */
      // empty corner in [x0, y0] * [x1, y1]
      int x0 = 0, x1 = N;
      int y0 = 0, y1 = N;
      // int x0 = 1, x1 = N - 1;
      // int y0 = 1, y1 = N - 1;
      for (; x0 <= x1 && y0 <= y1; ) {
// cerr<<"["<<x0<<", "<<x1<<"] * ["<<y0<<", "<<y1<<"]"<<endl;
        const bool cutX = (x1 - x0 >= y1 - y0);
        const int mid = cutX ? ((x0 + x1) / 2) : ((y0 + y1) / 2);
        const int w0 = cutX ? y0 : x0;
        const int w1 = cutX ? y1 : x1;
        
        for (int w = w0; w <= w1; ++w) {
          // corner (x, y) (on mid line) is empty?
          int x, y;
          if (cutX) {
            x = mid;
            y = w;
          } else {
            x = w;
            y = mid;
          }
          if ([&]() -> bool {
            for (int dx = 0; dx < 2; ++dx) for (int dy = 0; dy < 2; ++dy) {
              if (!(1 <= x + dx && x + dx <= N && 1 <= y + dy && y + dy <= N)) {
                return false;
              }
            }
            for (int dx = 0; dx < 2; ++dx) for (int dy = 0; dy < 2; ++dy) {
              if (A(x + dx, y + dy)) {
                return false;
              }
            }
            return true;
          }()) {
            Answer(x, y);
            goto found;
          }
        }
        
        if ( cutX && !(x0 <= mid - 1)) { x0 = mid + 1; continue; }
        if (!cutX && !(y0 <= mid - 1)) { y0 = mid + 1; continue; }
        if ( cutX && !(mid + 1 <= x1)) { x1 = mid - 1; continue; }
        if (!cutX && !(mid + 1 <= y1)) { y1 = mid - 1; continue; }
        
        // parity of (# corner) on (x0, y0)'s side
        const int x2 = cutX ? (mid - 1) : x1;
        const int y2 = cutX ? y1 : (mid - 1);
        int cnt = (x2 - x0 + 1) * (y2 - y0 + 1);
        // surrounding ships
        auto at = [&](int x, int y) -> int {
          return (1 <= x && x <= N && 1 <= y && y <= N) ? A(x, y) : 0;
        };
        for (int y = y0; y <= y2; ++y) f[x0][y] = 0;
        for (int y = y0; y <= y2; ++y) f[x2][y] = 0;
        for (int x = x0; x <= x2; ++x) f[x][y0] = 0;
        for (int x = x0; x <= x2; ++x) f[x][y2] = 0;
        for (int y = y0; y <= y2; ++y) if (at(x0    , y) || at(x0    , y + 1)) f[x0][y] = 1;
        for (int y = y0; y <= y2; ++y) if (at(x2 + 1, y) || at(x2 + 1, y + 1)) f[x2][y] = 1;
        for (int x = x0; x <= x2; ++x) if (at(x, y0    ) || at(x + 1, y0    )) f[x][y0] = 1;
        for (int x = x0; x <= x2; ++x) if (at(x, y2 + 1) || at(x + 1, y2 + 1)) f[x][y2] = 1;
// cerr<<"f = "<<endl;for(int x=0;x<=N;++x)pv(f[x],f[x]+N+1);
        for (int y = y0; y <= y2; ++y) { cnt -= f[x0][y]; f[x0][y] = 0; }
        for (int y = y0; y <= y2; ++y) { cnt -= f[x2][y]; f[x2][y] = 0; }
        for (int x = x0; x <= x2; ++x) { cnt -= f[x][y0]; f[x][y0] = 0; }
        for (int x = x0; x <= x2; ++x) { cnt -= f[x][y2]; f[x][y2] = 0; }
// cerr<<"  ["<<x0<<", "<<x2<<"] * ["<<y0<<", "<<y2<<"]: "<<cnt<<endl;
        if (cnt & 1) {
          (cutX ? x1 : y1) = mid - 1;
        } else {
          (cutX ? x0 : y0) = mid + 1;
        }
      }
      assert(false);
     found:{}
    }
  }
  return 0;
}

詳細信息

Test #1:

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

input:

2
3
1
4
0
0
1
0
0
0
1

output:

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

result:

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

Test #2:

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

input:

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

output:

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

result:

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

Test #3:

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

input:

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

output:

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

result:

ok max_C=3.50, avg_C=2.56 (100 test cases)

Test #4:

score: 0
Accepted
time: 2ms
memory: 5812kb

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: 46ms
memory: 5812kb

input:

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

output:

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

result:

ok max_C=5.14, avg_C=4.04 (100 test cases)

Test #6:

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

input:

100
31
1
23
1
62
1
0
1
0
1
1
1
1
1
1
1
0
1
0
1
0
1
0
0
0
1
0
0
0
1
0
0
0
1
0
0
1
1
0
0
0
1
0
0
1
0
0
1
0
0
1
0
1
0
1
0
1
0
0
1
0
1
0
0
0
1
0
0
1
0
0
1
0
0
1
0
1
0
0
1
0
0
0
1
0
0
1
0
0
1
0
0
1
0
1
0
1
1
0
1
0
1
1
0
0
1
0
0
1
0
0
0
1
0
0
0
1
0
1
0
0
1
0
0
1
0
0
1
0
0
1
0
0
1
0
0
1
0
0
1
0
0
1
0
0
1
0...

output:

! -1 -1
! -1 -1
? 31 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
? 32 18
? 32 19
? 31 20
? 31 21
? 32 20
? 32 21
? 31 22
? 31 23
? 32 22
? 32 23
? 31 24
? 31 25
? 32 24
? 31 26
? 31 27
? 31 28
? 32 27
? 32 ...

result:

ok max_C=5.33, avg_C=1.79 (100 test cases)

Test #7:

score: 0
Accepted
time: 64ms
memory: 5808kb

input:

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

output:

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

result:

ok max_C=5.34, avg_C=4.43 (100 test cases)

Test #8:

score: 0
Accepted
time: 50ms
memory: 6048kb

input:

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

output:

? 25 1
? 25 2
? 25 3
? 25 4
? 25 5
? 25 6
? 25 7
? 25 8
? 25 9
? 25 10
? 25 11
? 25 12
? 26 11
? 26 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
? 26 25
? 26 26
? 25 27
? 25 28
? 25 29
? 25 30
? 25 31
? 25 32
? 26 31
? 26 32
? 25 ...

result:

ok max_C=5.34, avg_C=4.20 (100 test cases)

Test #9:

score: 0
Accepted
time: 52ms
memory: 10948kb

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

output:

? 250 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
? 251 24
? 251 25
? 250 26
? 250 27
? 251 26
? 251 27
? 250 28
? 250 29
? 251 28
? 2...

result:

ok max_C=5.50, avg_C=4.63 (10 test cases)

Test #10:

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

input:

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

output:

! -1 -1
? 500 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
? 50...

result:

ok max_C=5.65, avg_C=2.79 (10 test cases)

Test #11:

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

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: 61ms
memory: 11512kb

input:

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

output:

? 500 1
? 500 2
? 500 3
? 501 2
? 501 3
? 500 4
? 500 5
? 500 6
? 500 7
? 500 8
? 500 9
? 500 10
? 500 11
? 501 10
? 501 11
? 500 12
? 500 13
? 500 14
? 500 15
? 500 16
? 500 17
? 500 18
? 500 19
? 501 18
? 501 19
? 500 20
? 500 21
? 501 20
? 501 21
? 500 22
? 500 23
? 501 22
? 501 23
? 500 24
? 500...

result:

ok max_C=5.25, avg_C=4.89 (5 test cases)

Test #13:

score: 0
Accepted
time: 39ms
memory: 11748kb

input:

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

output:

? 500 1
? 500 2
? 501 1
? 500 3
? 501 2
? 501 3
? 500 4
? 500 5
? 501 4
? 500 6
? 501 5
? 500 7
? 501 6
? 500 8
? 501 7
? 501 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
? 501 21
? 501 22
? 500 23
? 500 24
? 500 25
? ...

result:

ok max_C=4.78, avg_C=4.42 (5 test cases)

Test #14:

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

input:

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

output:

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

result:

ok max_C=5.72, avg_C=4.37 (5 test cases)

Test #15:

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

input:

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

output:

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

result:

ok max_C=5.53, avg_C=5.05 (5 test cases)

Test #16:

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

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

output:

? 500 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
? 5...

result:

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

Test #17:

score: 0
Accepted
time: 46ms
memory: 11452kb

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

output:

? 500 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
? 5...

result:

ok max_C=5.57, avg_C=4.93 (5 test cases)

Test #18:

score: 0
Accepted
time: 41ms
memory: 11560kb

input:

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

output:

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

result:

ok max_C=5.16, avg_C=4.75 (5 test cases)

Test #19:

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

input:

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

output:

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

result:

ok max_C=5.01, avg_C=4.65 (5 test cases)

Test #20:

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

input:

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

output:

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

result:

ok max_C=5.51, avg_C=4.96 (5 test cases)