日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程资源 > 编程问答 >内容正文

编程问答

Codeforces 989C (构造)

發(fā)布時(shí)間:2025/3/14 编程问答 16 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Codeforces 989C (构造) 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

傳送門(mén)

題面:

C. A Mist of Florescencetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputAs 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).

ExamplesinputCopy5 3 2 1 outputCopy4 7 DDDDDDD DABACAD DBABACD DDDDDDDinputCopy50 50 1 1 outputCopy4 50 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC ABABABABABABABABABABABABABABABABABABABABABABABABAB BABABABABABABABABABABABABABABABABABABABABABABABABA DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDinputCopy1 6 4 5 outputCopy7 7 DDDDDDD DDDBDBD DDCDCDD DBDADBD DDCDCDD DBDBDDD DDDDDDDNote

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

題目描述:

? ? 給你四個(gè)數(shù)a,b,c,d,分別代表四個(gè)字符A,B,C,D,的連通分量的個(gè)數(shù),讓你去構(gòu)造出最大為50*50的一個(gè)符合條件的圖。

題目分析:

? ? 我們可以考慮到如下的策略。首先我們可以確定將整張圖初始化為兩種字母,使得這兩種字母的連通分量分別為。

? ? 如n,m均為6時(shí),可以先構(gòu)造出:

AAAAAA
AAAAAA
AAAAAA
BBBBBB
BBBBBB
BBBBBB

這樣的一個(gè)矩陣。

? ? 其次,我們可以這么考慮,我們要使得C和D的連通分量增加,則我們就需要在圖中的A更新成C或B,在原來(lái)圖中的B更新成A或D。而要使得上下兩塊(A和B)的連通性不發(fā)生改變,我們就必須要間隔地進(jìn)行更改,比如上述的圖原來(lái)為.,我們要增加C的連通分量而使得原來(lái)A的不發(fā)生改變,則我們就需要將AAAA....變成CACA....即可,即變成下面的表格:

CACACA
CACACA
AAAAAA

此時(shí)A的連通分量不會(huì)發(fā)生改變,同理B也進(jìn)行如下操作即可。

? ? 而因?yàn)樽畲箢}目所給的a,b,c,d,均不知道范圍,因此我們就貪心地取最大就50即可。

代碼:

#include <bits/stdc++.h> using namespace std; char str[60][60]; int main() {int a,b,c,d;scanf("%d%d%d%d",&a,&b,&c,&d);for(int i=0;i<50;i++){for(int j=0;j<50;j++){if(i>25){str[i][j]='B';}else str[i][j]='A';}}a--,b--;for(int i=0;i<25;i+=2){for(int j=0;j<50;j+=2){if(b){str[i][j]='B';b--;}else if(c){str[i][j]='C';c--;}}}for(int i=27;i<50;i+=2){for(int j=0;j<50;j+=2){if(a){str[i][j]='A';a--;}else if(d){str[i][j]='D';d--;}}}puts("50 50");for(int i=0;i<50;i++){puts(str[i]);}return 0; }

轉(zhuǎn)載于:https://www.cnblogs.com/Chen-Jr/p/11007275.html

總結(jié)

以上是生活随笔為你收集整理的Codeforces 989C (构造)的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。