QOJ.ac

QOJ

実行時間制限: 2 s メモリ制限: 128 MB 満点: 100

#6651. Meow Meow III

統計

This game consists of a deck of cards and $n$ stacks. The task is to eliminate all cards according to the game rules. Initially, there are $m$ cards in the deck, with patterns $a_1, a_2, \dots, a_m$ from top to bottom. There are $k$ types of patterns in total, numbered from $1$ to $k$. Each pattern appears an even number of times in the deck. Initially, all stacks are empty.

There are two types of operations in this game: Choose a stack and place the top card of the deck onto the top of that stack. If, after this operation, the two topmost cards of this stack have the same pattern, these two cards are automatically eliminated. Choose two different stacks. If the top cards of these two stacks have the same pattern, these two cards can be eliminated. If they are different, nothing happens.

After multiple observations, Little E found that $n = 2$ and $k = m/2$ always hold, meaning there are only two stacks and each pattern appears exactly twice. Despite this, Little E has been unable to clear the game. Please help Little E design a game strategy, i.e., provide an operation sequence that allows Little E to eliminate all the cards.

Input

The first line contains a positive integer $m$. The second line contains $m$ positive integers, representing $a_1, a_2, \dots, a_m$. It is guaranteed that $1 \le a_i \le m/2$ and each number appears exactly twice in the sequence.

Output

If there is no solution, output a single line No solution.. If there is a solution, output Cleared. on the first line. On the second line, output a positive integer $op$, representing the number of operations. You must ensure $m \le op \le 2m$. The next line should contain a string of length $op$, where each character is a non-negative integer not exceeding $2$, representing the operations performed in order. If the value is $1$ or $2$, it indicates performing the first operation and choosing stack $1$ or stack $2$. If the value is $0$, it indicates performing the second operation. Since there are only two stacks, you do not need to output additional information to specify which stacks you chose.

Scoring

The first line of your output must match the standard answer. If a solution exists, and after performing all operations in order, the deck is empty and all stacks are empty, your answer is considered correct.

Examples

Input 1

4
2 1 2 1

Output 1

Cleared.
5
12202

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.