#P16966. [SCCPC 2026] 献给空白的无败冠冕

    ID: 19050 远端评测题 1000ms 1024MiB 尝试: 0 已通过: 0 显示难度NOI/NOI+/CTS 上传者: 标签>模拟动态规划 DP贪心四川Special Judge构造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 2×n2\times n matrix. The cell in row ii and column jj contains ai,ja_{i,j} coins.

At the start of the game, the player stands at cell (1,1)(1,1), and the goal is to move to cell (2,n)(2,n). 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 kk where you move down: first walk from (1,1)(1,1) to (1,k)(1,k), then move down to (2,k)(2,k), and finally walk to (2,n)(2,n).

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 2×n2\times n board. Some positions on the board are already fixed as positive integers, and the others are 1-1.

You need to replace all 1-1 with positive integers in [1,109][1,10^9], 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 1-1.

Input Format

The first line contains an integer nn (1n21051 \le n \le 2\cdot 10^5), the number of columns of the board.

The second line contains nn integers a1,1,a1,2,,a1,na_{1,1},a_{1,2},\ldots,a_{1,n}, representing the first row of the board.

The third line contains nn integers a2,1,a2,2,,a2,na_{2,1},a_{2,2},\ldots,a_{2,n}, representing the second row of the board.

For each position, we have ai,j=1a_{i,j}=-1, or 1ai,j1091\le a_{i,j}\le 10^9.

Output Format

If it is impossible to construct, output one line with a single integer 1-1.

Otherwise, output two lines, each with nn 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