QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#286210#7942. $K$ Subsequencesucup-team2894#AC ✓61ms20044kbC++201.4kb2023-12-17 05:38:082023-12-17 05:38:08

Judging History

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

  • [2023-12-17 05:38:08]
  • 评测
  • 测评结果:AC
  • 用时:61ms
  • 内存:20044kb
  • [2023-12-17 05:38:08]
  • 提交

answer

// UW BLACK
#include <bits/stdc++.h>

#define fr first
#define sc second
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)((x).size()))
#define rep(i,a,b) for(int i=(a);i<(b);++i)

using namespace std;

using ll = long long;
using ld = long double;
using vi = vector<int>;
using pii = pair<int,int>;

mt19937 rnd(223);

clock_t TIME0;

#define TIME ((clock() - TIME0) * 1.0 / CLOCKS_PER_SEC)

constexpr int maxn = 1e6 + 100, inf = 1e9 + 100;
using T = long double;
constexpr T EPS = 1e-9;

const ll mod = 1e9+7;

int a[maxn], sum[maxn],ans[maxn];
void solve() {
    int n,k;
    cin >> n >> k;
    for(int i=0;i<=n;i++)a[i]=sum[i]=ans[i]=0;
    for(int i=0;i<n;i++)cin >> a[i];
    set<pii> pq;
    for(int i=0;i<k;i++)pq.insert({0,i});
    for(int i=0;i<n;i++){
        if(a[i]==1){
            auto [c,ind] = *pq.begin();
            pq.erase(pq.begin());
            ans[i]=ind;
            pq.insert({c+1,ind});
        }
        else {
            auto [c,ind] = *--pq.end();
            pq.erase(--pq.end());
            ans[i]=ind;
            pq.insert({max(0,c-1),ind});
        }
    }
    for(int i=0;i<n;i++)cout << ans[i]+1 << " \n"[i==n-1];
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout << fixed;
    cout.precision(20);
    TIME0 = clock();
    int k=1;
    cin >> k;
    while(k--)
        solve();
    cerr << "\n\nConsumed " << TIME << endl;
}

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

详细

Test #1:

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

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

result:

ok Correct (5 test cases)

Test #2:

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

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

output:

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

result:

ok Correct (18434 test cases)

Test #3:

score: 0
Accepted
time: 19ms
memory: 14356kb

input:

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

output:

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

result:

ok Correct (1 test case)

Test #4:

score: 0
Accepted
time: 27ms
memory: 8840kb

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

result:

ok Correct (1 test case)

Test #5:

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

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 1 2 3 4 5 5 5 5 4 4 4 4 5 5 4 4 5 6 7 8 8 8 8 7 7 7 7 8 8 7 7 7 6 6 6 6 7 8 9 10 11 11 10 9 8 8 8 7 6 5 4 3 2 1 1 2 3 3 3 4 5 5 5 6 7 8 9 9 8 8 8 8 8 7 7 8 9 10 10 10 10 9 8 7 7 8 8 7 6 5 5 5 5 6 7 8 9 9 8 8 9 10 11 12 13 14 15 16 17 18 18 17 16 16 17 18 19 20 20 20 21 21 21 22 23 23 23 24 24 23...

result:

ok Correct (1 test case)

Test #6:

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

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:

1 2 2 2 3 4 5 6 7 7 7 8 8 8 8 7 6 6 7 8 9 10 11 12 12 12 13 14 15 16 16 16 16 15 14 13 12 11 10 9 9 9 8 8 8 7 6 5 5 6 6 5 4 4 5 5 4 4 5 5 5 5 5 5 5 5 5 6 7 8 9 9 9 9 9 9 9 9 8 8 9 10 10 9 8 7 6 5 5 6 7 8 8 7 6 6 7 7 6 6 6 6 7 8 8 7 6 6 6 5 4 3 3 4 4 3 3 3 3 3 2 2 2 1 86240 86240 86240 86240 1 1 1 2 ...

result:

ok Correct (1 test case)

Test #7:

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

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:

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

result:

ok Correct (1 test case)

Test #8:

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

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

result:

ok Correct (2 test cases)

Test #10:

score: 0
Accepted
time: 28ms
memory: 9692kb

input:

2
114819 248
-1 -1 -1 -1 -1 1 -1 1 -1 -1 1 -1 1 1 -1 1 -1 -1 1 -1 -1 1 -1 1 -1 1 -1 -1 -1 -1 -1 -1 -1 -1 1 -1 1 -1 -1 1 -1 1 1 1 1 -1 -1 -1 -1 1 1 1 1 1 -1 -1 1 -1 -1 -1 1 -1 -1 -1 1 -1 -1 1 1 -1 -1 -1 1 1 -1 -1 -1 1 -1 1 -1 -1 -1 1 1 -1 -1 -1 -1 1 1 1 -1 -1 -1 -1 1 -1 -1 -1 1 1 1 -1 -1 -1 -1 -1 1 -...

