QOJ.ac

QOJ

実行時間制限: 1 s メモリ制限: 512 MB 満点: 100

#8365. Repeated Problem Setting

統計

This is not an interactive problem.

Little Q found a very old game console with a very simple game:

There is a maze, which can be viewed as a $10 \times 10$ grid. Each cell is either an empty space or an obstacle. One of the empty spaces is the starting point, and another is the destination.

Little Q needs to control a character to move from the start to the destination. The console has four directional buttons, corresponding to East ('E'), South ('S'), West ('W'), and North ('N'). Additionally, the console has an "Enter" button. Little Q can press a sequence of directional buttons and then press the Enter button; the character will execute these movement commands in order. For each movement command, the character moves one cell in the corresponding direction. If the move leads to an obstacle or outside the map, the move fails; otherwise, it succeeds. A sequence of directional buttons followed by one Enter button is called an instruction.

In one round of the game, the character starts at the starting point. Little Q can give instructions to the character multiple times, and the character passes the level if it reaches the destination at any moment (including during the execution of a sequence of commands).

Little Q wants to beat the game, but unfortunately, the console's screen is broken, so he cannot see the state of the maze (the positions of obstacles and the current position of the character). Little Q can only determine the size of the maze from the screen boundaries (it is known to be $10 \times 10$).

Even more unfortunately, Little Q discovered that after entering the game and pressing the Enter button for the first time, he cannot use the directional buttons for the remainder of the game. This means Little Q can only provide one instruction!

Even worse, Little Q discovered that the time for one game is limited, allowing the character to execute no more than $10,000$ movement commands! Therefore, Little Q can press at most $10,000$ directional buttons.

Completing a level earns $10,000$ points. Beyond that, the game time also affects Little Q's score. Each movement command executed by the character (whether successful or not) costs $1$ unit of time. When the character reaches the destination for the first time, the game ends automatically. Let $t$ be the total time spent at the end (including the move that reached the destination). The score is calculated by subtracting $t$ from the completion score, i.e., $10,000 - t$. If the destination is not reached after all directional commands are executed, the game is automatically considered a failure after $10,000$ units of time. In this case, not only is the $10,000$ completion score not awarded, but $10,000$ points are deducted for the time consumed, resulting in a score of $-10,000$!

Little Q is at a loss. He asks for your help, hoping you can tell him how to input this single instruction to get the highest possible score. You need to write a program that outputs a string consisting of 'E', 'S', 'W', and 'N' with a length not exceeding $10,000$, representing the instruction you suggest Little Q should enter.

Fortunately, you know the generation method of the maze. The generation method is as follows: First, select $20$ cells on the $10 \times 10$ grid and mark them. Second, attempt to place obstacles $500$ times. For each attempt, randomly select a cell in the $10 \times 10$ grid. If the cell is empty and not marked, turn it into an obstacle. After this, if the $20$ marked cells can still reach each other by moving up, down, left, or right without passing through obstacles, the obstacle is kept; otherwise, the obstacle is removed, and the cell becomes empty again. After attempting to place all obstacles, the start and destination of the maze are chosen. The console randomly selects one pair of cells from all pairs with the maximum distance (distance is defined as the number of cells that need to be traversed) with equal probability, and sets one as the start and the other as the destination.

Your task is to make your outputted instruction achieve a higher average score. Each test case contains $1,000$ mazes generated using this method, but you do not know them. After your program outputs the instruction, it will be executed on these mazes, and the average score obtained will be the score returned for this test case.

Input

None.

Output

A single string consisting of 'E', 'S', 'W', 'N' with a length not exceeding $10,000$, representing the instruction you suggest Little Q should enter.

The commands 'E', 'S', 'W', 'N' correspond to moving from the current position $(x, y)$ to $(x, y+1)$, $(x+1, y)$, $(x, y-1)$, and $(x-1, y)$ respectively.

Examples

Input 1

(empty)

Output 1

WWWNNNWWWSSSWWWSSSWWWEEESSSEEESSSEEESSSWWWNNNWWWSSSWWWNNNEEEWWWNNNWWWSSSEEEWWWSSS

Note 1

The figure below shows a maze generated by the method described in the problem, where the circle is the start and the cross is the destination. The sample output can pass this maze.

Subtasks

Subtask 1 (100pts): No special restrictions.

Subtask 1 contains $20$ test cases. The scoring method is as follows:

If the output string contains characters other than 'E', 'S', 'W', 'N' or its length exceeds $10,000$, the score is $0$. Otherwise, the score is calculated as follows ($S$ is the average score obtained in the test case):

$S$ Value Corresponding Score
$S \leq 0$ $0$
$0 < S < 9100$ $\frac{8.1 \times 10^7}{(10^4 - S)^2}$
$S \geq 9100$ $100$

The subtask score is the minimum score among all test cases.

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.