POJ 3566 Building for UN (無腦構造 水題)
Time Limit: 5000MS | Memory Limit: 65536K | |||
Total Submissions: 1872 | Accepted: 832 | 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 h, w, 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 n different 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
Source
題目連結:http://poj.org/problem?id=3566
題目大意:用大寫或小寫字母表示一個國家的所有房間,有n個國家,要求任意兩個國家至少有一個房間相鄰(上下左右前後6個方向),每個國家自己所有的房間要是一個連通集合,求可行的構造方案
題目分析:在紙上畫畫即可
#include <cstdio>
char ans[100] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
int main()
{
int n;
while(scanf("%d", &n) != EOF)
{
printf("2 %d %d\n", n, n);
for(int i = 0; i < n; i++)
{
for(int j = 0; j < n; j++)
printf("%c", ans[i]);
printf("\n");
}
printf("\n");
for(int i = 0; i < n; i++)
{
for(int j = 0; j < n; j++)
printf("%c", ans[j]);
printf("\n");
}
}
}
相關文章
- Poj--3080Blue Jeans+KMP水題KMP
- POJ 2823Sliding Window(單調佇列水題)佇列
- CF 構造題
- POJ2031 Building a Space Station(最小生成樹,prim)UI
- 構造做題筆記筆記
- 不要讓創造力枯竭——初探《建築故事》(Building Stories)UI
- 智慧水務系統:構建高效節水的城市水網
- 【lombok】@NoArgsConstructor/@RequirArgsConstructor/@AllArgsConstructor - 生成無參構造器,指定引數構造器或包含所有引數的構造器LombokStructUI
- [How HTTPS works Part 1 — Building Blocks] HTTPS 的工作方式第 1 部分-基本構造塊HTTPUIBloC
- POJ 2031-Building a Space Station(最小生成樹-三維座標系)UI
- 莫隊的 1.5 近似構造 題解
- 構建微服務(Building Microservices)-PDF 文件微服務UIROS
- Java--構造器和構造方法Java構造方法
- 架構高可用之限流-抽刀斷水水更流架構
- C++ 建構函式實戰指南:預設構造、帶引數構造、複製構造與移動構造C++函式
- 無水乾貨:InnoDB底層原理
- 構造方法構造方法
- 構造器
- 反射-通過反射獲取無參構造方法並使用反射構造方法
- 3 月水題練習
- 無水乾貨-如何快速分析Linux伺服器的效能問題Linux伺服器
- Arduino BuildingUI
- Team BuildingUI
- 構造點,線結構
- 【轉載】POJ 圖論題目圖論
- POJ3984-迷宮問題
- CSS構造塊CSS
- Redis鎖構造Redis
- java構造器Java
- Format and un-format money/currency in JavaScriptORMJavaScript
- 二叉排序樹(水題)排序
- rk3566 新增MCP2515模組
- 靜態程式碼塊、構造程式碼塊、構造方法構造方法
- team building planUI
- Servlet呼叫構造方法,物件傳不進建構函式中去問題Servlet構造方法物件函式
- 深度學習問題記錄:Building your Deep Neural深度學習UI
- 構造無限級樹並深度遍歷查詢指定節點
- 【智慧製造】工業軟體:智慧製造的大腦