output:

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

result:

ok Correct (2 test cases)

Test #11:

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

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

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

input:

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

result:

ok Correct (4 test cases)

Test #15:

score: 0
Accepted
time: 35ms
memory: 10100kb

input:

5
7824 2
-1 -1 -1 -1 1 1 1 1 -1 1 1 1 -1 1 -1 -1 1 1 -1 -1 -1 1 -1 1 -1 1 -1 1 1 -1 1 1 1 1 -1 1 1 -1 1 1 1 -1 1 -1 -1 -1 1 -1 -1 -1 1 -1 -1 1 -1 -1 -1 1 -1 -1 -1 -1 -1 -1 -1 1 1 -1 -1 1 1 1 1 -1 1 -1 -1 1 -1 1 -1 1 -1 1 -1 -1 1 1 -1 1 -1 1 -1 1 1 1 1 -1 1 -1 -1 -1 -1 -1 1 1 -1 1 -1 1 -1 1 1 1 -1 -1...

output:

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

result:

ok Correct (5 test cases)

Test #16:

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

input:

6
7149 4795
-1 -1 1 -1 -1 1 1 -1 1 1 1 1 -1 1 -1 -1 -1 -1 -1 -1 -1 1 -1 -1 1 -1 -1 1 -1 -1 -1 -1 1 1 1 1 -1 1 -1 1 1 1 -1 -1 1 -1 1 1 1 -1 1 1 1 1 -1 1 -1 1 -1 1 -1 1 1 1 1 1 1 1 1 -1 1 -1 -1 -1 -1 -1 -1 -1 -1 -1 1 1 -1 1 1 -1 -1 -1 -1 1 1 1 -1 1 1 -1 1 -1 1 -1 1 1 -1 1 -1 -1 -1 1 1 1 1 1 1 -1 -1 -1...

output:

4795 4795 1 1 4795 1 2 2 2 3 4 5 5 5 5 4 3 2 1 4795 4795 1 1 4795 1 1 4795 1 1 4795 4795 4795 1 2 3 4 4 4 4 4 5 6 6 5 5 5 5 6 7 7 7 8 9 10 10 10 10 10 10 10 10 10 11 12 13 14 15 16 17 17 17 17 16 15 14 13 12 11 10 9 9 10 10 10 11 11 10 9 8 8 9 10 10 10 11 11 11 11 11 11 11 12 12 12 12 11 10 10 11 12...

result:

ok Correct (6 test cases)

Test #17:

score: 0
Accepted
time: 22ms
memory: 8560kb

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

input:

8
29021 106
-1 -1 -1 -1 1 -1 1 -1 1 -1 1 1 1 -1 -1 1 1 1 1 1 -1 -1 1 1 -1 -1 -1 1 1 -1 -1 -1 -1 -1 -1 1 1 -1 1 1 1 -1 -1 -1 1 1 1 1 1 1 1 1 -1 1 -1 1 -1 -1 1 -1 1 -1 1 -1 1 1 -1 1 1 -1 1 -1 -1 -1 1 1 1 1 -1 -1 -1 -1 1 -1 1 -1 -1 1 1 -1 -1 -1 1 -1 1 1 -1 1 1 1 -1 1 -1 1 1 -1 -1 -1 1 -1 -1 -1 1 -1 -1 ...

output:

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

result:

ok Correct (8 test cases)

Test #19:

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

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

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:

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

result:

ok Correct (10 test cases)

Test #21:

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

input:

100
2336 29
-1 -1 -1 1 -1 1 1 -1 -1 -1 1 -1 -1 1 1 1 1 1 1 -1 -1 1 1 -1 1 -1 -1 -1 1 -1 -1 1 1 1 1 -1 1 1 -1 1 -1 1 1 1 -1 -1 -1 -1 -1 1 1 -1 1 1 -1 -1 1 1 -1 -1 1 1 -1 -1 1 -1 -1 -1 1 -1 -1 -1 1 1 1 1 1 -1 -1 1 -1 -1 -1 -1 -1 -1 1 -1 1 1 1 1 1 -1 1 1 1 -1 1 1 1 -1 1 -1 1 -1 1 1 1 1 1 -1 1 -1 -1 -1 ...

output:

29 29 29 1 1 1 2 2 1 29 1 1 29 1 2 3 4 5 6 6 5 5 6 6 6 6 5 4 4 4 3 3 4 5 6 6 6 7 7 7 7 7 8 9 9 8 7 6 5 5 6 6 6 7 7 6 6 7 7 6 6 7 7 6 6 6 5 4 4 4 3 2 2 3 4 5 6 6 5 5 5 4 3 2 1 29 1 1 1 2 3 4 5 5 5 6 7 7 7 8 9 9 9 9 9 9 9 10 11 12 13 13 13 13 12 11 11 12 12 11 11 12 13 14 15 15 14 13 12 12 13 13 13 14...

