QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#136574#6718. Масив i частковi сумиhos_lyric100 ✓75ms21372kbC++148.7kb2023-08-09 08:12:092023-08-09 08:12:10

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-08-09 08:12:10]
  • 评测
  • 测评结果:100
  • 用时:75ms
  • 内存:21372kb
  • [2023-08-09 08:12:09]
  • 提交

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; }


template <class Func> struct MaxLiChaoTree {
  using TX = typename Func::TX;
  using TY = typename Func::TY;
  struct Node {
    int l, r;
    Func f;
  };
  vector<Node> nodes;

  const TX XL, XR;
  int rt;
  MaxLiChaoTree() : XL(0), XR(0), rt(-1) {}
  // [L, R)
  MaxLiChaoTree(TX XL_, TX XR_) : XL(XL_), XR(XR_), rt(-1) {}
  bool empty() const {
    return (!~rt);
  }
  // Add f to the whole [L, R).
  void add(Func f) {
    int *u = &rt;
    for (TX xL = XL, xR = XR; ; ) {
      if (!~*u) { *u = nodes.size(); nodes.push_back({-1, -1, f}); return; }
      const TX xMid = xL + (xR - xL) / 2;
      if (nodes[*u].f(xMid) < f(xMid)) swap(nodes[*u].f, f);
      if (xL + 1 == xR) return;
      if (nodes[*u].f(xL) < f(xL)) {
        u = &nodes[*u].l; xR = xMid;
      } else if (nodes[*u].f(xR) < f(xR)) {
        u = &nodes[*u].r; xL = xMid;
      } else {
        return;
      }
    }
  }
  // Get max at x.
  TY operator()(TX x) const {
    assert(XL <= x); assert(x < XR);
    assert(!empty());
    int u = rt;
    TY maxY = nodes[u].f(x);
    for (TX xL = XL, xR = XR; ; ) {
      const TX xMid = xL + (xR - xL) / 2;
      if (x < xMid) {
        u = nodes[u].l; xR = xMid;
      } else {
        u = nodes[u].r; xL = xMid;
      }
      if (!~u) break;
      const TY y = nodes[u].f(x);
      if (maxY < y) maxY = y;
    }
    return maxY;
  }
};

// y = p x + q
struct Line {
  using TX = Int;
  using TY = pair<Int, int>;
  Int p, q;
  int id;
  Line(Int p_, Int q_, int id_) : p(p_), q(q_), id(id_) {}
  TY operator()(TX x) const {
    return make_pair(p * x + q, id);
  }
};


using Op = pair<int, pair<int, int>>;
inline Op O(int t, int l = -1, int r = -1) {
  return Op(t, make_pair(l, r));
}

int N, Subtask;
vector<Int> A;

bool isDone(const vector<Int> &as) {
  for (int i = 0; i < N; ++i) if (as[i] < 0) return false;
  return true;
}
void apply(vector<Int> &as, const Op &op) {
  const int l = op.second.first;
  const int r = op.second.second;
  switch (op.first) {
    case 1: {
      for (int i = 0; i < N; ++i) as[i] *= -1;
    } break;
    case 2: {
      for (int i = l + 1; i < r; ++i) as[i] += as[i - 1];
    } break;
    case 3: {
      for (int i = r - 1; --i >= l; ) as[i] += as[i + 1];
    } break;
    default: assert(false);
  }
}
bool check(const vector<Op> &ops) {
  auto as = A;
  for (const Op &op : ops) apply(as, op);
  return isDone(as);
}
void reverse(vector<Op> &ops) {
  for (Op &op : ops) if (op.first != 1) {
    const int l = op.second.first;
    const int r = op.second.second;
    op.first ^= 2 ^ 3;
    op.second = make_pair(N - r, N - l);
  }
}

