Universal Cup Judging System

Universal Cup

Límite de tiempo: 2.0 s Límite de memoria: 512 MB Puntuación total: 100 Hackeable ✓
Estadísticas

Anton 發現了一條滿是咖啡店的街道。這條街道可以被看作一個圓環。在內側有 $n$ 家 Varka 咖啡店,而在外側有 $n$ 家 Surf 咖啡店。已知存在陣列 $a$ 和 $b$ 表示這些店所出品咖啡的品質:$a_i$ 表示第 $i$ 家 Varka 咖啡店的品質,$b_i$ 表示第 $i$ 家 Surf 咖啡店的品質。坐在某家咖啡店裡的顧客不喜歡看到街對面的人過得比自己更好,因此如果滿足以下條件之一,一家咖啡店裡的顧客就會感到傷心:

  • 顧客坐在第 $i$ 家 Varka 咖啡店裡,且 $b_{i-1}, b_i, b_{i+1}$ 中至少有兩個大於 $a_i$。這裡 $b_0$ 表示 $b_n$,$b_{n+1}$ 表示 $b_1$。
  • 顧客坐在第 $i$ 家 Surf 咖啡店裡,且 $a_{i-1}, a_i, a_{i+1}$ 中至少有兩個大於 $b_i$。這裡 $a_0$ 表示 $a_n$,$a_{n+1}$ 表示 $a_1$。

如果一家咖啡店的顧客感到傷心,我們就稱這家咖啡店是傷心的。現在 Anton 想知道,當 $a$ 和 $b$ 中的所有值合起來構成 $1, \dots, 2 \cdot n$ 的一個排列時,傷心的咖啡店數量最多能有多少。請幫助 Anton 構造一組能達到最大值的 $a, b$。

輸入格式

唯一的一行包含一個整數 $n$($3 \le n \le 10^5$)——Varka 和 Surf 咖啡店的數量。

輸出格式

第一行輸出 $n$ 個整數 $a_i$,表示各家 Varka 咖啡店的品質。

第二行輸出 $n$ 個整數 $b_i$,表示各家 Surf 咖啡店的品質。

$a$ 與 $b$ 的聯集必須構成 $1, \dots, 2 \cdot n$ 的一個排列。

範例

輸入格式 1

3

輸出格式 1

1 3 4
2 5 6

輸入格式 2

4

輸出格式 2

1 3 7 8
4 2 5 6

說明

對於第一個範例,只要另一個陣列中至少有 $2$ 個值大於某家咖啡店的值,該咖啡店就是傷心的(因為街道每側只有 $3$ 家咖啡店),因此值為 $1, 3, 4$ 的 Varka 咖啡店是傷心的,值為 $2$ 的 Surf 咖啡店也是傷心的。可以證明不可能讓 $5$ 家咖啡店同時傷心。

在第二個測試中,我們以兩家咖啡店為例進行分析:

  • 索引為 $2$ 的 Varka 咖啡店是傷心的,因為它的值為 $3$,且 $\{4, 2, 5\}$ 中至少有 $2$ 個值大於它的值。
  • 索引為 $1$ 的 Surf 咖啡店不是傷心的,因為它的值為 $4$,不滿足 $\{8, 1, 3\}$ 中至少有 $2$ 個值大於它的值。

如果考慮所有咖啡店,你會發現共有 $5$ 家傷心的咖啡店,且可以證明無法達到更大的數量。

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
#368EditorialOpen题解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.