33OJ
登录 注册

#P18104. [COCI 2026/2027 #2] Dijamanti

    ID: 20865 远端评测题 1000ms 512MiB 尝试: 0 已通过: 0 显示难度普及− 上传者: 标签>模拟数学COCI(克罗地亚)2026

[COCI 2026/2027 #2] Dijamanti

Problem Description

After Ivor acquired substantial wealth through hard work and perseverance, he decided to carefully invest in some nice diamonds. He currently owns nn diamonds, safely stored in his diamond box. Each diamond has its own size. The size of each diamond is an odd positive integer.

Every time Ivor goes on a trip (which is quite often), he wants to make sure nobody messes with his diamonds while he is away. That is why he makes a sketch of his box, including all the diamonds, on a piece of paper before he leaves for a trip. When he comes back, he will compare the state of the box with the one depicted in the sketch to see if anything has changed.

The diamond box is divided into nn compartments, each containing exactly one diamond. The diamonds are arranged in a single row, from left to right, and the size of the ii-th diamond is given by aia_i.

In a sketch, each diamond is made up of the character X and has a diamond shape. Its widest row consists of exactly aia_i X characters. Starting from the widest row, each row above and below it contains two fewer X characters than the row immediately below or above it, respectively. The topmost and bottommost rows therefore consist of a single X.

The compartment of the ii-th diamond is exactly aia_i characters wide. The remaining spaces inside each compartment are represented by the character *. Each diamond is horizontally centered within its compartment.

The compartments are separated by vertical borders represented by the character |. The left and right borders of the box are also represented by |, while the top and bottom borders, including the corners of the box, are represented by -.

All compartments have the same height, determined by the largest diamond. Diamonds that are shorter are vertically centered within their compartments.

Since Ivor is a very busy man, he unfortunately does not have enough time to make the sketch before he leaves tomorrow. That’s why he asked you, his friend, to help him. Will you sketch Ivor’s diamond box for him?

Input Format

The first line contains a positive integer nn (1≤n≤1001 \le n \le 100), the number of diamonds in Ivor’s diamond box.

The second line contains nn odd positive integers a1,a2,…,ana_1, a_2, \ldots, a_n (1≤ai≤1001 \le a_i \le 100), the sizes of the diamonds.

Output Format

Output the sketch of Ivor’s diamond box, following the rules described in the task statement.

1
9
-----------
|****X****|
|***XXX***|
|**XXXXX**|
|*XXXXXXX*|
|XXXXXXXXX|
|*XXXXXXX*|
|**XXXXX**|
|***XXX***|
|****X****|
-----------
4
3 1 5 3
-----------------
|***|*|**X**|***|
|*X*|*|*XXX*|*X*|
|XXX|X|XXXXX|XXX|
|*X*|*|*XXX*|*X*|
|***|*|**X**|***|
-----------------
4
7 3 7 5
---------------------------
|***X***|***|***X***|*****|
|**XXX**|***|**XXX**|**X**|
|*XXXXX*|*X*|*XXXXX*|*XXX*|
|XXXXXXX|XXX|XXXXXXX|XXXXX|
|*XXXXX*|*X*|*XXXXX*|*XXX*|
|**XXX**|***|**XXX**|**X**|
|***X***|***|***X***|*****|
---------------------------

Hint

Explanation of example 1

The box contains only one diamond, whose size is 99. Its widest row consists of 99 X characters, and each row above and below it contains two fewer X characters than the previous row.

Explanation of example 2

The largest diamond has size 55, so the box is 55 rows tall. The diamonds of sizes 33 and 11 are vertically centered within their compartments, while all diamonds are horizontally centered.

Scoring

Subtask Points Constraints
1 15 n=1n = 1.
2 9 ai=1a_i = 1 or ai=3a_i = 3 for every i=1,2,…,ni = 1, 2, \ldots, n.
3 6 a1=a2=⋯=ana_1 = a_2 = \cdots = a_n.
4 20 No additional constraints.