QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#360394 | #7942. $K$ Subsequences | Vengeful_Spirit# | WA | 0ms | 3672kb | C++20 | 1.5kb | 2024-03-21 18:50:00 | 2024-03-21 18:50:00 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5;
int res[N];
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
int T;
cin>>T;
while(T--){
int n,k;
cin>>n>>k;
vector<int>a,b;
for(int i=1;i<=n;i++){
int x;
cin>>x;
if(x==1)a.push_back(i);
else b.push_back(i);
}
int cnt=0,p=0,q=0;
// n%k * n/k+1 (k-n%k) *n/k
for(int i=1;i<=k;i++){
// cout<<"check "<<a.size()%k<<endl;
if(i<=a.size()%k){
for(int j=1;j<=a.size()/k+1;j++){
res[a[p++]]=i;
}
}
else{
for(int j=1;j<=a.size()/k;j++){
res[a[p++]]=i;
// cout<<"set "<<a[p]<<" "<<i<<endl;
}
}
}
for(int i=1;i<=k;i++){
if(i<=b.size()%k){
for(int j=1;j<=b.size()/k+1;j++){
res[b[q++]]=i;
}
}
else{
for(int j=1;j<=b.size()/k;j++){
res[b[q++]]=i;
}
}
}
for(int i=1;i<=n;i++){
cout<<res[i]<<" ";
}
cout<<"\n";
}
}
/*
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
1 1 2
1 1 2 2
1 1 1 2 2 2 3
1 1 1 2 1 2 2 2 3 3
1 1 2 2 1 2 3 4 3 3 4 4
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3672kb
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 2 1 1 2 2 1 1 1 2 2 3 3 1 1 1 2 1 2 2 2 3 3 1 1 2 2 1 2 3 4 3 3 4 4
result:
wrong answer Jury found better answer than participant (test case 4)