Universal Cup Judging System

Universal Cup

时间限制: 2.0 s 内存限制: 512 MB 总分: 100 可 Hack ✓
统计

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.