QOJ.ac

QOJ

Límite de tiempo: 3 s Límite de memoria: 2048 MB Puntuación total: 100

#7911. 幂运算

Estadísticas

Image by callmetak on Freepik

Zoe 在闲暇时间开发了一款在线计算器。不幸的是,该计算器上周遭到了拒绝服务攻击。攻击者创建了许多整数变量,将它们相互幂运算,并尝试进行一系列比较。这些巨大的整数超出了服务器的处理能力,导致其崩溃。在 Zoe 修复该问题之前,她决定亲自执行攻击者请求的计算。

现有 $n$ 个整数变量 $x_1, x_2, \dots, x_n$。初始时,每个变量的值均设为 $2023$。你需要执行 $m$ 条指令,指令分为以下两种类型:

  • 操作,格式为 “! $i$ $j$”,其中 $i \neq j$。这意味着将 $x_i$ 更新为 $x_i^{x_j}$。
  • 查询,格式为 “? $i$ $j$”,其中 $i \neq j$。这意味着如果 $x_i > x_j$,你应该输出 ‘>’;如果 $x_i = x_j$,输出 ‘=’;如果 $x_i < x_j$,输出 ‘<’。

考虑第一个样例。在执行 5 次操作后,变量的值为: $x_1 = (2023^{2023})^{2023^{2023}}$, $x_2 = (2023^{2023^{2023}})^{2023}$, $x_3 = 2023$, $x_4 = 2023^{2023}$。

输入格式

输入包含: 第一行包含两个整数 $n$ 和 $m$ ($2 \le n \le 1000, 1 \le m \le 1000$),分别表示变量的数量和指令的数量。 $m$ 行,每行包含一个字符 $c$(‘!’ 或 ‘?’)和两个整数 $i$ 和 $j$ ($1 \le i, j \le n, i \neq j$),描述指令。

输出格式

对于输入中的每个查询,输出其结果。

样例

输入格式 1

4 8
! 1 4
! 2 1
! 4 3
! 1 4
! 2 3
? 3 4
? 2 4
? 2 1

输出格式 1

<
>
=

输入格式 2

4 9
! 2 4
! 1 2
? 3 1
? 1 2
! 2 3
? 1 2
! 1 3
! 3 2
? 1 3

输出格式 2

<
>
>
<

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.