QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#187216#6718. Масив i частковi сумиCyanmond57 10ms7948kbC++175.3kb2023-09-24 15:34:292023-09-24 15:34:29

Judging History

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

  • [2023-09-24 15:34:29]
  • 评测
  • 测评结果:57
  • 用时:10ms
  • 内存:7948kb
  • [2023-09-24 15:34:29]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

#define rep(i, l, r) for (int i = (l); i < (r); ++i)
#define per(i, l, r) for (int i = (r - 1); i >= l; --i)
#define ALL(x) (x).begin(), (x).end()

using i64 = long long;

constexpr i64 cap = 1000000000000000000ll;

void main_() {
    int N, G;
    cin >> N >> G;
    vector<i64> A(N);
    for (auto &e : A) cin >> e;
    if (G == 1) {
        if (all_of(ALL(A), [](i64 v) { return v >= 0; })) {
            cout << 0 << endl;
        } else if (all_of(ALL(A), [](i64 v) { return v <= 0; })) {
            cout << 1 << '\n' << 1 << endl;
        } else {
            vector<i64> B(N), C(N);
            rep(i, 0, N) {
                B[i] = (i == 0 ? 0 : B[i - 1]) + A[i];
            }
            per(i, 0, N) {
                C[i] = (i == N - 1 ? 0 : C[i + 1]) + A[i];
            }
            if (all_of(ALL(B), [](i64 v) { return v >= 0; })) {
                cout << 1 << '\n' << 2 << ' ' << 1 << ' ' << N << endl;
            } else {
                cout << 1 << '\n' << 3 << ' ' << 1 << ' ' << N << endl;
            }
        }
        return;
    }
    if (G == 2) {
        i64 f = 0;
        for (const auto e : A) {
            if (e != 0) {
                f = e;
                break;
            }
        }
        if (f == 0) {
            cout << 0 << endl;
        } else {
            if (f == 1) {
                cout << 100 << endl;
                rep(i, 0, 100) cout << 2 << ' ' << 1 << ' ' << N << endl;
            } else {
                cout << 100 << endl;
                rep(i, 0, 99) cout << 2 << ' ' << 1 << ' ' << N << endl;
                cout << 1 << endl;
            }
        }
        return;
    }
    if (G == 5 or G == 6) {
        vector<pair<int, int>> ans;
        while (any_of(ALL(A), [](i64 x) { return x < 0; })) {
            __int128_t sum = 0;
            int r = N - 1;
            rep(i, 0, N) {
                sum += A[i];
                if (sum < A[i]) {
                    r = i - 1;
                    break;
                } else {
                    A[i] = sum;
                }
            }
            ans.push_back({0, r});
        }
        cout << ans.size() << endl;
        for (const auto &[a, b] : ans) cout << 2 << ' ' << a + 1 << ' ' << b + 1 << endl;
        return;
    }

    auto sol = [&]() -> vector<tuple<int, int, int>> {
        auto B = A;
        if (all_of(ALL(B), [](i64 v) { return v < 0; })) {
            vector<tuple<int, int, int>> res = {{-1, -1, -1}};
            return res;
        }
        vector<tuple<int, int, int>> ans;

        while (any_of(ALL(B), [](i64 v) { return v < 0; })) {
            int extendMax = 0;
            int la = -1, ra = -1;
            rep(l, 0, N) {
                __int128 sum = 0;
                int ex = 0;
                int lastR = N;
                rep(r, l, N) {
                    sum += B[r];
                    if (B[r] >= 0 and sum < 0) {
                        if (r != l) lastR = r - 1;
                        else lastR = r;
                        break;
                    }
                    if (B[r] < 0 and sum >= 0) {
                        ++ex;
                        if (ex > extendMax) {
                            extendMax = ex;
                            la = l;
                            ra = r;
                        }
                    }
                }
                l = lastR;
            }
            per(r, 0, N) {
                __int128 sum = 0;
                int ex = 0;
                int lastL = 0;
                per(l, 0, r + 1) {
                    sum += B[l];
                    if (B[l] >= 0 and sum < 0) {
                        if (l != r) lastL = l + 1;
                        else lastL = l;
                        break;
                    }
                    if (B[l] < 0 and sum >= 0) {
                        ++ex;
                        if (ex > extendMax) {
                            extendMax = ex;
                            la = r;
                            ra = l;
                        }
                    }
                }
                r = lastL;
            }

            ans.push_back({la < ra ? 2 : 3, min(la, ra), max(la, ra)});
            int i = la;
            __int128 sum = 0;
            while (true) {
                sum += B[i];
                __int128 v = sum;
                if (v >= cap) v = cap;
                if (v < -cap) v = -cap;
                B[i] = (i64)v;
                if (i == ra) break;
                i = la < ra ? (i + 1) : (i - 1);
            }
        }

        return ans;
    };

    const auto X = sol();
    for (auto &e : A) e = -e;
    auto Y = sol();
    Y.insert(Y.begin(), {1, 0, 0});
    vector<tuple<int, int, int>> ans;
    if (X.empty()) ans = X;
    else if (Y.size() == 1) ans = Y;
    else if (X[0] == make_tuple(-1, -1, -1)) ans = Y;
    else if (Y[1] == make_tuple(-1, -1, -1)) ans = X;
    else ans = X.size() < Y.size() ? X : Y;

    cout << ans.size() << endl;
    for (const auto &[t, l, r] : ans) {
        cout << t;
        if (t == 1) cout << endl;
        else cout << ' ' << l + 1 << ' ' << r + 1 << endl;
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    main_();
}

详细

Subtask #1:

score: 14
Accepted

Test #1:

score: 14
Accepted
time: 8ms
memory: 4716kb

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: 5ms
memory: 4632kb

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: 10ms
memory: 7744kb

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: 3ms
memory: 7948kb

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

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:

100
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000...

result:

ok OK: 100 operations

Test #6:

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

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:

100
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000...

result:

ok OK: 100 operations

Test #7:

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

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:

100
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000...

result:

ok OK: 100 operations

Test #8:

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

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:

100
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000...

result:

ok OK: 100 operations

Test #9:

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

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:

100
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000...

result:

ok OK: 100 operations

Test #10:

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

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:

100
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000
2 1 200000...

result:

ok OK: 100 operations

Subtask #3:

score: 0
Time Limit Exceeded

Dependency #2:

100%
Accepted

Test #11:

score: 0
Time Limit Exceeded

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:


result:


Subtask #4:

score: 0
Skipped

Dependency #3:

0%

Subtask #5:

score: 7
Accepted

Test #28:

score: 7
Accepted
time: 1ms
memory: 3864kb

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 139
2 1 2891

result:

ok OK: 2 operations

Test #29:

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

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 135
2 1 2847

result:

ok OK: 2 operations

Test #30:

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

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 139
2 1 2981

result:

ok OK: 2 operations

Test #31:

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

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 1507
2 1 3000

result:

ok OK: 2 operations

Test #32:

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

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 1507
2 1 3000

result:

ok OK: 2 operations

Subtask #6:

score: 19
Accepted

Dependency #5:

100%
Accepted

Test #33:

score: 19
Accepted
time: 7ms
memory: 4612kb

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 1124
2 1 191855

result:

ok OK: 2 operations

Test #34:

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

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 1136
2 1 191982

result:

ok OK: 2 operations

Test #35:

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

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 1127
2 1 193538

result:

ok OK: 2 operations

Test #36:

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

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 100007
2 1 200000

result:

ok OK: 2 operations

Test #37:

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

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 100007
2 1 200000

result:

ok OK: 2 operations

Subtask #7:

score: 0
Time Limit Exceeded

Dependency #5:

100%
Accepted

Test #38:

score: 0
Time Limit Exceeded

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:


result:


Subtask #8:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Dependency #3:

0%