QOJ.ac

QOJ

時間限制: 4.0 s 記憶體限制: 256 MB 總分: 100

#161. 伊热夫斯克训练营

统计

伊热夫斯克训练营即将开始!本赛季共有 $n$ 支队伍参加,队伍编号为从 $1$ 到 $n$ 的连续整数。在为期十一天的活动中,将为参赛队伍提供九场高水平的比赛。比赛编号为从 $1$ 到 $9$ 的连续整数。其中三场比赛将组成乌德穆尔特超级杯(UHSC)。问题是:应该选择哪三场比赛作为 UHSC 的比赛?

Oleg 正在协助举办伊热夫斯克训练营。对于每一场比赛,他预先知道 $n$ 支队伍中每一支队伍的名次。他希望利用这些信息选择三场比赛,以使 UHSC 的总“无聊度”最小化。

UHSC 的无聊度计算方式为:满足在三场 UHSC 比赛中队伍 $i$ 的名次均高于队伍 $j$ 的所有队伍对 $\{i, j\}$ 的数量。

你需要编写一个程序,帮助 Oleg 找到三场比赛 $a, b$ 和 $c$ 作为 UHSC,使得 UHSC 的总无聊度尽可能小。

输入格式

输入的第一行包含一个整数 $n$ —— 参赛队伍的数量($2 \le n \le 2^{16}$)。

接下来的九行,第 $i$ 行包含第 $i$ 场比赛的描述:$n$ 个唯一的正整数,范围在 $1$ 到 $n$ 之间,表示按名次从第一名到最后一名排列的队伍编号。

输出格式

输出仅一行,包含三个正整数 $a, b$ 和 $c$ —— 选择作为 UHSC 的比赛编号($1 \le a, b, c \le 9, a \neq b, a \neq c, b \neq c$)。

如果存在多个正确答案,输出其中任意一个即可。

样例

输入格式 1

7
1 2 3 4 5 6 7
1 2 4 5 3 7 6
1 3 2 5 7 6 4
1 2 3 4 5 7 6
1 2 3 4 5 6 7
2 1 3 4 5 6 7
7 1 2 3 4 5 6
5 4 1 3 6 7 2
1 2 4 5 3 6 7

输出格式 1

3 7 8

说明

对于样例测试用例,最小可能的无聊度值为 $5$。

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.