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
4Sample 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(思維)