QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#286261#7942. $K$ Subsequenceshos_lyricAC ✓287ms6644kbC++142.9kb2023-12-17 14:27:002023-12-17 14:27:00

Judging History

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

  • [2023-12-17 14:27:00]
  • 评测
  • 测评结果:AC
  • 用时:287ms
  • 内存:6644kb
  • [2023-12-17 14:27:00]
  • 提交

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 <random>
#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; }
#define COLOR(s) ("\x1b[" s "m")


int N, K;
vector<int> A;

vector<int> ks;
bool check(int t) {
  ks.assign(N, -1);
  priority_queue<pair<int, int>> que;
  priority_queue<int> queT;
  for (int k = 0; k < K; ++k) {
    queT.push(k);
  }
  for (int i = 0; i < N; ++i) {
    if (A[i] > 0) {
      if (queT.size()) {
        const int k = queT.top();
        queT.pop();
        if (t == 0) return false;
        ks[i] = k;
        que.emplace(t - 1, k);
      } else {
        const int f = que.top().first;
        const int k = que.top().second;
        que.pop();
        if (f == 0) return false;
        ks[i] = k;
        que.emplace(f - 1, k);
      }
    } else {
      if (que.size()) {
        const int f = que.top().first;
        const int k = que.top().second;
        que.pop();
        ks[i] = k;
        if (f + 1 == t) {
          queT.push(k);
        } else {
          que.emplace(f + 1, k);
        }
      } else if (queT.size()) {
        const int k = queT.top();
        queT.pop();
        ks[i] = k;
        queT.push(k);
      }
    }
  }
// cerr<<"check "<<t<<": "<<ks<<endl;
  return true;
}

int main() {
  for (int numCases; ~scanf("%d", &numCases); ) { for (int caseId = 1; caseId <= numCases; ++caseId) {
    scanf("%d%d", &N, &K);
    A.resize(N);
    for (int i = 0; i < N; ++i) {
      scanf("%d", &A[i]);
    }
    
    int lo = -1, hi = N;
    for (; lo + 1 < hi; ) {
      const int mid = (lo + hi) / 2;
      (check(mid) ? hi : lo) = mid;
    }
// cerr<<"hi = "<<hi<<endl;
    check(hi);
    for (int i = 0; i < N; ++i) {
      if (i) printf(" ");
      printf("%d", ks[i] + 1);
    }
    puts("");
  }
#ifndef LOCAL
  break;
#endif
  }
  return 0;
}

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

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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:

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

result:

ok Correct (5 test cases)

Test #2:

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

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

result:

ok Correct (1 test case)

Test #4:

score: 0
Accepted
time: 177ms
memory: 4672kb

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 152 152 152 152 152 152 152 152 152 152 152 152 152 152 152 152 152 152 152 152 152 152 152 151 152 151 152 151 150 152 151 150 152 152 152 152 152 151 152 151 152 152 152 152 152 152 152 152 152 151 152 151 152 151 152 152 152 152 152 152 152 152 152 152 152 152 152 151 152 152 152 151 150 149 ...

result:

ok Correct (1 test case)

Test #5:

score: 0
Accepted
time: 175ms
memory: 4764kb

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 136 135 134 133 132 136 136 136 135 136 136 136 135 136 135 136 135 131 130 129 136 136 136 135 136 136 136 135 136 135 136 136 134 136 136 136 135 134 128 127 126 136 135 134 133 136 136 132 131 130 129 128 127 126 136 135 134 136 136 133 132 136 136 131 130 129 128 136 135 136 136 136 136 134 ...

result:

ok Correct (1 test case)

Test #6:

score: 0
Accepted
time: 231ms
memory: 5476kb

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:

86240 86239 86240 86240 86238 86237 86236 86235 86234 86240 86240 86233 86240 86240 86240 86239 86238 86240 86239 86238 86232 86231 86230 86229 86240 86240 86228 86227 86226 86225 86240 86240 86240 86239 86238 86237 86236 86235 86234 86233 86240 86240 86232 86240 86240 86231 86230 86229 86240 86239 ...

result:

ok Correct (1 test case)

Test #7:

score: 0
Accepted
time: 287ms
memory: 6644kb

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:

196586 196586 196586 196586 196586 196586 196586 196586 196586 196586 196586 196586 196586 196586 196586 196586 196586 196586 196586 196586 196586 196586 196586 196586 196586 196585 196584 196586 196585 196584 196586 196586 196586 196586 196586 196585 196586 196586 196586 196586 196586 196586 196584...

result:

ok Correct (1 test case)

Test #8:

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

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:

32664 32663 32662 32664 32664 32661 32660 32664 32664 32659 32658 32664 32663 32664 32664 32662 32664 32663 32662 32664 32663 32664 32664 32664 32663 32657 32664 32663 32662 32664 32664 32661 32660 32659 32658 32664 32664 32664 32664 32657 32664 32664 32664 32664 32663 32664 32663 32664 32664 32664 ...

result:

