QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#729306 | #9574. Strips | ucup-team3282# | WA | 61ms | 3848kb | C++20 | 1.4kb | 2024-11-09 16:52:00 | 2024-11-09 16:52:00 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int maxn=1e5+10;
typedef long long ll;
int n,m,k,w;
int a[maxn];
int b[maxn];
pair<int,bool> t[maxn*2];
vector<int> ans;
int main(){
ios::sync_with_stdio();
int T;
cin>>T;
while(T--){
cin>>n>>m>>k>>w;
for(int i=1;i<=n;i++)
cin>>a[i];
for(int i=1;i<=m;i++)
cin>>b[i];
for(int i=1;i<=n;i++)
t[i]={a[i],0};
for(int i=n+1;i<=n+m;i++)
t[i]={b[i-n],1};
t[n+m+1]={w+1,1};
t[0]={0,1};
sort(t+1,t+n+m+2);
int lp=0,rp=0;
ans.clear();
for(int i=1;i<=n+m+1;i++){
if(t[i].second){
rp=i;
int cnt=0,r=-k;
vector<int> res;
for(int j=lp+1;j<rp;j++){
if(r+k-1<t[j].first){
r=t[j].first;
cnt++;
res.push_back(r);
}
}
// cout<<"t "<<t[lp].first<<' '<<t[rp].first<<endl;
if((ll)cnt*k>t[rp].first-t[lp].first-1){
ans.clear();
break;
}
if(res.empty())
continue;
if(res.back()+k-1>=t[rp].first){
res.back()=t[rp].first-k;
}
for(int id=cnt-2;id>=0;id--){
if(res[id]+k-1>=res[id+1])
res[id]=res[id+1]-k;
}
for(int tmp:res)
ans.push_back(tmp);
lp=rp;
}
}
if(ans.empty()){
cout<<-1<<endl;
}
else{
cout<<ans.size()<<endl;
for(int t:ans)
cout<<t<<' ';
cout<<endl;
}
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3596kb
input:
4 5 2 3 16 7 11 2 9 14 13 5 3 2 4 11 6 10 2 1 11 2 1 2 6 1 5 3 2 1 2 6 1 5 2
output:
4 2 7 10 14 -1 2 1 5 -1
result:
ok ok 4 cases (4 test cases)
Test #2:
score: -100
Wrong Answer
time: 61ms
memory: 3848kb
input:
11000 3 8 2 53 32 3 33 35 19 38 20 1 30 10 6 7 10 1 42 3 14 4 36 28 40 22 17 20 12 41 27 7 1 19 13 9 6 6 13 78 55 76 53 32 54 58 62 45 21 4 7 61 8 7 3 68 9 26 54 31 22 3 38 65 34 16 58 47 52 29 53 5 8 4 33 33 5 30 6 15 27 12 9 28 19 2 13 10 6 1 2 48 8 12 48 1 41 31 40 7 6 7 61 20 19 30 52 49 17 40 3...
output:
6 1 3 10 20 32 38 11 1 3 4 9 13 14 19 22 28 36 40 -1 9 3 9 22 26 31 38 50 54 65 -1 6 1 8 12 31 41 47 -1 -1 -1 -1 -1 6 3 24 33 43 48 60 2 4 31 5 10 20 31 41 51 5 3 6 16 30 33 5 4 25 30 41 42 5 3 7 17 44 60 -1 4 34 49 54 66 7 1 18 32 40 50 59 65 5 13 41 51 62 78 2 20 81 4 2 11 16 23 5 3...
result:
wrong answer Integer parameter [name=c] equals to 6, violates the range [-1, 3] (test case 1)