QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#796296 | #9574. Strips | shinonomezhou | WA | 0ms | 3640kb | C++20 | 1.8kb | 2024-12-01 16:11:20 | 2024-12-01 16:11:22 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
using pll=pair<ll,ll>;
vector<ll>ve;
ll n,m,k,w;
int main(){
ios::sync_with_stdio(0);
cin.tie(0),cout.tie(0);
int tt;
cin>>tt;
while(tt--){
vector<ll>ans;
cin>>n>>m>>k>>w;
// set<ll>redd,blk;
vector<ll>red,blk;
for(int i=0;i<n;i++){
ll x;
cin>>x;
red.push_back(x);
}
for(int i=0;i<m;i++){
ll x;
cin>>x;
blk.push_back(x);
}
blk.push_back(0),blk.push_back(w+1);
sort(red.begin(),red.end()),sort(blk.begin(),blk.end());
// cout<<"black:";
// for(auto it:blk)cout<<it<<' ';cout<<'\n';
ll flag=0;
ll posr=0,posb=0;
while(posb<blk.size()-1){
ll l=blk[posb],r=blk[posb+1];posb++;
// cout<<l<<' '<<r<<"y\n";
ve.clear();
for(;posr<red.size();posr++){
if(red[posr]>r)break;
if(red[posr]>=l&&red[posr]<=r)ve.push_back(red[posr]);
}
if(ve.empty()){
continue;
}
ll dis=ve[ve.size()-1]-ve[0]+1;
ll tmp=dis/k;
if(dis%k)tmp++;
if(tmp*k>r-l-1){
flag=1;
break;
}
vector<ll>ans1;
ll up=min((ll)ve.size(),(r-l-1)/k);
ll sta=ve[0],ed=sta+k-1,pos=0;
ll x=0;
for(ll i=1;i<=up;i++){
ans1.push_back(sta);
while(pos<ve.size()&&ve[pos]<=ed){
pos++;
}
if(pos==ve.size()){
x=i;
break;
}
else {
sta=ve[pos],ed=sta+k-1;
}
}
ll last=r-1;
for(int i=ans1.size()-1;i>=0;i--){
ll sta=ans1[i],ed=sta+k-1;
if(ed>last){
ans1[i]-=ed-last;
last=ans[i]-1;
}
else break;
}
for(auto it:ans1){
ans.push_back(it);
}
}
if(flag){
cout<<-1<<'\n';
continue;
}
cout<<ans.size()<<'\n';
for(auto it:ans)cout<<it<<' ';cout<<'\n';
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3640kb
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 -3 10 14 -1 2 1 5 -1
result:
wrong answer Integer parameter [name=l_i] equals to -3, violates the range [1, 14] (test case 1)