QOJ.ac

QOJ

Limite de temps : 1 s Limite de mémoire : 64 MB Points totaux : 70

#13564. 替换

Statistiques

Vlatko 喜欢玩整数数组。他在一张纸上写了两个包含 $N$ 个元素的数组,每个元素要么是一个正整数,要么是一个代表变量的英文小写字母序列。变量可以用任意整数替换。两个数组中可能包含相同的变量,或者同一个变量在数组中出现多次。如果是这种情况,该变量在两个数组中的每一次出现都必须替换为相同的整数。

Vlatko 想知道是否可以通过用一些整数值替换所有变量,使得这两个数组变得相等。如果两个数组在相同位置上的数字相等,则认为这两个数组相等。

输入格式

第一行包含一个正整数 $N$ ($1 \le N \le 50\,000$),表示每个数组中的元素个数。

第二行包含第一个数组的 $N$ 个元素。

第三行包含第二个数组的 $N$ 个元素。

两个数组中的每个元素可以为以下之一:

  • 一个小于 $1\,000$ 的正整数,或
  • 一个代表变量的英文小写字母序列(长度不超过 10 个字符)。

输出格式

如果可以通过用整数值替换所有变量使两个数组相等,则输出 DA(克罗地亚语中的“是”,不带引号)。否则输出 NE(克罗地亚语中的“否”)。

子任务

在占总分 20% 的测试数据中,每个变量在两个数组中总共只会恰好出现一次。

在另外占总分 20% 的测试数据中,只会出现两个变量 xy。这些变量可能会在两个数组中多次出现。

样例

输入样例 1

3
3 1 2
3 1 x

输出样例 1

DA

输入样例 2

4
4 5 iks ipsilon
1 iks 3 iks

输出样例 2

NE

输入样例 3

5
x 3 x y 3
x y 2 z 3

输出样例 3

DA

说明

样例 3 解释:

通过代入 $x = 2$,$y = 3$,$z = 3$,两个数组都将变得相等(均为 2 3 2 3 3)。

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.