码迷,mamicode.com
首页 > 其他好文 > 详细

UVA1605-Building for UN(思维)

时间:2018-09-08 23:28:46      阅读:206      评论:0      收藏:0      [点我收藏+]

标签:include   nat   and   col   cas   input   print   rect   show   

Problem UVA1605-Building for UN

Accept: 398  Submit: 2303
Time Limit: 10000 mSec

技术分享图片 Problem 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 ?oors, one on top of another. Each ?oor is a rectangular grid of the same dimensions, each cell of this grid is an o?ce. Two o?ces are considered adjacent if they are located on the same ?oor and share a common wall, or if one’s ?oor is the other’s ceiling. The St. Petersburg building will host n national missions. Each country gets several o?ces 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 o?ces, 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

Input consists of several datasets. Each of them has a single integer number n (1 ≤ n ≤ 50) — the number of countries that are hosted in the building.

技术分享图片 Output

On the ?rst line of the output for each dataset write three integer numbers h, w, and l — height, width and length of the building respectively. h descriptions of ?oors should follow. Each ?oor description consists of l lines with w characters on each line. Separate descriptions of adjacent ?oors with an empty line. Use capital and small Latin letters to denote o?ces of di?erent countries. There should be at most 1 000 000 o?ces in the building. Each o?ce should be occupied by a country. There should be exactly n di?erent countries in the building. In this problem the required building design always exists. Print a blank line between test cases.

 

技术分享图片 Sample Input

4
 

技术分享图片 Sample Output

2 2 2

AB

CC


zz zz

 

题解:水题,啥限制都没有,不要求最小,字典序之类的,随便画一画就出来了。

 

 1 #include <bits/stdc++.h>
 2 
 3 using namespace std;
 4 
 5 const int maxn = 60;
 6 
 7 char gra[maxn][maxn], gra2[maxn][maxn];
 8 
 9 int main()
10 {
11     int n;
12     while (~scanf("%d", &n)) {
13         printf("%d %d %d\n", 2, n, n);
14         for (int i = 0; i < n; i++) {
15             for (int j = 0; j < n; j++) {
16                 if(i < 26) gra[i][j] = A + i;
17                 else gra[i][j] = a + i - 26;
18             }
19         }
20 
21         for (int j = 0; j < n; j++) {
22             for (int i = 0; i < n; i++) {
23                 if(j < 26) gra2[i][j] = A + j;
24                 else gra2[i][j] = a + j - 26;
25             }
26         }
27 
28         for (int i = 0; i < n; i++) {
29             for (int j = 0; j < n; j++) {
30                 printf("%c", gra[i][j]);
31             }
32             printf("\n");
33         }
34         printf("\n");
35         for (int i = 0; i < n; i++) {
36             for (int j = 0; j < n; j++) {
37                 printf("%c", gra2[i][j]);
38             }
39             printf("\n");
40         }
41         printf("\n");
42     }
43     return 0;
44 }

 

UVA1605-Building for UN(思维)

标签:include   nat   and   col   cas   input   print   rect   show   

原文地址:https://www.cnblogs.com/npugen/p/9610962.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!