不难想,但是边界特判真的搞死人
因为每一个0都会和每一个1配对,配对结果会贡献给01或10
/*
x个1形成x*(x-1)/2个
111111
*/
#include <bits/stdc++.h>
using namespace std;
#define int long long
int a,b,c,d;
map<int,int>mp;
signed main()
{
mp[0]=1;
for(int i=2;i*(i-1)/2<=1e9;i++) mp[i*(i-1)/2]=i;
cin >> a >> b >> c >> d;
if( mp[a]==0||mp[d]==0 ) { cout << "Impossible\n";return 0;}
if( a+b+c+d==0 )//0,1都不存在
{
cout << 0;
return 0;
}
if( b+c+d==0 )//只存在0
{
while(mp[a]--) cout << 0;
return 0;
}
if( a+b+c==0 )//只存在1
{
while( mp[d]--) cout << 1;
return 0;
}
int zero=mp[a],one=mp[d];
if( zero*one!=b+c ) cout << "Impossible\n";
else
{
//考虑在1中插入0
while(1)
{
if( one<=b ) cout << 0 ,zero--,b-=one;
else cout << 1 ,one--;
if( b==0 ) break;
}
while( one-- ) cout << 1 ;
while( zero-- ) cout << 0 ;
}
}