QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#772997 | #9574. Strips | buling | Compile Error | / | / | C++14 | 2.0kb | 2024-11-22 23:21:25 | 2024-11-22 23:21:29 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define lll i << 1
#define rrr i << 1 | 1
const int N=2e5+6;
int ma,mi;
int n,m,a[N],b[N],dd[N];
int ans=0;
void solve()
{
string s,s2;
int res=0,q,re;
ans=0;
cin>>n>>m>>re>>q;
for(int i=1;i<=n;i++)
cin>>a[i];
for(int j=1;j<=m;j++)
cin>>b[j];
sort(a+1,a+n+1);
sort(b+1,b+m+1);
b[++m]=q+1;
int j=1;
for(int i=0;i<=m;i++)
{
for(;j<=n;)
{
map<int,int> mp;
int k=j,l=b[i],tt=0;
if(b[i]<a[j]&&b[i+1]>a[j])
{
for(k=j;k<=n;k++)
{
if(b[i]<a[k]&&b[i+1]>a[k])
{
if(l>=a[k])
continue;
tt++;
int r=min(b[i+1]-1,a[k]+re-1);
int yy=r-re+1;
int mm=l-yy+1;
if(yy>l)
{
mp[tt]+=yy-l-1;
if(mp[tt]==0)
mp.erase(tt);
}
else
{
for (auto it = mp.rbegin(); it != mp.rend(); it++)
{
auto &[x,y]=*it;
if(y<=mm)
{
mm-=y;
y=0;
mp.erase(x);
if(mp.size()==0)
break;
}
else
{
y-=mm;
mm=0;
}
}
}
if(mm>0)
{
cout<<-1<<"\n";
return ;
}
l=r;
}
else
break;
}
int rer=b[i];
for(int qw=ans+1;qw<=ans+tt;qw++)
{
dd[qw]=rer+mp[qw-ans]+1;
//cout<<qw<<" "<<j<<" "<<b[i]<<" "<<mp[qw-ans]<<" "<<rer<<" "<<dd[qw]<<"\n";
rer=dd[qw]+re-1;
}
j=k;
}
else
break;
ans+=tt;
}
}
cout<<ans<<"\n";
for(int i=1;i<=ans;i++)
cout<<dd[i]<<" ";
for(int i=1;i<=max(n,m,ans);i++)
{
a[i]=b[i]=dd[i]=0;
}
cout<<"\n";
}
signed main()
{
std::ios::sync_with_stdio(false);//取消cin与stdin同步,加速读入
cin.tie(0);cout.tie(0);
int t;
t=1;
cin>>t;
while(t--)
{
solve();
}
return 0;
}
详细
answer.code: In function ‘void solve()’: answer.code:61:67: warning: structured bindings only available with ‘-std=c++17’ or ‘-std=gnu++17’ [-Wc++17-extensions] 61 | auto &[x,y]=*it; | ^ In file included from /usr/include/c++/13/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:51, from answer.code:1: /usr/include/c++/13/bits/stl_algobase.h: In instantiation of ‘constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare) [with _Tp = int; _Compare = int]’: answer.code:106:20: required from here /usr/include/c++/13/bits/stl_algobase.h:306:17: error: ‘__comp’ cannot be used as a function 306 | if (__comp(__a, __b)) | ~~~~~~^~~~~~~~~~