#P16966. [SCCPC 2026] 献给空白的无败冠冕
[SCCPC 2026] 献给空白的无败冠冕
Background
:::align{center}
:::
:::epigraph[No Game No Life] Once the pact is made, may this game be without defeat. :::
Problem Description
In a world where everything is decided by games, Stephanie, Sora, and Shiro are studying a new board game.
The board is a matrix. The cell in row and column contains coins.
At the start of the game, the player stands at cell , and the goal is to move to cell . In each step, the player can only move one cell to the right, or one cell down.
Since the board has only two rows, a legal path is equivalent to choosing a column where you move down: first walk from to , then move down to , and finally walk to .
Shiro moves first and collects all coins on her path. After Shiro finishes, Sora moves and collects all coins in cells that were not visited by Shiro. Shiro wants to minimize the number of coins Sora collects, while Sora wants to maximize the number of coins he collects.
Stephanie watched carefully for a while, and then confidently proposed a strategy: if Shiro just chooses the path that lets her collect the most coins, wouldn’t she win?
Shiro stayed silent for a second and pointed out that this strategy is not always correct. Stephanie, unconvinced, demanded that Shiro immediately give a board such that her strategy would uniquely choose a wrong path. However, Shiro was busy playing against Sora, so she handed this task to you.
Now you are given a board. Some positions on the board are already fixed as positive integers, and the others are .
You need to replace all with positive integers in , so that the constructed board satisfies the following conditions:
There exists a unique path that makes Shiro’s collected coins as large as possible; and Stephanie’s unique choice is wrong, meaning that there exists another path for Shiro such that the maximum number of coins Sora can obtain is smaller.
If it is impossible to construct such a board, output .
Input Format
The first line contains an integer (), the number of columns of the board.
The second line contains integers , representing the first row of the board.
The third line contains integers , representing the second row of the board.
For each position, we have , or .
Output Format
If it is impossible to construct, output one line with a single integer .
Otherwise, output two lines, each with integers, representing the constructed board.
3
5 -1 2
-1 2 7
5 1 2
2 2 7
1
-1
1
-1
Hint
Translated by ChatGPT 5