QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#497066#7942. $K$ SubsequencesdeepthoughtAC ✓213ms7580kbC++233.5kb2024-07-28 18:41:092024-07-28 18:41:09

Judging History

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

  • [2024-07-28 18:41:09]
  • 评测
  • 测评结果:AC
  • 用时:213ms
  • 内存:7580kb
  • [2024-07-28 18:41:09]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

struct CompareSecond {
    bool operator()(const pair<int, int>& p1, const pair<int, int>& p2) {
        return p1.second < p2.second; // min-heap based on the second element
    }
};

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int tc;
    cin >> tc;
    for(int tt = 1; tt <= tc; tt++) {
        int n, k;
        cin >> n >> k;
        vector <int> a(n);
        bool pl = true;
        int cnt = 0;
        for(int i = 0; i < n; i++){ 
            cin >> a[i];
            if(a[i] == 1) pl = false;
            if(a[i] == 1) cnt++;
        }
        if(pl == true) {
            for(int i = 0; i < n; i++) cout << 1 << " ";
            cout << '\n';
            continue;
        }
        // if(tt == 14722) assert(a[7] == - 1);
        
        // k = 2
        // 7 tane 1
        // 3 tane 0
        // Array: [1, 1, 1, - 1, -1, -1, 1, 1, 1, 1]
        


        // 000011111
        // lo last 0, high first 1
        int lo = 0;
        int hi = n;
        while((hi - lo) > 1) {
            int mid = lo + (hi - lo) / 2;
            priority_queue<pair<int, int>, vector<pair<int, int>>, CompareSecond> pos;
            stack <pair<int, int>> neg;
            for(int i = 1; i <= k; i++) {
                pos.push({i, 0});
            }
            bool ok = true;
            for(int i = 0; i < n; i++) {
                if(a[i] == 1) {
                    if(pos.empty()) {ok = false; break;}
                    auto [x, y] = pos.top();
                    pos.pop();
                    if(y + 1 == mid) neg.push({x, y + 1});
                    else pos.push({x, y + 1});
                }
                else if(a[i] == - 1) {
                    if(neg.empty()) {
                        if(pos.empty()) {ok = false; break;}
                        auto [x, y] = pos.top();
                        pos.pop();
                        pos.push({x, max(y - 1, 0)});                        
                    }
                    else {
                        auto [x, y] = neg.top();
                        neg.pop();
                        assert(y > 0);
                        assert(y == mid);
                        pos.push({x, y - 1});
                    }
                }
            }
            if(ok) {
                hi = mid;
            }
            else {
                lo = mid;
            }
        }
        priority_queue<pair<int, int>, vector<pair<int, int>>, CompareSecond> pos;
        stack <pair<int, int>> neg;
        for(int i = k; i >= 1; i--) {
            pos.push({i, 0});
        }
        int mid = hi;
        for(int i = 0; i < n; i++) {
            if(a[i] == 1) {
                auto [x, y] = pos.top();
                cout << x << " ";
                pos.pop();
                if(y + 1 == mid) neg.push({x, y + 1});
                else pos.push({x, y + 1});
            }
            else if(a[i] == - 1) {
                if(neg.empty()) {
                    auto [x, y] = pos.top();
                    cout << x << " ";
                    pos.pop();
                    pos.push({x, max(y - 1, 0)});                        
                }
                else {
                    auto [x, y] = neg.top();
                    cout << x << " ";
                    neg.pop();
                    assert(y > 0);
                    pos.push({x, y - 1});
                }
            }
        }
        cout << '\n';
    }
    





}

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

详细

Test #1:

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

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

result:

ok Correct (5 test cases)

Test #2:

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

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 1
1 -1 -1 1 -1 -1 -1 -1 -1
10 10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ok Correct (1 test case)

Test #4:

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

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 150 150 138 122 122 26 1 152 77 150 138 138 122 26 26 152 77 150 150 138 122 122 26 26 26 26 150 150 150 150 150 150 115 115 1 1 144 144 144 144 149 115 138 1 151 122 146 146 149 149 149 149 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 151 146 146 134 134 134 134 134 134 151 151 1...

result:

ok Correct (1 test case)

Test #5:

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

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 134 134 134 106 106 134 106 106 134 106 106 106 134 106 134 106 134 134 69 69 134 69 69 106 134 134 69 106 106 69 134 134 106 69 69 134 69 106 106 104 104 106 69 134 104 106 106 69 134 106 104 69 134 106 3 3 3 3 3 4 4 3 4 3 106 106 106 106 3 106 106 3 3 4 106 3 4 114 4 4 4 3 106 4 3 106 106 3 10...

result:

ok Correct (1 test case)

