# CF618F Double Knapsack

## 代码

#include<bits/stdc++.h>
using namespace std;
#define re register
#define ll long long
#define get getchar()
#define in inline
{
int t=0; char ch=get;
while(ch<'0' || ch>'9') ch=get;
while(ch<='9' && ch>='0') t=t*10+ch-'0', ch=get;
return t;
}
const int _=2e6+6;
int n,a[_],b[_];
ll suma[_],sumb[_],x[_],y[_];
bool f[_];
int main()
{
for(re int i=1;i<=n;i++)
for(re int i=1;i<=n;i++)
int fff=0;
if(sumb[n]<suma[n]) {
for(re int i=1;i<=n;i++) {
ll t=a[i];
a[i]=b[i],b[i]=t;
t=suma[i];
suma[i]=sumb[i],sumb[i]=t;
}
fff=1;
}
int j=0;
for(re int i=0;i<=n;i++) {
while(sumb[j]<suma[i]) j++;
int k=sumb[j]-suma[i];
if(f[k])
{
if(!fff) {
cout<<i-x[k]<<endl;
for(re int p=x[k]+1;p<=i;p++)
cout<<p<<' ';cout<<endl;
cout<<j-y[k]<<endl;
for(re int p=y[k]+1;p<=j;p++)
cout<<p<<' ';cout<<endl;
}
else {
cout<<j-y[k]<<endl;
for(re int p=y[k]+1;p<=j;p++)
cout<<p<<' ';cout<<endl;
cout<<i-x[k]<<endl;
for(re int p=x[k]+1;p<=i;p++)
cout<<p<<' ';cout<<endl;
}
return 0;
}
f[k]=1;
x[k]=i,y[k]=j;
}
}


posted @ 2019-10-25 15:13  yzhx  阅读(136)  评论(1编辑  收藏  举报