C. A Mist of Florescence

题意:一张图由ABCD构成(50*50),要求分别有a,b,c,d(100)个联通块.

思路:

#include<bits/stdc++.h>
#define PI acos(-1.0)
#define pb push_back
#define F first
#define S second
#define debug puts
#define setp cout << fixed << setprecision(3)
#define FAST_IO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
typedef long long ll;
const int N=3e5+5;
const int MOD=1e9+7;
const ll INF=1e18+8;
struct node{
    int cnt;
    char ch;
}p[5];

bool cmp(node a,node b){
    return a.cnt<b.cnt;
}
char ans[60][60];
int main(void){
//    FAST_IO;
    for(int i=1;i<=4;i++){
        int cnt;cin>>cnt;
        p[i].cnt=cnt-1;
        p[i].ch='A'+i-1;
//        printf("%c",p[i].ch);
    }
    cout << 48 << " "<< 50 << endl;
    sort(p+1,p+1+4,cmp);
    for(int i=1;i<=12;i++){
        for(int j=1;j<=50;j++)  ans[i][j]=p[1].ch;
    }

    for(int i=13;i<=24;i++){
        for(int j=1;j<=50;j++)  ans[i][j]=p[2].ch;
    }

    for(int i=25;i<=36;i++){
        for(int j=1;j<=50;j++)  ans[i][j]=p[3].ch;
    }

    for(int i=37;i<=48;i++){
        for(int j=1;j<=50;j++)  ans[i][j]=p[4].ch;
    }

    char ch=p[4].ch;
    int cnt=p[4].cnt;
    for(int i=2;i<=12&&cnt;i+=2){
        for(int j=1;j<=50&&cnt;j+=2){
            ans[i][j]=ch;
            cnt--;
        }
    }

    ch=p[3].ch;
    cnt=p[3].cnt;
    for(int i=13+1;i<=24&&cnt;i+=2){
        for(int j=1;j<=50&&cnt;j+=2){
            ans[i][j]=ch;
            cnt--;
        }
    }

    ch=p[2].ch;
    cnt=p[2].cnt;
    for(int i=25+1;i<=36&&cnt;i+=2){
        for(int j=1;j<=50&&cnt;j+=2){
            ans[i][j]=ch;
            cnt--;
        }
    }

    ch=p[1].ch;
    cnt=p[1].cnt;
    for(int i=37+1;i<=48&&cnt;i+=2){
        for(int j=1;j<=50&&cnt;j+=2){
            ans[i][j]=ch;
            cnt--;
        }
    }

    for(int i=1;i<=48;i++){
        for(int j=1;j<=50;j++)  cout << ans[i][j];
        cout <<"\n";
    }

    return 0;
}