Test #6:

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

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 86238 86238 86234 86226 86210 86178 86114 85986 85986 85730 85218 85218 84194 84194 85730 86114 82146 78050 69858 53474 20706 1 2 2 86238 3 4 5 6 6 7 7 5 4 3 86238 1 20706 53474 85986 85986 69858 8 8 78050 82146 86178 85218 86114 86114 85218 86210 85730 84194 84194 85730 9 10 10 11 11 12 12 2 ...

result:

ok Correct (1 test case)

Test #7:

score: 0
Accepted
time: 213ms
memory: 7580kb

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 196584 196580 196572 196572 196556 196556 196524 196524 196460 196332 196076 196076 195564 194540 192492 192492 188396 180204 163820 131052 65516 65516 1 196586 196584 196584 196586 1 196580 196580 196572 196556 196524 196460 196460 196332 196332 196076 196076 195564 194540 192492 1924...

result:

ok Correct (1 test case)

Test #8:

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

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 32662 32658 32658 32650 32634 32602 32602 32538 32410 32154 32154 32410 31642 31642 32538 30618 28570 24474 24474 28570 16282 16282 1 2 3 3 2 1 32658 32658 30618 32634 32650 32662 4 4 5 5 32664 32602 32602 6 7 32410 32410 7 32538 31642 32154 28570 16282 16282 24474 24474 28570 32154 8 1 32662 ...

result:

ok Correct (2 test cases)

Test #9:

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

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 2 2 2 1 2 2 2 2 2 2 1 1 2 2 1 2 1 1 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 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 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 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 2 2 2 2 2 2 2 2 2 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: 117ms
memory: 4128kb

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 246 242 234 218 186 186 122 122 1 248 248 246 246 246 246 246 246 234 234 125 186 186 122 122 218 218 1 246 234 248 187 122 242 218 218 1 1 246 234 234 248 248 122 122 122 248 122 248 125 125 218 218 1 218 125 1 1 218 125 1 1 1 2 126 126 3 242 242 242 242 218 125 125 125 125 1 2 2 3 3 186 218 21...

result:

ok Correct (2 test cases)

Test #11:

score: 0
Accepted
time: 127ms
memory: 4376kb

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

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

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

result:

ok Correct (3 test cases)

Test #14:

score: 0
Accepted
time: 58ms
memory: 3900kb

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 79 75 67 51 51 1 81 79 75 67 42 51 1 1 79 79 67 42 51 51 1 72 72 67 67 67 67 67 67 67 67 67 67 67 67 67 67 79 42 42 51 51 80 67 79 72 42 19 19 19 19 79 79 42 42 42 62 62 62 62 62 1 1 62 42 1 62 42 1 1 67 67 67 67 1 42 62 67 67 1 42 62 67 67 67 67 67 1 67 1 1 67 1 1 67 1 67 42 42 62 62 62 42 62 42...

result:

ok Correct (4 test cases)

Test #15:

score: 0
Accepted
time: 127ms
memory: 4336kb

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

result:

ok Correct (5 test cases)

Test #16:

score: 0
Accepted
time: 78ms
memory: 3800kb

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 4793 4789 4789 4781 4765 4733 4733 4669 4541 4285 3773 3773 2749 2749 4285 4541 4669 4765 701 1 4795 4795 4793 4789 4789 4781 2 2 4733 3 4 5 3773 4765 701 701 1 1 4795 4793 4789 4789 4793 4781 4781 2 4733 3 3 4 4669 4541 4285 4285 701 701 1 1 2749 2749 6 4793 4781 4789 7 3 8 9 9 10 10 8 3 7 478...

result:

ok Correct (6 test cases)

Test #17:

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

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

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 104 100 92 76 76 44 44 106 106 100 100 54 100 54 100 94 94 106 106 106 94 106 94 94 106 100 94 106 106 94 100 106 94 76 81 81 81 81 44 44 44 81 44 81 80 80 55 55 104 104 44 104 44 44 104 104 55 44 44 104 104 55 55 44 104 104 55 104 104 104 104 55 44 104 55 44 3 44 55 104 80 3 3 44 44 81 55 104 1...

result:

ok Correct (8 test cases)

Test #19:

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

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

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 1594 1590 1590 1582 1566 1534 1534 1566 1582 1470 1342 1342 1470 1594 1086 1086 574 574 1596 1 1 2 3 1590 4 5 1582 1566 1594 1594 1086 1086 1566 1596 1 2 2 3 3 1 1590 4 4 5 1582 1582 5 574 1594 1566 1596 1086 1086 1596 2 1 1 1590 4 4 3 3 5 1582 1582 5 1590 1470 1470 1342 1342 2 1534 1534 1566 1...

result:

ok Correct (10 test cases)

