QOJ.ac

QOJ

Puntuación total: 100 Solo salida

#14961. Rhyme of the Wind

Estadísticas

Background

There is a special concert—no pianos, no cellos, no violins, and not even any performers, just some crystal wind chimes. Each wind chime can only play one note, and when all the notes are interwoven, the audience is mesmerized, feeling a wonderful harmony.

The concert uses a special stage. The surface of the stage is divided into $n \times n$ congruent square grids. The wind chimes required for the music are suspended in the air, directly above the centers of some grids. According to the melody design, a grid can have one wind chime suspended above it, or no wind chime at all, but it cannot have two or more wind chimes.

There is a special wind-powered driving device around the wind chimes. In each time segment, it can generate a thin breeze along a certain straight line, causing all wind chimes on that line to start playing, while all other wind chimes stop playing. Due to limited functionality, the driving device can only generate a total of $6n-2$ straight lines in 4 directions (in directions I, II, III, and IV, there are $n, n, 2n-1,$ and $2n-1$ lines respectively, called driving lines), as shown in Figure 1. Note that: in any time segment, the driving device may choose not to generate a breeze, but it cannot generate breezes on two lines simultaneously.

As someone with both musical talent and programming skills, you are invited to design the core part of the concert—the wind chime array. The entire concert is divided into several time segments, and each time segment requires a specific chord to be played, i.e., a combination of notes. To ensure the quality of the concert, your design must be able to play the entire concert accurately, meaning that for each time segment, there must exist a driving line such that the breeze on that line allows the wind chimes to play the desired chord. Specifically, if the notes corresponding to all wind chimes on that line form a multiset $S_1$, and the notes that should be played in that time segment form a multiset $S_2$, then $S_1$ must be equal to $S_2$.

For example, the wind chime array in Figure 2 can play the music in Figure 3 by driving lines 1, 2, and 3 in the 3 time segments respectively. Note that the second time segment cannot drive line 2', because although there is only note C on that line, there are two notes C in the music, while there is only one on line 2', so the auditory effect is different. Specifically, the multisets $\{C, C\}$ and $\{C\}$ are not the same. Similarly, the third time segment cannot drive line 3', because the multisets $\{C, G\}$ and $\{G\}$ are not the same. Although the required note G is played, an extra note C is also played. This is not allowed.

Figure 1. Four driving directions

Figure 2. Wind chime array

Figure 3. Music

Input

This is an answer-submission problem. All input files wind1.in through wind10.in are already placed in the user directory. The first line of each file contains an integer $n$, representing the number of time segments in the music. The next $n$ lines each contain one or more notes, separated by spaces. The format of each note is XYZ, where X is one of the uppercase letters C, D, E, F, G, A, B, representing the pitch name of the note; Y is either empty, or a single character '#', or a single character 'b'; Z is an integer from 1 to 7, representing the octave of the note. For example, D1, C#4, and Bb3 are all valid notes.

Output

For each input file, you need to provide the corresponding output file, which is the wind chime array you designed. The first line of the output file contains an integer $m$, the side length of the array. The following $m$ lines each contain $m$ notes, representing the notes that can be played by the wind chimes in the corresponding grids. Grids without wind chimes are represented by a single character ".".

Examples

Input 1

3 
C4 E4 
C4 C4 
G4

Output 1

3 
. E4 . 
C4 . C4 
G4 . .

Scoring

Each data set is scored individually. If the array you designed is invalid or the side length exceeds 1000, the score is 0. Otherwise, you get at least 1 point. Assuming you designed a valid array with side length $ans$, and the side length of the optimal array is $best$, your score for this test point is:

$$Score = \left\lfloor \frac{best^2}{ans^2} \times 9 \right\rfloor + 1$$

Note

We provide the program wind_c to check whether your output is a solution for the corresponding input. The usage is:

wind_c <test_point_number>

If the wind chime array can play the entire concert, it will output Correct, otherwise it will output the corresponding error message.


o sube archivos uno por uno:

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.