vector<Op> solve() {
  // 0?
  if (check({})) return {};
  
  // 1?
  for (const Op op : {O(1), O(2, 0, N), O(3, 0, N)}) {
    if (check({op})) return {op};
  }
  
  // 2?
  for (const Op op : {O(2, 0, N), O(3, 0, N)}) {
    if (check({O(1), op})) return {O(1), op};
  }
  for (int dir = 0; dir < 2; ++dir) {
    vector<Int> B(N + 1), C(N + 2);
    for (int i = 0; i < N; ++i) B[i + 1] = B[i] + A[i];
    for (int i = 0; i <= N; ++i) C[i + 1] = C[i] + B[i];
    
    // O(2, 0, r), O(2, 0, N)
    /*
      0 <= i <= r: (C[i+1] - C[1])
      r <= i <= N: (C[r+1] - C[1]) + (B[i] - B[r])
    */
    {
      vector<Int> head(N + 1);
      head[0] = C[1] - C[1];
      for (int r = 1; r <= N; ++r) head[r] = min(head[r - 1], C[r + 1] - C[1]);
      int im = N;
      for (int r = N; r >= 0; --r) {
        if (B[im] > B[r]) im = r;
        if (head[r] >= 0 &&
            (C[r + 1] - C[1]) + (B[im] - B[r]) >= 0) {
          vector<Op> ops{O(2, 0, r), O(2, 0, N)};
          assert(check(ops));
          if (dir) reverse(ops);
          return ops;
        }
      }
    }
    
    // O(3, l, r), O(2, 0, N)
    /*
      0 <= i <= l: B[i]
      l <= i <= r: B[l] + (i - l) B[r] - (C[i] - C[l])
      r <= i <= N: B[l] + (r - l) B[r] - (C[r] - C[l]) + (B[i] - B[r])
    */
    {
      auto brute = [&]() -> pair<int, int> {
        for (int l = 0; l <= N; ++l) for (int r = l; r <= N; ++r) {
          if (check({O(3, l, r), O(2, 0, N)})) return make_pair(l, r);
        }
        return make_pair(-1, -1);
      };
      auto slow = [&]() -> pair<int, int> {
        vector<Int> head(N + 1);
        head[0] = B[0];
        for (int l = 1; l <= N; ++l) head[l] = min(head[l - 1], B[l]);
        for (int r = N; r >= 0; --r) {
          int im0 = r, im1 = r;
          for (int i = r; i <= N; ++i) if (B[im1] > B[i]) im1 = i;
          for (int l = r; l >= 0; --l) {
            if (im0 * B[r] - C[im0] > l * B[r] - C[l]) im0 = l;
            if (head[l] >= 0 &&
                B[l] + (im0 - l) * B[r] - (C[im0] - C[l]) >= 0 &&
                B[l] + (r - l) * B[r] - (C[r] - C[l]) + (B[im1] - B[r]) >= 0) {
              return make_pair(l, r);
            }
          }
        }
        return make_pair(-1, -1);
      };
      auto fast = [&]() -> pair<int, int> {
        int badL = N + 1;
        for (int l = 0; l <= N; ++l) if (B[l] < 0) {
          badL = l;
          break;
        }
        vector<Int> tail(N + 1);
        tail[N] = B[N];
        for (int r = N; --r >= 0; ) tail[r] = min(B[r], tail[r + 1]);
        const Int minB = *min_element(B.begin(), B.end());
        const Int maxB = *max_element(B.begin(), B.end());
        // f(B[r]) = B[l] - (l B[r] - C[l])
        // g(B[r]) = - (i B[r] - C[i])
        MaxLiChaoTree<Line> f(minB, maxB + 1), g(minB, maxB + 1);
        for (int r = 0; r <= N; ++r) {
          {
            const int l = r;
            if (l < badL) f.add(Line(-l, B[l] + C[l], l));
          }
          {
            const int i = r;
            g.add(Line(-i, C[i], i));
          }
          if (!f.empty()) {
            const int l = f(B[r]).second;
#ifdef LOCAL
for(int i=0;i<=l;++i)assert(B[l]+(i-l)*B[r]-(C[i]-C[l])>=0);
for(int i=l;i<=r&&i<badL;++i)assert(B[l]+(i-l)*B[r]-(C[i]-C[l])>=0);
#endif
            if (B[l] - l * B[r] + C[l] - g(B[r]).first >= 0 &&
                B[l] + (r - l) * B[r] - (C[r] - C[l]) + (tail[r] - B[r]) >= 0) {
              return make_pair(l, r);
            }
          }
        }
        return make_pair(-1, -1);
      };
      // const auto res = slow();
      const auto res = fast();
#ifdef LOCAL
const auto brt=brute();
if(~brt.first&&!~res.first){
 cerr<<A<<" "<<B<<" "<<C<<": "<<brt<<" "<<slow()<<" "<<res<<endl;
 assert(false);
}
#endif
      if (~res.first) {
        vector<Op> ops{O(3, res.first, res.second), O(2, 0, N)};
        assert(check(ops));
        if (dir) reverse(ops);
        return ops;
      }
    }
    
    reverse(A.begin(), A.end());
  }
  
  // 3
  {
    vector<Op> ops;
    vector<Int> B(N + 1, 0);
    for (int i = 0; i < N; ++i) B[i + 1] = B[i] + A[i];
    int i0 = 0, i1 = 0;
    for (int i = 0; i <= N; ++i) {
      if (B[i0] > B[i]) i0 = i;
      if (B[i1] < B[i]) i1 = i;
    }
    if (i0 > i1) {
      ops.push_back(O(1));
      swap(i0, i1);
    }
    ops.push_back(O(3, 0, i1));
    ops.push_back(O(2, 0, N));
    assert(check(ops));
    return ops;
  }
}

