Building for the UN
InterviewTime limit3sMemory limit128 MB
Print a fixed two-floor n by n grid where the lower floor's rows and upper floor's columns each represent a labeled country, satisfying a connectivity and adjacency construction.
- Level
Easy3 of 10
- Topics
- Implementation, Simulation, Matrix
- Solved
- No attempts yet
Statement
The United Nations is going to construct a new headquarters shaped like a rectangular box. The building is made of several identical rectangular floors stacked one on top of another. Every floor is a rectangular grid of the same size, and every cell of the grid is one office.
Two offices are adjacent when they lie on the same floor and share a wall, or when one sits directly on top of the other (the ceiling of the lower office is the floor of the upper one).
The building must host national missions. Each country receives a set of offices, and the offices belonging to one country must form a connected region: from any office of a country you can reach every other office of the same country by stepping between adjacent offices of that country.
Because any two countries may want to negotiate privately behind a shared wall or ceiling, every pair of countries must own at least one pair of adjacent offices.
Such a building always exists. So that the answer is unique, you must output the specific valid building described in the Output section.
Input
A single line with one integer () — the number of countries.
Output
Construct the building exactly as follows, then print it.
- The building has height (two floors), and each floor is an grid: rows, each of characters.
- Label the countries with the first characters of the sequence (all uppercase letters first, then all lowercase letters). Call these labels .
- Lower floor: every office in row belongs to country , so row is the character repeated times.
- Upper floor: every office in column belongs to country , so every row equals .
First print three integers , , and — the height, width, and length of the building; here and . Then print the lower floor as lines of characters, print one empty line, and print the upper floor as lines of characters.