ok Correct (2 test cases)

Test #9:

score: 0
Accepted
time: 49ms
memory: 4588kb

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:

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

result:

ok Correct (2 test cases)

Test #10:

score: 0
Accepted
time: 176ms
memory: 4704kb

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 248 248 248 248 248 248 248 248 247 248 248 248 247 248 248 248 248 248 248 248 248 248 248 248 248 248 248 248 248 248 248 248 248 248 248 248 248 247 246 245 248 247 246 245 248 247 246 245 244 248 247 248 248 246 245 248 248 244 248 248 248 248 248 247 248 247 248 248 247 248 ...

result:

ok Correct (2 test cases)

Test #11:

score: 0
Accepted
time: 152ms
memory: 4900kb

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: 40ms
memory: 4668kb

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: 142ms
memory: 4536kb

input:

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

output:

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

result:

ok Correct (3 test cases)

Test #14:

score: 0
Accepted
time: 76ms
memory: 4384kb

input:

4
25729 81
-1 -1 -1 -1 1 -1 -1 -1 -1 -1 -1 -1 -1 1 -1 1 -1 -1 -1 1 -1 -1 1 -1 1 1 1 -1 -1 1 1 -1 1 -1 -1 1 -1 -1 -1 1 -1 1 -1 -1 -1 -1 -1 -1 1 1 -1 -1 1 -1 1 1 1 1 1 1 -1 1 1 1 -1 -1 -1 1 1 1 1 1 1 1 -1 -1 -1 -1 1 -1 -1 -1 -1 1 -1 1 -1 1 1 -1 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:

81 81 81 81 81 81 81 81 81 81 81 81 81 81 81 81 81 81 81 81 81 81 81 81 81 80 79 81 80 81 80 81 81 81 80 81 81 79 81 81 81 81 81 81 81 81 81 81 81 80 81 80 81 81 81 80 79 78 77 76 81 81 75 74 81 80 79 81 80 79 73 72 71 70 81 80 79 78 81 81 77 76 75 81 81 81 81 81 80 81 81 81 81 79 81 80 81 80 78 77 ...

result:

ok Correct (4 test cases)

Test #15:

score: 0
Accepted
time: 157ms
memory: 4660kb

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

result:

ok Correct (5 test cases)

Test #16:

score: 0
Accepted
time: 96ms
memory: 4436kb

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 4795 4795 4795 4795 4794 4795 4795 4793 4792 4791 4795 4795 4795 4794 4793 4792 4791 4795 4795 4795 4795 4795 4795 4795 4795 4795 4795 4795 4795 4795 4795 4794 4793 4792 4795 4795 4795 4795 4791 4790 4795 4794 4795 4795 4795 4794 4789 4795 4795 4788 4787 4786 4795 4795 4795 4795 4795 4795 ...

result:

ok Correct (6 test cases)

Test #17:

score: 0
Accepted
time: 42ms
memory: 4288kb

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: 155ms
memory: 4308kb

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 106 106 106 106 106 106 106 105 104 106 105 106 105 103 102 101 106 105 106 105 106 105 104 106 105 106 105 103 102 101 106 106 105 106 106 104 103 106 105 104 106 105 104 102 101 100 99 98 106 106 106 106 106 105 106 106 106 106 106 106 106 105 106 106 97 106 106 106 105 104 106 105...

result:

ok Correct (8 test cases)

Test #19:

score: 0
Accepted
time: 76ms
memory: 3880kb

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: 153ms
memory: 4372kb

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:

1596 1595 1594 1596 1596 1593 1592 1596 1595 1594 1596 1595 1596 1595 1593 1596 1596 1596 1596 1592 1596 1596 1596 1596 1596 1596 1596 1596 1596 1595 1596 1596 1596 1595 1596 1596 1595 1596 1596 1596 1595 1596 1596 1596 1596 1595 1596 1595 1596 1595 1594 1593 1592 1596 1595 1596 1595 1596 1596 1591 ...

result:

ok Correct (10 test cases)

Test #21:

score: 0
Accepted
time: 66ms
memory: 4000kb

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 29 29 29 28 29 28 29 29 29 29 29 28 27 26 25 24 29 28 29 28 29 29 29 28 27 29 29 26 29 28 27 26 29 29 23 29 29 29 29 22 21 29 28 27 26 25 29 28 29 29 27 29 28 29 28 29 28 29 28 29 28 29 29 27 24 29 29 23 22 29 28 27 26 25 29 28 29 29 27 26 25 21 29 29 29 29 28 27 26 25 29 29 24 23 29 29 22 ...

result:

ok Correct (100 test cases)

Test #22:

score: 0
Accepted
time: 70ms
memory: 4160kb

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 2314 2314 2314 2314 2313 2312 2314 2314 2311 2310 2309 2314 2314 2314 2313 2314 2314 2312 2311 2314 2314 2310 2...

result:

ok Correct (101 test cases)

