Educational Codeforces Round 45 (Rated for Div. 2) D Graph And Its Complement(图的构造)
题意:构造一个图,使这个图的连通分量有a个,其补图的连通分量有b个,输出邻接矩阵
可以推出当min(a,b)!=1时输出no
a=b=1且n=2或者n=3时也为no
其余只要把一个连通分量里的x个点用x-1条边串起来就好了
哎,最后想到n=3也为no,可惜了..
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define inf 0x3f3f3f3f
#define pll pair<ll,ll>
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define rep1(i,a,b) for(int i=a;i>=b;i--)
#define rson rt<<1|1,m+1,r
#define lson rt<<1,l,m
#define mod 323232323
using namespace std;
const int N=1000+100;
int arr[N][N];
int main()
{
#ifdef LOCAL_DEFINE
freopen("D:\\rush.txt","r",stdin);
#endif
ios::sync_with_stdio(false),cin.tie(0);
int n,a,b;
cin>>n>>a>>b;
if((n==2||n==3)&&a==1&&b==1)
{
cout<<"NO"<<endl;
return 0;
}
if(min(a,b)!=1)
{
cout<<"NO"<<endl;
}
else
{
cout<<"YES"<<endl;
int c=max(a,b);
for(int i=1;i<=n-c;i++)
{
arr[i][i+1]=1;
arr[i+1][i]=1;
}
for(int i=1;i<=n;i++)
{
for(int j=1;j<=n;j++)
{
if(i==j)
cout<<0;
else if(c!=a)
cout<<!arr[i][j];
else
cout<<arr[i][j];
}
cout<<endl;
}
}
return 0;
}