int main() {
  for (; ~scanf("%d%d", &N, &Subtask); ) {
    A.resize(N);
    for (int i = 0; i < N; ++i) {
      scanf("%lld", &A[i]);
    }
    
    const auto ans = solve();
    printf("%d\n", (int)ans.size());
    for (const Op &op : ans) {
      if (op.first == 1) {
        puts("1");
      } else {
        printf("%d %d %d\n", op.first, op.second.first + 1, op.second.second);
      }
    }
  }
  return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 14
Accepted

Test #1:

score: 14
Accepted
time: 12ms
memory: 6292kb

input:

200000 1
1 1 0 0 1 0 1 0 0 0 0 1 1 0 1 0 1 1 0 1 1 0 0 1 1 1 0 0 1 1 1 1 0 1 0 1 1 1 1 1 0 1 0 1 0 1 1 0 0 1 1 1 0 0 1 0 0 0 1 0 0 1 0 1 0 0 0 1 0 0 1 0 0 1 1 0 1 0 0 1 0 0 0 0 1 0 0 1 1 1 1 1 0 0 0 1 1 0 1 1 1 1 1 1 0 0 0 1 1 0 0 1 0 1 0 1 0 1 1 0 1 0 1 0 1 1 0 1 0 1 1 1 1 1 1 0 1 1 1 0 1 1 1 0 0 0...

output:

0

result:

ok OK: 0 operations

Test #2:

score: 0
Accepted
time: 13ms
memory: 6392kb

input:

200000 1
-1 0 0 0 -1 0 0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 0 0 -1 -1 0 -1 -1 0 0 0 -1 -1 0 -1 0 -1 0 -1 0 -1 -1 0 0 -1 -1 0 0 -1 -1 0 -1 -1 -1 -1 0 -1 -1 0 0 0 -1 0 -1 -1 -1 0 -1 -1 0 0 0 -1 -1 -1 -1 -1 0 0 -1 -1 0 -1 0 -1 0 -1 -1 -1 0 -1 -1 0 0 0 0 -1 -1 -1 0 0 -1 -1 -1 0 0 -1 -1 -1 0 0 -1 -1 -1 0 -...

output:

1
1

result:

ok OK: 1 operations

Test #3:

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

input:

200000 1
0 0 1 -1 1 1 -1 -1 0 1 -1 0 0 1 0 0 1 1 1 1 0 -1 -1 0 -1 -1 1 -1 1 1 1 1 -1 1 -1 1 1 0 -1 -1 0 1 0 0 0 0 1 1 -1 0 0 -1 -1 -1 0 0 0 1 1 1 -1 1 1 0 0 1 1 -1 1 0 0 1 1 1 1 -1 0 1 0 0 0 0 1 0 0 -1 0 -1 1 -1 0 1 -1 -1 0 0 0 -1 0 0 1 1 1 0 -1 0 1 1 1 0 1 0 0 0 -1 -1 0 -1 -1 1 -1 -1 1 1 0 1 1 1 -1...

output:

1
2 1 200000

result:

ok OK: 1 operations

Test #4:

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

input:

200000 1
-1 -1 -1 -1 0 1 0 -1 -1 0 -1 -1 1 0 0 -1 0 1 -1 0 -1 1 -1 0 1 1 0 1 1 1 0 0 1 -1 0 1 0 0 0 0 1 1 1 1 1 0 1 -1 1 1 0 -1 0 1 0 0 0 1 1 0 1 0 -1 -1 0 0 -1 -1 0 1 -1 -1 -1 0 1 0 0 -1 0 1 0 1 1 1 1 0 1 -1 -1 -1 0 0 0 -1 1 1 -1 -1 -1 1 0 0 -1 -1 0 -1 -1 -1 0 1 1 1 1 0 1 -1 -1 0 -1 0 0 0 -1 -1 -1 ...

output:

1
3 1 200000

result:

ok OK: 1 operations

Subtask #2:

score: 17
Accepted

Test #5:

score: 17
Accepted
time: 9ms
memory: 6260kb

input:

200000 2
1 1 0 0 1 0 1 0 1 1 0 1 1 1 1 0 0 0 1 1 0 0 0 1 1 0 1 0 0 0 0 0 1 0 1 0 0 1 0 1 1 1 0 0 1 1 0 0 0 0 0 0 1 1 0 1 1 0 1 0 1 0 1 1 1 0 0 1 0 0 1 1 1 1 0 0 0 0 1 1 0 0 0 1 1 0 1 0 1 1 0 0 0 0 1 1 0 1 1 1 1 0 0 0 0 1 0 0 1 0 0 0 1 1 1 0 0 1 1 0 1 1 0 1 1 1 0 0 1 0 0 0 0 0 1 1 0 0 0 1 1 0 1 0 1 0...

output:

0

result:

ok OK: 0 operations

Test #6:

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

input:

200000 2
0 0 -1 -1 0 -1 0 0 -1 -1 0 -1 -1 0 -1 0 -1 -1 -1 -1 -1 0 0 -1 0 -1 -1 0 0 -1 -1 -1 -1 -1 -1 -1 -1 0 0 -1 -1 0 -1 -1 -1 0 -1 0 -1 0 -1 0 0 0 0 0 0 0 0 0 0 -1 0 -1 0 -1 0 0 0 -1 -1 0 0 -1 -1 -1 0 -1 -1 0 -1 -1 -1 -1 0 -1 -1 -1 0 0 -1 0 0 0 -1 -1 -1 0 0 -1 -1 0 -1 -1 -1 -1 -1 -1 -1 0 0 0 -1 -1...

output:

1
1

result:

ok OK: 1 operations

Test #7:

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

input:

200000 2
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 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:

2
3 10032 52201
2 1 200000

result:

ok OK: 2 operations

Test #8:

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

input:

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

output:

2
2 167935 199997
3 1 200000

result:

ok OK: 2 operations

Test #9:

score: 0
Accepted
time: 75ms
memory: 16568kb

input:

200000 2
1 1 0 0 1 0 0 0 0 0 0 0 1 0 0 -1 0 0 0 0 -1 0 -1 0 -1 0 0 0 0 -1 0 0 0 -1 0 0 0 -1 0 -1 0 0 0 0 0 0 0 -1 -1 1 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 -1 0 -1 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 -1 0 0 0 0 -1 0 0 0 1 0 0 -1 0 -1 0 0 0 0 0 -1 0 0 0 -1 -1 0 0 0 -1 0 -1 0 0 0 0 0 0 ...

output:

3
1
3 1 199995
2 1 200000

result:

ok OK: 3 operations

Test #10:

score: 0
Accepted
time: 13ms
memory: 9336kb

input:

200000 2
-1 0 1 -1 0 1 1 0 1 0 0 1 0 1 -1 1 1 -1 1 -1 -1 0 -1 -1 0 -1 0 0 0 1 1 0 -1 1 -1 0 1 0 1 -1 -1 -1 -1 1 -1 1 1 -1 1 1 -1 0 1 -1 0 -1 1 -1 0 -1 1 -1 0 1 1 1 0 -1 0 -1 -1 -1 -1 0 0 -1 1 -1 -1 0 1 -1 0 0 0 0 0 0 1 1 1 0 -1 0 -1 1 -1 1 -1 1 1 0 0 1 1 -1 1 1 -1 -1 1 0 -1 1 -1 0 0 0 -1 0 0 1 1 -1 ...

output:

2
3 1 1135
2 1 200000

result:

ok OK: 2 operations

Subtask #3:

score: 18
Accepted

Dependency #2:

100%
Accepted

Test #11:

score: 18
Accepted
time: 11ms
memory: 6268kb

input:

200000 3
0 1 1 0 0 1 0 1 0 0 1 1 1 0 0 1 1 1 0 0 1 1 0 0 1 0 0 0 1 0 0 1 1 0 0 0 1 0 0 0 1 1 0 1 1 1 0 0 0 0 1 1 0 1 1 0 0 0 0 1 1 0 0 1 0 0 1 0 1 1 1 0 0 1 0 0 0 0 1 1 0 1 0 0 1 1 0 1 0 1 0 0 0 0 0 1 1 0 0 1 0 1 0 1 0 0 0 0 1 1 0 0 1 0 1 1 0 1 1 0 1 1 0 1 1 1 0 1 1 1 1 0 1 1 1 1 1 1 1 1 0 1 0 0 1 0...

output:

0

result:

ok OK: 0 operations

Test #12:

score: 0
Accepted
time: 4ms
memory: 6352kb

input:

200000 3
0 -1 0 -1 -1 -1 0 0 -1 0 -1 -1 0 0 -1 0 0 -1 -1 -1 0 0 -1 -1 -1 0 -1 -1 0 0 -1 0 0 0 -1 -1 0 -1 0 0 0 -1 0 0 0 0 -1 0 0 0 0 0 -1 -1 -1 -1 0 -1 -1 0 0 0 -1 -1 -1 0 -1 -1 0 -1 0 -1 -1 -1 0 -1 0 -1 -1 0 -1 0 0 0 -1 -1 -1 -1 0 0 -1 -1 0 0 0 -1 0 0 -1 -1 0 0 -1 -1 0 0 0 0 0 -1 0 0 0 0 -1 -1 0 -1...

output:

1
1

result:

ok OK: 1 operations

Test #13:

score: 0
Accepted
time: 13ms
memory: 6316kb

input:

200000 3
-1 -1 -1 -1 1 -1 0 1 -1 0 -1 -1 -1 1 1 0 -1 0 1 -1 1 0 -1 0 0 1 -1 0 -1 0 0 -1 1 -1 1 1 -1 -1 0 -1 1 1 0 0 1 0 1 1 1 -1 0 -1 0 1 1 1 -1 -1 -1 1 -1 0 -1 0 1 -1 1 -1 -1 -1 1 0 1 1 -1 0 0 -1 1 -1 1 1 1 1 0 -1 1 -1 0 -1 -1 1 0 0 1 -1 1 -1 0 1 0 0 0 1 0 -1 -1 1 -1 -1 0 1 -1 1 1 0 0 1 0 1 0 1 1 -...

output:

1
3 1 200000

result:

ok OK: 1 operations

Test #14:

score: 0
Accepted
time: 15ms
memory: 10592kb

input:

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

output:

2
2 1 1667
2 1 193638

result:

ok OK: 2 operations

Test #15:

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

input:

200000 3
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 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:

2
3 13465 70916
2 1 200000

result:

ok OK: 2 operations

Test #16:

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

input:

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

output:

2
3 3 44502
2 1 200000

result:

ok OK: 2 operations

Test #17:

score: 0
Accepted
time: 57ms
memory: 16684kb

input:

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

output:

2
2 72290 168772
3 1 200000

result:

ok OK: 2 operations

Test #18:

score: 0
Accepted
time: 67ms
memory: 17360kb

input:

200000 3
1 1 1 0 0 0 0 0 0 0 -1 0 0 0 1 0 0 0 -1 0 -1 0 0 -1 0 -1 0 0 -1 0 0 0 0 0 -1 0 0 -1 0 0 -1 0 0 0 0 -1 0 -1 0 -1 0 -1 0 0 0 -1 0 0 1 0 0 0 1 0 0 0 0 0 0 -1 0 0 0 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 -1 0 0 0 -1 -1 0 0 0 -1 0 0 0 -1 0 0 0 0 0 -1 1 0 0 0 -1 0 -1 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 -1 0...

output:

3
1
3 1 199994
2 1 200000

result:

ok OK: 3 operations

Test #19:

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

input:

200000 3
0 -1 1 1 0 0 0 1 -1 0 1 0 -1 -1 1 -1 -1 0 -1 -1 -1 0 0 1 0 0 0 -1 0 1 -1 -1 0 0 1 1 1 0 -1 1 1 0 -1 0 -1 0 1 0 1 0 0 -1 -1 -1 0 1 -1 0 1 -1 0 0 0 0 1 0 1 1 0 -1 0 1 0 1 1 -1 -1 -1 0 0 1 0 0 -1 0 -1 1 0 0 -1 1 1 1 0 0 0 1 -1 1 -1 0 -1 1 -1 1 0 -1 1 -1 0 1 -1 1 -1 0 0 0 0 -1 1 0 1 0 -1 -1 1 -...

output:

2
3 1 75
2 1 200000

result:

ok OK: 2 operations

Subtask #4:

score: 7
Accepted

Dependency #3:

100%
Accepted

Test #20:

score: 7
Accepted
time: 12ms
memory: 6348kb

input:

200000 4
1 1 1 1 0 1 0 0 1 1 1 1 1 0 1 1 1 0 1 0 0 0 1 0 0 1 1 1 0 0 0 0 0 1 1 1 0 0 1 0 0 1 0 1 1 0 1 1 0 0 0 0 1 1 0 1 0 1 1 0 0 0 1 1 1 1 0 0 1 1 1 1 1 1 1 1 0 0 0 1 1 0 1 1 1 1 1 0 1 1 0 1 0 1 1 1 0 1 0 1 1 1 1 1 1 1 0 1 1 0 1 1 0 0 0 1 1 1 1 1 1 1 0 1 0 1 0 1 1 1 0 1 0 1 1 0 0 1 1 1 1 0 1 0 1 0...

output:

0

result:

ok OK: 0 operations

Test #21:

score: 0
Accepted
time: 13ms
memory: 6404kb

input:

200000 4
-1 -1 -1 -1 0 0 -1 -1 0 0 0 -1 0 0 -1 0 0 0 0 0 0 0 -1 0 0 -1 0 0 0 -1 0 -1 -1 0 0 -1 -1 0 -1 -1 -1 0 -1 0 -1 -1 -1 -1 0 -1 -1 -1 0 0 0 0 0 0 -1 0 -1 -1 0 -1 -1 0 0 -1 0 -1 0 0 -1 0 0 0 -1 0 0 -1 0 0 -1 0 -1 0 0 -1 -1 -1 -1 -1 -1 0 -1 -1 -1 0 0 -1 0 -1 0 -1 0 -1 0 0 -1 0 -1 -1 0 -1 -1 0 -1 ...

output:

1
1

result:

ok OK: 1 operations

Test #22:

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

input:

200000 4
-1 1 1 -1 1 -1 0 -1 -1 0 0 -1 0 1 1 1 1 -1 0 -1 -1 -1 -1 0 1 -1 -1 1 -1 0 1 1 0 1 1 0 0 0 0 1 -1 1 0 0 -1 -1 -1 1 1 1 1 0 1 1 0 0 0 0 1 -1 1 0 0 1 1 -1 -1 0 1 -1 1 1 0 1 0 1 1 0 1 -1 1 0 1 0 0 1 0 0 0 1 1 0 1 1 -1 -1 0 -1 0 1 0 -1 0 1 -1 1 1 0 -1 -1 0 0 0 -1 -1 1 1 0 1 0 0 0 -1 -1 -1 -1 0 1...

output:

1
3 1 200000

result:

ok OK: 1 operations

Test #23:

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

input:

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

output:

2
2 1 1632
2 1 192074

result:

ok OK: 2 operations

Test #24:

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

input:

200000 4
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 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:

2
3 11938 58982
2 1 200000

result:

ok OK: 2 operations

Test #25:

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

input:

200000 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 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -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 161939 188989
3 1 200000

result:

ok OK: 2 operations

Test #26:

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

input:

200000 4
1 1 1 1 1 1 1 1 1 1 -1 0 0 0 0 -1 0 -1 0 0 0 -1 0 1 -1 0 0 1 -1 0 0 0 0 -1 0 -1 -1 0 0 0 -1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 -1 0 0 -1 0 0 0 -1 0 -1 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 -1 0 0 -1 0 0 0 0 -1 0 -1 0 0 -1 0 0 -1 0 0 0 0 -1 0 0 -1 0 0...

output:

3
1
3 1 199987
2 1 200000

result:

ok OK: 3 operations

Test #27:

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

input:

200000 4
0 -1 0 0 0 -1 1 1 1 0 1 1 1 -1 -1 -1 -1 -1 1 0 1 1 0 -1 0 -1 0 1 -1 0 -1 0 0 -1 1 1 -1 1 0 0 1 1 0 0 0 1 0 -1 0 -1 -1 -1 1 0 0 1 0 -1 1 1 1 1 1 0 -1 1 -1 1 1 1 0 -1 -1 0 1 1 1 1 0 0 0 0 -1 1 -1 1 0 1 -1 -1 0 1 1 -1 -1 0 0 -1 1 1 1 1 1 0 -1 0 -1 1 -1 1 0 0 1 0 -1 0 1 -1 1 0 1 1 -1 1 1 1 0 1 ...

output:

2
3 1 70
2 1 200000

result:

ok OK: 2 operations

Subtask #5:

score: 7
Accepted

Test #28:

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

input:

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

output:

2
2 1 202
2 1 2891

result:

ok OK: 2 operations

Test #29:

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

input:

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

output:

2
2 1 191
2 1 2847

result:

ok OK: 2 operations

Test #30:

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

input:

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

output:

2
2 1 200
2 1 2981

result:

ok OK: 2 operations

Test #31:

score: 0
Accepted
time: 1ms
memory: 3904kb

input:

3000 5
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 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:

2
2 1 1516
2 1 3000

result:

ok OK: 2 operations

Test #32:

score: 0
Accepted
time: 1ms
memory: 3884kb

input:

3000 5
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 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:

2
2 1 1515
2 1 3000

result:

ok OK: 2 operations

Subtask #6:

score: 19
Accepted

Dependency #5:

100%
Accepted

Test #33:

score: 19
Accepted
time: 8ms
memory: 10656kb

input:

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

output:

2
2 1 1626
2 1 191855

result:

ok OK: 2 operations

Test #34:

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

input:

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

output:

2
2 1 1648
2 1 191982

result:

ok OK: 2 operations

Test #35:

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

input:

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

output:

2
2 1 1629
2 1 193538

result:

ok OK: 2 operations

Test #36:

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

input:

200000 6
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 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:

2
2 1 100086
2 1 200000

result:

ok OK: 2 operations

Test #37:

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

input:

200000 6
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 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:

2
2 1 100086
2 1 200000

result:

ok OK: 2 operations

Subtask #7:

score: 17
Accepted

Dependency #5:

100%
Accepted

Test #38:

score: 17
Accepted
time: 1ms
memory: 3804kb

input:

3000 7
1 0 1 0 1 1 0 0 0 0 0 1 0 1 1 1 1 0 1 1 0 1 0 0 0 1 1 1 0 0 1 0 0 1 1 1 0 0 0 1 0 1 1 1 1 1 0 1 0 0 0 1 0 0 0 0 0 1 1 0 0 1 0 0 1 1 0 1 0 1 0 1 1 0 1 0 0 0 1 1 1 1 1 1 1 1 0 0 1 0 1 0 0 1 1 1 0 1 0 0 1 1 0 1 0 0 0 1 1 1 1 1 0 1 0 1 0 0 0 1 1 1 1 1 0 0 0 0 0 0 0 1 1 1 0 1 1 1 0 0 1 1 0 0 1 1 0...

output:

0

result:

ok OK: 0 operations

Test #39:

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

input:

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

output:

2
3 1 5
2 1 3000

result:

ok OK: 2 operations

Test #40:

score: 0
Accepted
time: 1ms
memory: 3868kb

input:

3000 7
-1 0 0 0 0 -1 0 -1 -1 0 0 0 0 0 -1 -1 0 -1 -1 0 0 0 0 -1 -1 0 -1 0 -1 -1 -1 0 -1 -1 -1 -1 -1 0 0 -1 -1 -1 0 0 0 0 -1 0 -1 0 -1 0 -1 0 -1 0 0 -1 0 -1 0 0 0 -1 -1 0 0 -1 -1 0 0 -1 -1 0 0 -1 0 -1 0 -1 -1 -1 0 -1 -1 -1 0 0 -1 0 -1 0 -1 0 0 0 0 -1 0 -1 0 -1 -1 -1 -1 0 0 0 0 0 -1 0 0 -1 -1 -1 -1 0 ...

output:

1
1

result:

ok OK: 1 operations

Test #41:

score: 0
Accepted
time: 1ms
memory: 3744kb

input:

3000 7
-1 0 0 1 -1 1 -1 0 -1 1 -1 0 -1 1 1 1 0 1 -1 1 1 0 1 -1 -1 0 -1 1 0 0 -1 0 0 1 1 1 0 1 1 0 1 0 -1 0 0 -1 -1 1 1 0 0 1 1 1 -1 1 1 -1 -1 -1 -1 1 -1 -1 0 -1 0 -1 0 0 1 0 1 1 1 -1 1 0 0 0 -1 -1 0 0 1 0 1 -1 1 -1 0 1 -1 -1 0 -1 -1 0 1 0 0 -1 -1 0 -1 0 1 -1 1 -1 1 1 0 -1 1 0 0 -1 0 1 1 0 -1 1 1 1 0...

output:

1
3 1 3000

result:

ok OK: 1 operations

Test #42:

score: 0
Accepted
time: 1ms
memory: 3840kb

input:

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

output:

2
3 132 622
2 1 3000

result:

ok OK: 2 operations

Test #43:

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

input:

3000 7
1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -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 2441 2829
3 1 3000

result:

ok OK: 2 operations

Test #44:

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

input:

3000 7
1 1 1 1 1 0 -1 -1 0 -1 -1 -1 0 0 0 -1 0 0 1 0 0 0 0 0 0 0 0 1 -1 -1 -1 0 0 0 -1 0 -1 -1 0 1 0 -1 0 0 0 0 0 0 -1 0 0 0 -1 -1 0 -1 0 -1 0 0 0 0 0 0 -1 0 0 0 -1 0 0 0 0 -1 0 0 -1 0 0 0 -1 0 -1 0 0 0 0 -1 0 0 0 0 0 -1 -1 -1 0 0 0 0 0 -1 0 -1 0 0 -1 0 0 -1 -1 0 -1 -1 0 0 0 0 0 0 -1 -1 0 0 0 0 0 0 ...

output:

3
1
3 1 2995
2 1 3000

result:

ok OK: 3 operations

Test #45:

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

input:

3000 7
1 1 1 -1 1 0 -1 0 0 -1 0 -1 0 0 0 0 -1 0 -1 0 0 -1 -1 -1 0 0 0 0 0 -1 0 -1 0 0 0 1 0 -1 0 0 0 0 0 -1 0 -1 0 0 -1 0 -1 0 0 -1 0 0 0 0 -1 -1 0 0 -1 0 0 0 0 -1 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 -1 0 1 0 0 0 0 -1 0 -1 0 0 0 0 0 0 0 -1 0 0 0 -1 -1 0 0 0 -1 0 -1 -1 0 0 0 0 0 0 -1 -1 -1 0 0 0 -1 0 ...

output:

3
1
3 1 2971
2 1 3000

result:

ok OK: 3 operations

Test #46:

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

input:

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

output:

2
3 2759 2959
3 1 2959

result:

ok OK: 2 operations

Test #47:

score: 0
Accepted
time: 1ms
memory: 3788kb

input:

3000 7
0 1 1 -1 -1 1 0 -1 -1 0 0 0 0 0 1 -1 0 -1 0 0 0 1 -1 1 -1 1 0 0 1 0 1 1 -1 1 -1 1 0 1 1 1 1 1 0 0 0 1 1 1 -1 -1 0 0 0 0 0 -1 -1 -1 -1 0 -1 1 0 -1 1 0 0 0 -1 1 -1 -1 0 1 0 1 -1 1 -1 1 1 -1 0 1 -1 0 0 1 0 -1 0 0 -1 -1 -1 0 0 1 -1 0 0 -1 1 -1 -1 -1 0 -1 0 -1 -1 0 -1 1 1 1 -1 1 0 -1 0 1 1 -1 1 0 ...

output:

2
3 1 38
2 1 3000

result:

ok OK: 2 operations

Subtask #8:

score: 1
Accepted

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Dependency #3:

100%
Accepted

Dependency #4:

100%
Accepted

Dependency #5:

100%
Accepted

Dependency #6:

100%
Accepted

Dependency #7:

100%
Accepted

Test #48:

score: 1
Accepted
time: 11ms
memory: 6344kb

input:

200000 8
-1 -1 -1 0 -1 1 0 1 1 -1 0 0 0 0 0 -1 1 -1 1 -1 -1 0 1 0 -1 0 0 0 1 0 1 1 0 -1 -1 0 -1 1 1 -1 0 1 -1 0 0 -1 1 1 -1 0 1 -1 -1 -1 -1 1 0 1 -1 0 0 0 -1 -1 1 -1 1 0 -1 -1 -1 -1 -1 -1 0 1 0 -1 0 -1 -1 -1 -1 -1 1 1 -1 -1 0 0 1 1 -1 1 0 -1 -1 0 1 0 0 0 -1 1 -1 1 1 0 1 -1 -1 -1 -1 1 0 1 1 1 0 1 -1 ...

output:

2
1
2 1 200000

result:

ok OK: 2 operations

Test #49:

score: 0
Accepted
time: 34ms
memory: 21308kb

input:

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

output:

2
3 192137 193782
3 1 193782

result:

ok OK: 2 operations

Test #50:

score: 0
Accepted
time: 15ms
memory: 9312kb

input:

200000 8
1 -1 0 1 -1 0 -1 1 0 0 -1 0 0 0 1 0 -1 0 0 -1 -1 1 1 0 0 0 0 0 0 1 0 0 0 0 0 1 -1 0 -1 0 1 1 0 0 -1 1 -1 -1 -1 0 -1 0 0 1 1 1 1 1 1 0 1 -1 1 1 0 -1 1 -1 0 0 0 0 0 0 -1 0 -1 1 -1 -1 0 -1 1 -1 0 1 0 -1 1 0 -1 -1 1 1 0 0 0 -1 -1 -1 1 0 -1 0 0 -1 0 1 -1 0 -1 -1 1 0 0 -1 1 1 0 1 -1 -1 1 -1 -1 1 ...

output:

2
3 7 30
2 1 200000

result:

ok OK: 2 operations

Test #51:

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

input:

200000 8
0 -1 1 -1 0 0 0 -1 1 -1 1 -1 -1 1 1 0 0 1 1 0 -1 -1 1 1 1 1 -1 1 -1 0 -1 -1 0 -1 -1 -1 -1 0 -1 -1 -1 0 -1 -1 -1 0 0 0 0 0 1 1 1 -1 1 -1 -1 1 0 0 1 -1 0 -1 -1 -1 -1 1 -1 -1 -1 1 -1 1 0 1 0 -1 1 0 -1 1 0 0 1 0 -1 -1 0 0 -1 1 0 1 -1 1 -1 1 1 0 0 0 1 1 0 -1 -1 0 -1 -1 -1 -1 -1 -1 0 -1 1 1 -1 0 ...

output:

2
3 2 382
2 1 200000

result:

ok OK: 2 operations

Test #52:

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

input:

200000 8
1 1 0 0 -1 1 0 -1 -1 0 0 -1 -1 0 1 0 -1 1 0 0 0 -1 1 0 0 0 -1 0 -1 0 -1 1 -1 1 0 0 0 -1 -1 0 1 -1 0 1 0 1 -1 -1 0 -1 0 1 1 1 -1 1 -1 0 -1 0 -1 1 1 1 1 0 1 0 -1 -1 0 1 -1 0 1 1 0 1 -1 -1 -1 0 1 1 -1 1 -1 0 1 0 -1 0 -1 -1 -1 1 0 -1 0 -1 1 0 0 -1 0 -1 -1 1 0 0 1 0 1 1 0 0 0 1 1 0 0 0 -1 0 0 -1...

output:

2
3 12 78
2 1 200000

result:

ok OK: 2 operations

Test #53:

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

input:

200000 8
-1 0 -1 -1 0 1 0 1 0 0 0 -1 1 0 0 1 -1 1 -1 0 1 0 1 -1 1 1 -1 -1 0 0 1 -1 0 -1 0 1 -1 -1 -1 1 -1 1 0 0 1 -1 0 1 0 0 0 0 0 -1 0 1 0 1 1 0 -1 1 1 0 0 0 1 -1 -1 1 1 1 -1 -1 1 -1 1 1 0 -1 -1 1 0 -1 0 0 1 -1 1 -1 0 0 -1 0 -1 0 -1 1 1 1 1 -1 1 -1 -1 1 1 1 -1 1 0 1 1 -1 -1 1 1 -1 1 -1 0 0 -1 0 1 1...

output:

2
1
3 1 200000

result:

ok OK: 2 operations

Test #54:

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

input:

200000 8
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 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:

2
3 10547 43497
2 1 200000

result:

ok OK: 2 operations

Test #55:

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

input:

200000 8
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 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:

2
3 22919 70162
2 1 200000

result:

ok OK: 2 operations

Test #56:

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

input:

200000 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 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -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 97777 175782
3 1 200000

result:

ok OK: 2 operations

Test #57:

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

input:

200000 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 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -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 139301 182130
3 1 200000

result:

ok OK: 2 operations

Test #58:

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

input:

200000 8
1 1 1 1 1 1 1 1 1 -1 0 -1 0 -1 -1 0 0 0 -1 0 -1 0 -1 -1 -1 0 0 -1 0 -1 0 0 0 -1 0 0 0 -1 0 0 0 -1 0 -1 0 0 0 -1 0 0 0 0 -1 -1 0 1 0 -1 -1 -1 0 0 0 0 0 0 0 0 -1 0 -1 0 0 -1 -1 -1 0 -1 -1 -1 0 0 0 0 0 0 -1 0 0 0 0 -1 0 -1 -1 0 -1 -1 -1 0 0 0 0 0 0 0 0 0 0 -1 0 1 0 0 -1 0 0 0 0 -1 0 0 -1 0 0 0...

output:

3
1
3 1 199989
2 1 200000

result:

ok OK: 3 operations

Test #59:

score: 0
Accepted
time: 67ms
memory: 17412kb

input:

200000 8
1 1 1 1 1 1 1 1 1 1 0 -1 0 0 0 -1 0 0 0 0 0 0 0 0 -1 0 -1 0 0 -1 -1 -1 0 0 0 0 -1 0 0 -1 0 0 0 0 -1 0 1 0 0 1 -1 0 0 0 -1 0 0 0 0 0 -1 -1 0 -1 0 0 0 0 0 0 0 0 0 -1 -1 0 0 -1 0 0 0 1 0 -1 -1 0 -1 0 -1 0 0 0 0 0 0 1 0 0 0 -1 -1 0 0 0 0 -1 0 -1 0 0 0 0 0 0 0 -1 0 0 0 -1 0 0 0 0 0 -1 0 0 0 0 0 ...

output:

3
1
3 1 199985
2 1 200000

result:

ok OK: 3 operations

Test #60:

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

input:

200000 8
1 1 1 1 1 1 1 1 -1 0 -1 -1 -1 -1 0 0 0 0 0 -1 0 0 0 -1 0 0 -1 -1 0 0 0 -1 -1 0 0 0 0 -1 0 0 0 0 0 0 -1 0 0 -1 -1 0 -1 0 1 0 0 0 0 0 0 1 0 0 0 0 -1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 -1 -1 -1 0 0 0 0 0 0 0 0 0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 0 -1 0 -1 0 0 -1 0 0 0 0 -1 0 0 -1 0 0 -1 0 -1...

output:

3
1
3 1 199983
2 1 200000

result:

ok OK: 3 operations

Extra Test:

score: 0
Extra Test Passed