Universal Cup Judging System

Universal Cup

Time Limit: 2.0 s Memory Limit: 1024 MB Total points: 100 Hackable ✓
Statistics

Description

Let $n \ge 1$. Consider the following standard way to divide a large triangle into $n^2$ smaller triangles by drawing three sets of pairwise parallel lines:

problem_17171_1.png

Naturally, this defines an undirected graph with $(n + 1)(n + 2)/2$ vertices and $3n(n + 1)/2$ edges: the vertices are the nodes of the grid or, in other words, the intersection points of the lines (marked in bold in the picture), and the edges are the segments between neighboring nodes. Your task is to construct an Eulerian cycle on the edges of this graph that "starts" from the topmost vertex of the triangle. In other words, you need to start at the topmost vertex, move along the edges, traverse each edge exactly once, and, in the end, return to the topmost vertex. It can be proven that a solution always exists.

Input

An integer $n$ is given, ranging from $1$ to $20$.

Output

Output a string of exactly $3n(n + 1)/2$ digits from $0$ to $5$, representing some Eulerian cycle of the graph in the following format: $0$ means moving directly to the right from the current vertex, $1$ means moving in the right-up direction, $2$ means moving left-up, $3$ means moving left, $4$ means moving left-down, and $5$ means moving right-down. For clarity, the directions are shown in the picture below.

problem_17171_33d5f69dce15e1d87a6778f3f3d32524.png

The traversal must start from the top vertex. Any of the possible traversals will be accepted.

Example

2
404240022

Note

problem_17171_54bdc9bca5027ba99b1a899532d54824.png

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
#1222EditorialOpen题解jianglyView

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.