Test #21:

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

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 27 23 15 15 1 1 1 1 29 23 23 16 15 15 15 29 29 29 29 15 29 15 15 15 15 29 15 29 29 29 15 15 29 29 29 29 27 29 29 29 29 27 27 27 29 15 27 29 15 27 15 27 15 15 27 15 27 27 15 27 15 15 27 15 15 27 15 29 29 27 15 29 29 2 2 2 2 29 2 2 29 2 29 2 3 24 24 27 27 27 29 29 27 29 27 3 27 27 3 3 3 3 3 3 3 3 2...

result:

ok Correct (100 test cases)

Test #22:

score: 0
Accepted
time: 63ms
memory: 3724kb

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 2312 2312 2308 2300 2284 2252 2252 2188 2060 1804 1292 1292 268 268 1804 1 1 2060 2188 2314 2314 2284 2300 231...

result:

ok Correct (101 test cases)

Test #23:

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

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 7062 7058 7050 7050 7058 7034 7034 7002 6938 6810 6554 6042 6042 6554 5018 5018 2970 2970 1 7064 7062 7062 7064 1 2 2 7058 7034 7050 3 3 7050 7034 7058 4 5 6554 6554 5 5018 2970 2970 6042 6042 6 6 5018 1 1 4 2 2 7064 7062 7062 7064 7 7058 7034 7034 7058 7 7050 5 6554 2970 6042 5018 5018 6042 4 ...

result:

ok Correct (102 test cases)

Test #24:

score: 0
Accepted
time: 59ms
memory: 3756kb

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 402 398 398 390 374 342 278 150 1 1 404 402 402 404 398 398 390 390 374 374 150 342 2 3 1 1 3 4 404 398 398 390 390 404 150 150 374 374 402 402 5 3 1 6 398 404 404 398 150 150 6 374 402 390 7 8 9 9 8 10 398 6 150 150 6 398 404 404 11 11 12 13 8 9 9 14 14 8 13 12 15 15 10 398 398 7 390 404 40...

result:

ok Correct (103 test cases)

Test #25:

score: 0
Accepted
time: 53ms
memory: 3708kb

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

result:

ok Correct (105 test cases)

Test #27:

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

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 1 -1 -1 1 -1 1 -1 1 1 1 -1 1 -1 -1 1 -1 -1 -1 1 1 1 -1 -1 1 1 -1 -1 -1 -1 1 1 1 -1 1 1 -1 -1 1 -1 -1 1 1 1 1 -1 1 -1 1 1 1 -1 1 1 1 -1 1 1 -1 1 -1 1 -1 -1 -1 1 1 -1 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:

8 8 8 8 8 8 8 8 8 8 1 1 1 1 6 6 6 6 6 6 6 6 2 6 6 2 2 2 2 6 2 2 6 6 2 6 5 6 6 6 2 6 6 2 6 2 2 6 2 6 2 6 2 6 2 6 2 2 5 2 2 5 2 5 2 2 2 5 5 2 2 2 2 2 2 6 6 2 6 2 1 2 2 1 2 2 2 2 2 6 5 2 6 6 5 6 1 1 7 1 6 5 1 1 2 6 5 5 1 1 2 5 1 6 6 2 2 2 2 5 2 6 5 2 6 1 1 1 1 5 1 5 1 2 2 6 2 6 2 2 2 5 2 5 2 1 1 1 1 1 ...

result:

ok Correct (1000 test cases)

Test #28:

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

input:

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

result:

ok Correct (1002 test cases)

Test #30:

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

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

result:

ok Correct (1003 test cases)

Test #31:

score: 0
Accepted
time: 47ms
memory: 3620kb

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 255 251 243 227 195 131 131 195 3 1 1 3 227 257 257 243 4 4 2 2 251 255 5 6 195 131 227 257 257 243 2 2 255 255 4 4 251 3 3 1 1 257 7 2 2 255 4 4 255 8 8 3 1 1 3 7 9 9 10 10 2 2 11 255 8 8 4 7 9 9 7 10 2 2 10 4 3 1 8 12 13 7 9 9 7 4 10 2 14 15 16 17 7 7 17 16 9 9 18 18 19 20 20 19 15 21 21 22 23...

result:

ok Correct (1004 test cases)

Test #32:

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

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 1 -1 -1 1 1 1 1 -1 1 -1 1 -1 1 1 1 -1 -1 -1 -1 1 1 -1 1 -1 1 -1 1 -1 1 -1 1 1 1 -1 -1 1 -1 -1 -1 -1 1 1 -1 -1 -1 -1 1 -1 1 -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:

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

result:

ok Correct (1005 test cases)

Test #33:

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

input:

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

result:

ok Correct (9996 test cases)

Test #35:

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

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

result:

ok Correct (9997 test cases)

Test #36:

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

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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Correct (9999 test cases)

Test #38:

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

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