QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#762411 | #9574. Strips | szy10010 | WA | 0ms | 3756kb | C++23 | 1.7kb | 2024-11-19 14:54:29 | 2024-11-19 14:54:32 |
Judging History
answer
#include<iostream>
#include<set>
#include<queue>
#include<map>
#include<cmath>
#include<string>
#include<vector>
#include<cstring>
#include<algorithm>
#include<unordered_map>
#define pb push_back
#define fi first
#define se second
#define int long long
#define all(x) (x).begin(),(x).end()
#define _for(i, a) for(int i = 0; i < (a); ++i)
#define _rep(i, a, b) for(int i = (a);i <= (b); ++i)
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define u1 (u<<1)
#define u2 (u<<1|1)
#define endl '\n'
using namespace std;
typedef pair<int,int> PII;
const int INF=0x3f3f3f3f;
const int P=1e9+7;
const int N=1e5+20,M=2*N;
int n,m,k,w,num;
void solve(){
vector<int> v;
cin>>n>>m>>k>>w;
priority_queue<int,vector<int>,greater<>> q;
_for(i,n){
cin>>num;
q.push(num);
}
_for(i,m){
cin>>num;
v.pb(num);
}
v.pb(0);
v.pb(w+1);
sort(all(v));
vector<int> res;
_rep(i,1,v.size()-1){
vector<PII> ans;
int l=v[i-1];
int r=v[i];
int now=l;
while(q.size()&&q.top()<=r){
int t=q.top();
if(now<t){
ans.pb({t,t-now-1});
// cout<<t<<" "<<t-now-1<<" ";
now=t+k-1;
// cout<<now<<endl;
}
q.pop();
}
int d=max(now-r+1,(int)0);
for(int i=ans.size()-1;i>=0;i--){
if(d==0){
res.pb(ans[i].fi);
}else{
if(d>=ans[i].se){
d-=ans[i].se;
}else{
int c=ans[i].fi-d;
d=0;
while(c<r){
res.pb(c);
c+=k;
}
}
}
}
if(d>0){
cout<<-1<<endl;
return;
}
}
cout<<res.size()<<endl;
_for(i,res.size()){
cout<<res[i]<<" ";
}
cout<<endl;
}
signed main(){
IOS;
int T=1;
cin>>T;
_rep(i,1,T){
solve();
}
return 0;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3756kb
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:
3 2 7 14 -1 2 1 5 -1
result:
wrong answer There is no stripe covering red cell 11 (test case 1)