QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 1024 MB Total points: 100

#3881. 打怪兽

Statistics

Emma 刚刚发现了一款名为《Gwint: A wizard’s game》的新卡牌游戏。游戏中有两种卡牌:怪物卡和法术卡。怪物卡用于得分,而法术卡通常以某种方式与怪物互动。

每张怪物卡上都有一个整数值,即怪物的力量值(power)。怪物之间可以进行战斗,在战斗中,力量值既代表怪物的攻击力,也代表怪物的生命值。怪物轮流攻击对方,直到其中一方死亡。每当怪物 $A$ 攻击怪物 $B$ 时,会导致 $B$ 失去等同于 $A$ 的力量值的生命值。反之,如果 $B$ 攻击 $A$,$A$ 也会失去等同于 $B$ 的力量值的生命值(见下例)。这一过程持续进行,直到其中一个怪物的力量值降为 $0$ 或更低,此时该怪物被视为死亡。

图 F.1:怪物 A 和 B 之间的战斗,初始力量值分别为 4 和 7。A 先手。B 最终获胜,剩余力量值为 2。

Emma 最喜爱的卡牌之一是一张名为“Fight!”的法术卡,其效果如下:

选择两只怪物。它们将进行殊死搏斗。如果幸存怪物的剩余力量值恰好为 $1$,则将此卡牌收回你的手牌。

当然,Emma 希望能尽可能高效地进行游戏,通过选择两只怪物来让“Fight!”卡牌回到她的手中。然而,棋盘上往往有很多怪物,这使得判断是否能做到这一点变得非常耗时。你能帮她找到两只可以选取的怪物,从而让她收回这张卡牌吗?

输入格式

输入包含: 一行一个整数 $n$ ($2 \le n \le 10^5$),表示怪物的数量; 一行 $n$ 个整数 $m_1, \dots, m_n$ ($1 \le m_i \le 10^6$),表示每只怪物的力量值。

输出格式

如果没有 Emma 可以选择的怪物对,输出 impossible。否则,输出两个不同的整数 $i, j$ ($1 \le i, j \le n$),其中 $i$ 是发起战斗的怪物索引,$j$ 是另一只怪物的索引。如果存在多种方案,输出其中任意一种即可。

样例

样例输入 1

4
1 12 67 8

样例输出 1

impossible

样例输入 2

5
1 1 12 67 8

样例输出 2

2 1

样例输入 3

6
1 5 6 7 90 8

样例输出 3

2 6

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.