QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#589887 | #7942. $K$ Subsequences | eroinevs | WA | 17ms | 3856kb | C++14 | 1.7kb | 2024-09-25 20:30:20 | 2024-09-25 20:30:20 |
Judging History
answer
#include <bits/stdc++.h>
#define ll long long
#define int long long
#define ff first
#define ss second
#define PI pair<int, int>
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define bust ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
const ll INF = (ll)1e9 + 7, mod = 998244353;
void solve(){
int n, k;
cin >> n >> k;
int a[n], cnt1 = 0, cnt2 = 0, q = 0;
for(auto&e: a) cin >> e;
int ind = -1;
deque<int> stp, stn; // stack ends with 1, ends with -1
// for(int i = 0; i < k; i++){
// stp.push_back(i);
// }
for(int i = 0; i < n; ++i){
if(a[i] == 1){
if(!stn.empty()){
ind = stn.front();
stn.pop_front();
}
else{
++ind;
ind %= k;
}
/* else if(!stp.empty()){
ind = stp.front();
stp.pop_front();
}*/
stp.push_front(ind);
}
else{
if(!stp.empty()){
ind = stp.front();
stp.pop_front();
}
else{
++ind;
ind %= k;
}
// else if(!stn.empty()){
// ind = stn.front();
// stn.pop_front();
// }
stn.push_front(ind);
}
cout << ind+1 << ' ';
}
cout << '\n';
}
signed main() {
bust
int t;
cin >> t;
while (t--) {
solve();
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3508kb
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 1 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: -100
Wrong Answer
time: 17ms
memory: 3856kb
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 1 2 1 1 2 2 2 1 2 1 1 1 2 1 2 2 1 1 1 2 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 1 2 3 3 2 1 2 2 1 2 1 1 1 1 1 1 1 1 1 1 1 2 3 4 5 6 7 8 9 1 1 1 1 1 1 2 2 2 3 1 2 2 1 1 1 1 1 2 1 2 2 2 3 4 4 4 1 1 2 3 4 5 6 7 7 7 1 1 2 2 2 3 3 2 2 1 1 1 1 1 1 1 1 1 1 2...
result:
wrong answer Jury found better answer than participant (test case 17)