POJ 3566 (弱校联萌十一大决战之厉兵秣马 B. Building for UN)

简介:
Building for UN
Time Limit: 5000MS   Memory Limit: 65536K
Total Submissions: 1788   Accepted: 805   Special Judge

Description

The United Nations has decided to build a new headquarters in Saint Petersburg, Russia. It will have a form of a rectangular parallelepiped and will consist of several rectangular floors, one on top of another. Each floor is a rectangular grid of the same dimensions, each cell of this grid is an office.

Two offices are considered adjacent if they are located on the same floor and share a common wall, or if one’s floor is the other’s ceiling.

The St. Petersburg building will host n national missions. Each country gets several offices that form a connected set.

Moreover, modern political situation shows that countries might want to form secret coalitions. For that to be possible, each pair of countries must have at least one pair of adjacent offices, so that they can raise the wall or the ceiling they share to perform secret pair-wise negotiations just in case they need to.

You are hired to design an appropriate building for the UN.

Input

The input file consists of a single integer number n (1 ≤ n ≤ 50) — the number of countries that are hosted in the building.

Output

On the first line of the output file write three integer numbers hw, and l — height, width and length of the building respectively.

h descriptions of floors should follow. Each floor description consists of l lines with w characters on each line. Separate descriptions of adjacent floors with an empty line.

Use capital and small Latin letters to denote offices of different countries. There should be at most 1 000 000 offices in the building. Each office should be occupied by a country. There should be exactly ndifferent countries in the building. In this problem the required building design always exists.

Sample Input

4

Sample Output

2 2 2
AB
CC

zz
zz


题目大意:

给定m个国家,然后联合国想建造办公室,每两个国家想要至少有相邻(可以上下,也可以左右相邻)的两个办公室,

然后用大写字母或者是小写字母表示国家,字母不同国家不同,输出有几层楼,几个办公室,几条办公室


解题思路;

题意要求至少有两个相邻的办公室,所以我们只需要每层的第一条是不同的国家,

第二条全是相同的国家,一共有n层

For example:

Input:

4

Output:

4 4 2
AAAA
ABCD


BBBB
ABCD


CCCC
ABCD


DDDD
ABCD

上代码:

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <queue>
#include <algorithm>
#include <set>
using namespace std;

#define MM(a) memset(a,0,sizeof(a))
typedef long long LL;
typedef unsigned long long ULL;
const int maxn = 1e3+5;
const int mod = 1000000007;
const double eps = 1e-7;
const double pi = 3.1415926;


char s[100];
int main()
{
    int n;
    while(cin>>n)
    {
        cout<<n<<" "<<n<<" "<<2<<endl;;
        for(int i=0; i<n; i++)
        {
            if(i <= 25)
                s[i] = 'A'+i;
            else
                s[i] = 'a'+i-26;
        }
        for(int j=0; j<n; j++)
        {
            for(int i=0; i<n; i++)
            {
                if(j <= 25)
                    cout<<char('A'+j);
                else
                    cout<<char('a'+j-26);
            }
            cout<<endl;
            for(int i=0; i<n; i++)
                cout<<s[i];
            puts("\n");
        }
    }
    return 0;
}


目录
相关文章
|
3月前
|
算法 C++
POJ 3740 Easy Finding题解
这篇文章提供了一个使用舞蹈链(Dancing Links)算法解决POJ 3740 "Easy Finding" 问题的C++代码实现,该问题要求找出矩阵中能够使每一列都恰好包含一个1的行集合。
UVa11157 - Dynamic Frog(动态规划)
UVa11157 - Dynamic Frog(动态规划)
57 0
|
人工智能 关系型数据库 Go
PRML Chapter01 练习题Exercise
PRML Chapter01 练习题Exercise
PRML Chapter01 练习题Exercise
Codeforces1486 C1.Guessing the Greatest (easy version)(交互题+二分)
Codeforces1486 C1.Guessing the Greatest (easy version)(交互题+二分)
91 0
Codeforces1486 C2.Guessing the Greatest (hard version)(交互题+奇怪的二分)
Codeforces1486 C2.Guessing the Greatest (hard version)(交互题+奇怪的二分)
48 0
|
人工智能 BI
[UVA 1599] Ideal Path | 细节最短路
Description New labyrinth attraction is open in New Lostland amusement park. The labyrinth consists of n rooms connected by m passages. Each passage is colored into some color ci .
203 0
POJ-2492,A Bug's Life(分类并查集)
POJ-2492,A Bug's Life(分类并查集)
|
Java 物联网 Go
洛谷 P1001 A+B Problem (java实现)
洛谷 P1001 A+B Problem (java实现)
LeetCode解题之二:Add Two Numbers
LeetCode解题之二:Add Two Numbers