QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#724796 | #9574. Strips | Time_stop | WA | 0ms | 3640kb | C++14 | 2.6kb | 2024-11-08 15:05:58 | 2024-11-08 15:05:58 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int M =2e5+5;
int n,m;
struct s{
long long x;
bool flag;
};
s input[M];
bool cmp(s x,s y){
return x.x<y.x;
}
long long k,rr;
int main(){
int t;
cin>>t;
while(t--){
cin>>n>>m>>k>>rr;
int fl=0;
for(int i=1;i<=n;i++){
cin>>input[i].x;
input[i].flag=0;
}
for(int i=n+1;i<=n+m;i++){
cin>>input[i].x;
input[i].flag=1;
}
input[n+m+1].x=rr+1;
input[n+m+1].flag=1;
sort(input+1,input+n+m+2,cmp);
vector<long long> sum;
int l=0,r=0;
for(int i=1;i<=n+m+1;i++){
if(input[i].flag==1){
vector<long long> ans;
r=i;
long long res=0;
int tot=0,pop=input[l].x;
for(int j=l+1;j<r;j++){
if(input[j].x>pop){
res+=input[j].x-pop-1;
ans.push_back(input[j].x);
pop=input[j].x+k-1;
if(input[r].x-input[j].x<k){
int sn=input[r].x-input[j].x;
if(k-sn>res){
fl=1;
break;
}
else{
tot=k-sn;
break;
}
}
}
}
if(fl){
break;
}
for(int k=0;k<ans.size();k++){
sum.push_back(ans[k]-tot);
}
l=i;
}
}
if(fl){
cout<<-1<<endl;
}
else{
cout<<sum.size()<<endl;
for(int i=0;i<sum.size();i++){
cout<<sum[i]<<' ';
}
cout<<endl;
}
}
}
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 6 10 14 -1 2 1 5 -1
result:
wrong answer There is no stripe covering red cell 9 (test case 1)