result:

ok Correct (100 test cases)

Test #22:

score: 0
Accepted
time: 19ms
memory: 8228kb

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

result:

ok Correct (101 test cases)

Test #23:

score: 0
Accepted
time: 27ms
memory: 8300kb

input:

102
8381 7064
-1 -1 1 1 -1 -1 1 -1 1 1 1 1 1 -1 -1 1 -1 1 -1 1 1 1 -1 -1 -1 1 -1 1 1 1 1 -1 -1 -1 -1 1 1 1 -1 -1 1 1 -1 1 -1 1 -1 -1 1 -1 -1 1 -1 1 1 -1 -1 1 1 1 -1 -1 -1 1 1 1 1 1 1 -1 -1 1 -1 1 -1 -1 -1 -1 1 1 -1 1 1 -1 -1 1 -1 -1 1 -1 -1 -1 1 -1 -1 1 -1 1 1 -1 -1 1 1 1 1 -1 -1 1 1 1 -1 1 -1 -1 -1...

output:

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

result:

ok Correct (102 test cases)

Test #24:

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

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:

1 1 404 1 1 404 404 404 1 2 3 3 3 4 4 3 3 3 3 3 3 3 2 2 3 4 5 5 4 4 5 6 6 6 6 5 5 5 5 5 5 5 5 6 7 8 9 10 10 9 9 9 8 8 9 10 11 12 13 13 12 12 13 14 15 15 14 13 13 13 13 13 13 14 15 16 16 16 16 15 14 13 13 13 12 12 12 11 10 10 10 9 8 8 8 8 9 9 9 10 10 10 10 10 10 9 8 7 6 5 5 6 7 8 8 7 6 6 7 7 7 8 8 8 ...

result:

ok Correct (103 test cases)

Test #25:

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

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:

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

result:

ok Correct (104 test cases)

Test #26:

score: 0
Accepted
time: 23ms
memory: 8216kb

input:

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

result:

ok Correct (1000 test cases)

Test #28:

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

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:

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

result:

ok Correct (1001 test cases)

Test #29:

score: 0
Accepted
time: 23ms
memory: 7988kb

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

result:

ok Correct (1003 test cases)

Test #31:

score: 0
Accepted
time: 27ms
memory: 8072kb

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

result:

ok Correct (1004 test cases)

Test #32:

score: 0
Accepted
time: 27ms
memory: 8068kb

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:

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

result:

ok Correct (1005 test cases)

Test #33:

score: 0
Accepted
time: 27ms
memory: 7952kb

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:

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

result:

ok Correct (9995 test cases)

Test #34:

score: 0
Accepted
time: 19ms
memory: 7980kb

input:

9996
27 1
1 1 -1 -1 -1 -1 -1 -1 -1 1 1 1 -1 -1 -1 -1 1 -1 1 -1 -1 -1 1 1 -1 1 1
7 2
1 1 1 1 -1 -1 1
22 3
-1 -1 1 1 -1 -1 -1 1 1 1 -1 -1 -1 -1 -1 1 -1 1 1 -1 -1 1
37 4
-1 -1 -1 1 -1 1 -1 -1 -1 1 1 -1 1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 1 1 1 1 1 -1 1 1 1
7 1
-1 1 -1 -1 1 1 1
29 1
-1 -1 1 -1 1 -1 1...

output:

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

result:

ok Correct (9996 test cases)

Test #35:

score: 0
Accepted
time: 23ms
memory: 8220kb

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

result:

ok Correct (9997 test cases)

Test #36:

score: 0
Accepted
time: 23ms
memory: 8036kb

input:

9998
28 3
-1 1 1 -1 -1 -1 -1 -1 1 1 1 -1 -1 1 -1 1 -1 -1 -1 -1 -1 -1 -1 1 1 1 1 1
12 2
-1 -1 -1 1 -1 -1 1 -1 1 1 -1 1
8 6
-1 1 1 -1 1 1 1 1
3 1
1 1 -1
12 1
1 -1 1 1 1 -1 1 -1 -1 1 1 -1
3 1
1 -1 -1
77 3
-1 -1 1 1 1 -1 1 -1 1 1 1 1 1 1 1 -1 -1 -1 1 -1 -1 1 -1 -1 1 1 -1 1 -1 1 1 -1 -1 -1 -1 -1 1 -1 1 -...

output:

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

result:

ok Correct (9998 test cases)

Test #37:

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

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

result:

ok Correct (10000 test cases)

Extra Test:

score: 0
Extra Test Passed