QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#363612#7942. $K$ Subsequencesvmadhu99#AC ✓108ms13956kbC++201.1kb2024-03-24 00:55:192024-03-24 00:55:19

Judging History

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

  • [2024-03-24 00:55:19]
  • 评测
  • 测评结果:AC
  • 用时:108ms
  • 内存:13956kb
  • [2024-03-24 00:55:19]
  • 提交

answer

#include <bits/stdc++.h>

#define pb push_back
#define f first
#define s second
 
using ll = long long;
using namespace std;

const int MOD = 1e9 + 7;

int main(){
    int t;
    cin >> t;
    while(t--){
        int n, k;
        cin >> n >> k;
        vector<int> elems(n);
        for(int i = 0; i < n; i++){
            cin >> elems[i];
        }
        vector<int> ans(n);
        set<pair<int, int>> pq;
        for(int i = 1; i <= k; i++){
            pq.insert({0, i});
        }
        for(int i = n - 1; i >= 0; i--){
            if(elems[i] == 1){
                auto small = *pq.begin();
                pq.erase(small);
                ans[i] = small.s;
                small.f++;
                pq.insert(small);
            } else {
                auto big = *pq.rbegin();
                pq.erase(big);
                ans[i] = big.s;
                big.f--; big.f = max(big.f, 0);
                pq.insert(big);
            }
        }
        for(int x : ans){
            cout << x << " ";
        }
        cout << endl;
    }
}

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

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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:

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

result:

ok Correct (5 test cases)

Test #2:

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

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

result:

ok Correct (1 test case)

Test #4:

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

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:

74 74 74 75 75 75 76 77 78 79 80 80 80 81 81 81 82 83 83 83 84 84 84 84 83 83 84 84 83 82 82 83 84 84 84 84 84 84 83 83 84 85 86 87 88 89 90 90 90 90 89 89 90 90 89 89 89 89 89 89 89 89 89 89 89 89 89 89 90 90 90 90 89 88 87 87 87 86 85 85 86 86 86 87 87 86 86 87 88 89 89 89 90 90 90 90 89 89 89 88 ...

result:

ok Correct (1 test case)

Test #5:

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

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:

123 123 122 121 120 119 119 119 119 120 120 120 120 119 119 120 120 119 118 117 116 116 116 116 117 117 117 117 116 116 117 117 117 118 118 118 118 117 116 115 114 113 113 114 115 116 116 116 117 118 119 120 121 122 123 123 122 121 121 121 120 119 119 119 118 117 116 115 115 116 116 116 116 116 117 ...

result:

ok Correct (1 test case)

Test #6:

score: 0
Accepted
time: 88ms
memory: 8676kb

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:

34 33 33 33 32 31 30 29 28 28 28 27 27 27 27 28 29 29 28 27 26 25 24 23 23 23 22 21 20 19 19 19 19 20 21 22 23 24 25 26 26 26 27 27 27 28 29 30 30 29 29 30 31 31 30 30 31 31 30 30 30 30 30 30 30 30 30 29 28 27 26 26 26 26 26 26 26 26 27 27 26 25 25 26 27 28 29 30 30 29 28 27 27 28 29 29 28 28 29 29 ...

result:

ok Correct (1 test case)

Test #7:

score: 0
Accepted
time: 108ms
memory: 13956kb

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:

15 15 16 17 17 17 17 17 17 17 18 19 19 19 20 21 21 21 22 23 24 25 25 25 25 24 23 23 24 25 25 25 26 27 27 26 26 26 26 26 26 26 25 24 24 25 26 27 27 27 28 29 29 29 30 30 30 31 32 32 31 30 29 28 28 28 27 27 27 26 25 24 24 25 26 26 25 25 26 26 25 25 26 27 27 27 28 29 29 29 30 31 31 31 32 32 32 32 32 33 ...

result:

ok Correct (1 test case)

Test #8:

score: 0
Accepted
time: 87ms
memory: 9788kb

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:

86 85 84 84 84 83 82 82 82 81 80 80 81 81 81 82 82 81 80 80 81 81 81 81 80 79 79 80 81 81 81 82 83 84 85 85 85 85 85 86 86 86 87 87 86 86 87 88 89 89 88 87 87 87 87 88 89 90 90 89 88 87 87 87 86 86 86 86 86 86 87 87 87 87 87 88 88 88 88 87 87 87 86 86 87 88 88 87 86 85 84 84 84 83 83 83 82 82 83 84 ...

result:

ok Correct (2 test cases)

Test #9:

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

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:

1 2 2 1 2 2 1 1 1 1 2 2 2 2 2 1 2 2 2 2 1 2 1 1 2 2 2 1 1 2 1 1 2 2 1 1 2 1 1 2 1 2 1 2 1 2 2 1 1 2 1 2 1 1 1 1 1 2 2 2 2 1 1 1 2 1 2 2 2 1 1 2 1 1 1 1 1 2 2 2 1 2 2 2 2 2 2 2 2 1 2 1 2 1 2 1 2 1 1 2 2 2 2 2 1 2 1 2 1 2 2 2 2 2 2 2 2 2 1 1 2 1 1 2 1 1 1 1 1 1 2 1 2 1 2 1 1 1 1 1 1 2 2 1 1 2 2 2 1 1 ...

result:

ok Correct (2 test cases)

Test #10:

score: 0
Accepted
time: 51ms
memory: 5132kb

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:

28 29 30 31 32 32 32 32 32 33 33 33 33 32 32 32 32 33 33 33 34 34 34 34 34 34 34 35 36 37 38 39 40 41 41 41 41 41 42 42 42 42 41 40 39 39 40 41 42 42 41 40 39 38 38 39 39 39 40 41 41 41 42 43 43 43 44 44 43 43 44 45 45 44 44 45 46 46 46 46 46 47 48 48 47 47 48 49 50 50 49 48 48 49 50 51 51 51 52 53 ...

result:

ok Correct (2 test cases)

Test #11:

score: 0
Accepted
time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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 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 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: 45ms
memory: 4580kb

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:

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

result:

ok Correct (3 test cases)

Test #14:

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

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:

34 35 36 37 37 37 38 39 40 41 42 43 44 44 44 44 44 45 46 46 46 47 47 47 47 46 45 45 46 46 45 45 45 45 46 46 46 47 48 48 48 48 48 49 50 51 52 53 53 52 52 53 53 53 53 52 51 50 49 48 48 48 47 46 46 47 48 48 47 46 45 44 43 42 42 43 44 45 45 45 46 47 48 48 48 48 48 48 47 47 47 47 47 46 46 47 47 46 45 44 ...

result:

ok Correct (4 test cases)

Test #15:

score: 0
Accepted
time: 62ms
memory: 5772kb

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:

1 2 1 2 2 1 2 1 1 1 2 1 1 1 1 2 2 1 1 2 1 1 1 1 1 1 1 1 2 2 2 1 2 1 1 1 2 2 2 1 2 2 2 2 1 2 2 2 1 2 2 2 1 1 1 2 1 1 1 2 1 2 1 2 1 1 2 2 1 1 2 1 2 2 2 2 1 1 1 1 1 1 1 1 1 2 2 1 1 1 1 1 1 1 2 1 2 2 2 2 1 2 1 2 2 1 1 1 1 1 1 1 2 1 1 2 1 1 1 2 2 1 1 1 1 2 1 2 1 2 2 1 2 2 2 2 1 2 2 1 2 1 2 1 1 2 2 1 2 1 ...

result:

ok Correct (5 test cases)

Test #16:

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

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:

65 66 66 66 67 67 66 66 66 65 64 63 63 63 63 64 65 66 67 68 69 69 69 70 70 70 71 71 71 72 73 74 74 73 72 71 71 71 71 71 70 69 69 70 70 70 70 69 68 68 68 67 66 65 65 65 65 65 65 65 65 65 64 63 62 61 60 59 58 58 58 58 59 60 61 62 63 64 65 66 66 65 65 65 64 64 65 66 67 67 66 65 65 65 64 64 64 64 64 64 ...

result:

ok Correct (6 test cases)

Test #17:

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

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

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:

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

result:

ok Correct (8 test cases)

Test #19:

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

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

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:

137 136 135 135 135 134 133 133 134 135 135 134 134 135 136 136 136 136 136 137 137 137 138 139 140 141 142 143 143 142 142 142 142 143 144 144 143 143 143 143 144 145 145 145 145 144 144 145 145 144 143 142 141 141 142 142 141 141 141 140 140 140 140 140 139 139 140 141 141 141 141 141 142 142 142 ...

result:

ok Correct (10 test cases)

Test #21:

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

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:

15 16 17 17 17 17 16 16 17 18 18 18 19 19 18 17 16 15 14 14 15 15 14 14 14 14 15 16 16 16 17 17 16 15 14 14 14 13 13 13 13 13 12 11 11 12 13 14 15 15 14 14 14 13 13 14 14 13 13 14 14 13 13 14 14 14 15 16 16 16 17 18 18 17 16 15 14 14 15 15 15 16 17 18 19 20 20 20 20 19 18 17 16 16 16 15 14 14 14 13 ...

result:

ok Correct (100 test cases)

Test #22:

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

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 
133 133 133 134 134 133 132 132 132 131 130 129 129 129 129 130 130 130 131 132 132 132 133 134 134 133 133 134 134...

result:

ok Correct (101 test cases)

Test #23:

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

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:

117 118 118 117 117 118 118 118 118 117 116 115 114 114 115 115 115 115 115 115 114 113 113 114 115 115 115 115 114 113 112 112 113 114 115 115 114 113 113 114 114 113 113 113 113 113 113 114 114 114 115 115 115 115 114 114 115 115 114 113 113 114 115 115 114 113 112 111 110 110 111 111 111 111 111 ...

result:

ok Correct (102 test cases)

Test #24:

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

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:

26 26 27 27 27 28 29 30 30 29 28 28 28 27 27 28 28 28 28 28 28 28 29 29 28 27 26 26 27 27 26 25 25 25 25 26 26 26 26 26 26 26 26 25 24 23 22 21 21 22 22 22 23 23 22 21 20 19 18 18 19 19 18 17 16 16 17 18 18 18 18 18 18 17 16 15 15 15 15 16 17 18 18 18 19 19 19 20 21 21 21 22 23 23 23 23 22 22 22 21 ...

result:

ok Correct (103 test cases)

Test #25:

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

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

result:

ok Correct (104 test cases)

Test #26:

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

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

result:

ok Correct (1000 test cases)

Test #28:

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

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

result:

ok Correct (1001 test cases)

Test #29:

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

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:

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

result:

ok Correct (1002 test cases)

Test #30:

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

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:

2 2 3 3 2 1 16 16 1 2 3 3 2 1 1 2 3 4 4 3 2 2 2 2 2 1 16 16 16 1 1 1 1 16 1 2 2 2 3 3 3 3 3 4 4 4 5 5 5 6 7 7 6 5 5 5 4 3 3 4 5 6 6 5 5 5 4 3 2 1 1 2 2 1 16 16 1 1 16 16 16 1 2 2 2 3 4 4 3 2 1 1 2 2 1 
3 3 1 1 3 3 1 2 3 1 2 3 1 2 3 3 3 3 2 1 1 2 2 1 3 3 3 2 2 2 2 3 1 2 2 1 3 3 3 3 1 1 3 3 3 3 3 2 1 ...

result:

ok Correct (1003 test cases)

Test #31:

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

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:

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

result:

ok Correct (1004 test cases)

Test #32:

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

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:

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

result:

ok Correct (1005 test cases)

Test #33:

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

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 -1 -1 -1
24 22
1 -1 1 -1 1 -1 1 1 1 -1 1 1 1 1 -1 1 1 -1 1 -1 -1 1 -1 -1
6 3
1 -1 1 1 -1 -1
6 4
-1 1 -1 -1 -1 1
14 9
-1 -1 1 -1 1 -1 1 1 1 1 1 1 1 -1
24 3
1 -1 -1 -1 1 1 -1 1 1 1 ...

output:

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

result:

ok Correct (9995 test cases)

Test #34:

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

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

result:

ok Correct (9997 test cases)

Test #36:

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

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:

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

result:

ok Correct (9998 test cases)

Test #37:

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

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

Extra Test:

score: 0
Extra Test Passed