Test #23:

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

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 7064 7063 7064 7063 7064 7064 7064 7063 7062 7061 7060 7064 7063 7064 7064 7064 7064 7064 7063 7059 7064 7063 7062 7064 7064 7064 7063 7062 7058 7064 7063 7062 7061 7064 7063 7062 7064 7063 7064 7063 7064 7064 7064 7064 7064 7063 7064 7064 7062 7064 7064 7064 7063 7064 7063 7064 7063 7062 ...

result:

ok Correct (102 test cases)

Test #24:

score: 0
Accepted
time: 69ms
memory: 3928kb

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:

404 404 404 404 404 404 404 404 404 403 402 404 404 401 404 403 404 404 404 404 404 404 402 404 403 402 400 404 403 404 403 399 404 404 404 403 404 404 404 404 404 404 404 403 398 397 396 395 404 403 404 404 402 404 403 402 394 393 392 404 403 404 403 391 390 404 403 402 404 404 404 404 404 403 402 ...

result:

ok Correct (103 test cases)

Test #25:

score: 0
Accepted
time: 66ms
memory: 3992kb

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:

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

result:

ok Correct (104 test cases)

Test #26:

score: 0
Accepted
time: 71ms
memory: 3916kb

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:

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

result:

ok Correct (105 test cases)

Test #27:

score: 0
Accepted
time: 37ms
memory: 3812kb

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

result:

ok Correct (1001 test cases)

Test #29:

score: 0
Accepted
time: 44ms
memory: 3808kb

input:

1002
182 6
1 1 1 1 -1 -1 1 -1 -1 1 1 -1 1 1 -1 1 1 1 1 1 -1 -1 -1 -1 1 -1 1 1 1 -1 -1 1 1 1 1 -1 1 1 -1 -1 -1 -1 -1 1 -1 -1 1 1 -1 -1 -1 1 -1 1 -1 -1 -1 1 1 1 -1 1 1 1 1 -1 -1 -1 -1 -1 1 -1 1 -1 1 1 -1 -1 1 1 1 1 -1 1 1 -1 -1 -1 -1 1 1 1 1 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:

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

result:

ok Correct (1002 test cases)

Test #30:

score: 0
Accepted
time: 44ms
memory: 3760kb

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:

16 16 16 16 15 14 16 15 14 16 16 16 15 14 16 15 14 16 16 15 14 16 16 16 16 13 16 15 14 13 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 15 14 16 16 13 12 16 15 14 13 16 15 16 16 14 13 11 10 16 15 16 15 16 15 14 16 16 13 12 11 10 16 16 16 16 16 15 14 13 16 15 16 15
3 3 3 3 2 3 2 3...

result:

ok Correct (1003 test cases)

Test #31:

score: 0
Accepted
time: 45ms
memory: 3796kb

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 257 256 255 254 253 252 257 256 257 256 257 256 255 257 257 254 257 257 257 257 253 252 257 256 255 254 253 252 257 257 251 257 257 257 257 257 257 250 257 257 257 257 249 248 257 257 247 257 256 257 257 257 256 257 256 255 257 257 257 257 257 257 257 256 255 257 257 246 245 257 256 257 256 257 ...

result:

ok Correct (1004 test cases)

Test #32:

score: 0
Accepted
time: 40ms
memory: 3816kb

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

result:

ok Correct (9995 test cases)

Test #34:

score: 0
Accepted
time: 40ms
memory: 4040kb

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

result:

ok Correct (9996 test cases)

Test #35:

score: 0
Accepted
time: 36ms
memory: 4072kb

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 9 8 9 9 7 9 9 9 9 6 5 4 3 2
1
20 20 20 20 20 20 20 20 20 20 20 20 20 20 19 20 20 18 20 19 18 20 20 19 20 20 20 19 20 20 20 20 19 18 17 16 20
2 2 2 2 2 2 1 2 1 2 1 2 1 2 2 2 2 1 1 2 2 2 2 1 1 2 2 2 2 2 2 1 2 1 2 2 2 2 1 2 2 1 2 1 2 1 2 1 2 1 2 2 2 1 2 1 2 2 2 2 2 2 2 2
2 1 2 1 2 2 2 1 2 1 2 2 2 1 1...

result:

ok Correct (9997 test cases)

Test #36:

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

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 1
12 2
-1 -1 -1 1 -1 -1 1 -1 1 1 -1 1
8 6
-1 1 1 -1 1 1 1 1
3 1
1 1 -1
12 1
1 -1 1 1 1 -1 1 -1 -1 1 1 -1
3 1
1 -1 -1
77 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 -...

output:

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

result:

ok Correct (9998 test cases)

Test #37:

score: 0
Accepted
time: 40ms
memory: 3784kb

input:

9999
65 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
12 3
1 1 1 1 -1 -1 -1 -1 1 1 -1 -1
75 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...

output:

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

result:

ok Correct (9999 test cases)

Test #38:

score: 0
Accepted
time: 33ms
memory: 3784kb

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

result:

ok Correct (10000 test cases)

Extra Test:

score: 0
Extra Test Passed