zoukankan      html  css  js  c++  java
  • CF989C A Mist of Florescence 构造 思维好题 第八题

    A Mist of Florescence
    time limit per test
    1 second
    memory limit per test
    256 megabytes
    input
    standard input
    output
    standard output
    As the boat drifts down the river, a wood full of blossoms shows up on the riverfront.

    "I've been here once," Mino exclaims with delight, "it's breathtakingly amazing."

    "What is it like?"

    "Look, Kanno, you've got your paintbrush, and I've got my words. Have a try, shall we?"

    There are four kinds of flowers in the wood, Amaranths, Begonias, Centaureas and Dianthuses.

    The wood can be represented by a rectangular grid of nn rows and mm columns. In each cell of the grid, there is exactly one type of flowers.

    According to Mino, the numbers of connected components formed by each kind of flowers are aa, bb, cc and dd respectively. Two cells are considered in the same connected component if and only if a path exists between them that moves between cells sharing common edges and passes only through cells containing the same flowers.

    You are to help Kanno depict such a grid of flowers, with nn and mm arbitrarily chosen under the constraints given below. It can be shown that at least one solution exists under the constraints of this problem.

    Note that you can choose arbitrary nn and mm under the constraints below, they are not given in the input.

    Input

    The first and only line of input contains four space-separated integers aa, bb, cc and dd (1a,b,c,d1001≤a,b,c,d≤100) — the required number of connected components of Amaranths, Begonias, Centaureas and Dianthuses, respectively.

    Output

    In the first line, output two space-separated integers nn and mm (1n,m501≤n,m≤50) — the number of rows and the number of columns in the grid respectively.

    Then output nn lines each consisting of mm consecutive English letters, representing one row of the grid. Each letter should be among 'A', 'B', 'C' and 'D', representing Amaranths, Begonias, Centaureas and Dianthuses, respectively.

    In case there are multiple solutions, print any. You can output each letter in either case (upper or lower).

    Examples
    input
    Copy
    5 3 2 1
    output
    Copy
    4 7
    DDDDDDD
    DABACAD
    DBABACD
    DDDDDDD
    input
    Copy
    50 50 1 1
    output
    Copy
    4 50
    CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
    ABABABABABABABABABABABABABABABABABABABABABABABABAB
    BABABABABABABABABABABABABABABABABABABABABABABABABA
    DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD
    input
    Copy
    1 6 4 5
    output
    Copy
    7 7
    DDDDDDD
    DDDBDBD
    DDCDCDD
    DBDADBD
    DDCDCDD
    DBDBDDD
    DDDDDDD
    Note

    In the first example, each cell of Amaranths, Begonias and Centaureas forms a connected component, while all the Dianthuses form one.

     题意: 给你A,B,C,D连通量的数目(连通量指上或下或左或右有连接),要你给出一个矩阵(给出的矩阵长宽小于等于50)满足这样的要求

    引入别人博客的一张图

    图中说明了一切  将你的矩阵四分,分别填充B,A,D,C,然后在这四个矩阵中按要求填充

    #include <map>
    #include <set>
    #include <cmath>
    #include <queue>
    #include <cstdio>
    #include <vector>
    #include <string>
    #include <cstring>
    #include <iostream>
    #include <algorithm>
    #define debug(a) cout << #a << " " << a << endl
    using namespace std;
    const int maxn = 1e2 + 10;
    const int mod = 1e9 + 7;
    typedef long long ll;
    char mapn[maxn][maxn];
    void myfill( ll xs, ll ys, ll xe, ll ye, char c ) {
        for( ll i = xs; i <= xe; i ++ ) {
            for( ll j = ys; j <= ye; j ++ ) {
                mapn[i][j] = c;
            }
        }
    }
    int main(){
        std::ios::sync_with_stdio(false);
        ll a, b, c, d;
        while( cin >> a >> b >> c >> d ) {
            a --, b --, c --, d --;
            myfill( 0, 0, 24, 24, 'B' );
            myfill( 0, 25, 24, 49, 'A' );
            myfill( 25, 0, 49, 24, 'D' );
            myfill( 25, 25, 49, 49, 'C' );
            for( ll i = 0; i <= 24; i ++ ) {
                for( ll j = 0; j <= 24; j ++ ) {
                    if( i % 2 && j % 2 && a ) {
                        mapn[i][j] = 'A';
                        a --;
                    }
                }
            }
            for( ll i = 0; i <= 24; i ++ ) {
                for( ll j = 25; j <= 49; j ++ ) {
                    if( i % 2 == 0 && j % 2 == 0 && b ) {
                        mapn[i][j] = 'B';
                        b --;
                    }
                }
            }
            for( ll i = 25; i <= 49; i ++ ) {
                for( ll j = 0; j <= 24; j ++ ) {
                    if( i % 2 && j % 2 && c ) {
                        mapn[i][j] = 'C';
                        c --;
                    }
                }
            }
            for( ll i = 25; i <= 49; i ++ ) {
                for( ll j = 25; j <= 49; j ++ ) {
                    if( i % 2 == 0 && j % 2 == 0 && d ) {
                        mapn[i][j] = 'D';
                        d --;
                    }
                }
            }
            cout << "50 50" << endl;
            for( ll i = 0; i <= 49; i ++ ) {
                cout << mapn[i] << endl;
            }
        }
        return 0;
    }
    彼时当年少,莫负好时光。
  • 相关阅读:
    同步类容器和并发类容器
    T4模板生成自定义的实体类
    C# UrlEncode 编码
    PLSQL快速生成增删改查语句
    Oracle 检查星期只能是1-7的数字不能重复
    PLSQL 插入数据无响应
    C# DataTable 排序
    C# 获取程序集信息
    C# 调用WinRAR解压缩文件
    DataTable 获取一列最大值并修改
  • 原文地址:https://www.cnblogs.com/l609929321/p/9220046.html
Copyright © 2011-2022 走看看