QOJ.ac

QOJ

حد الوقت: 2.0 s حد الذاكرة: 1024 MB مجموع النقاط: 100 قابلة للهجوم ✓

#17790. 别时茫茫江浸月

الإحصائيات

有 $2^n$ 只 Bugcat,每只都有一个唯一的属性,可以用 $0$ 到 $2^n - 1$ 之间的一个数表示。

这些 Bugcat 需要被配对成 $2^{n-1}$ 个小组(每个小组恰好包含两只 Bugcat)在餐厅用餐。Bugcat 们都很善良,因此没有一只 Bugcat 会出现在多于一个小组中。

餐厅里有 $2^{n-1} + 1$ 张双人桌,编号从 $1$ 到 $2^{n-1} + 1$。要求安排在每张桌子的两只 Bugcat 的属性值的异或(XOR)值等于该桌子的编号。

然而,独自来到餐厅的小 B 已经占用了最安静的桌子 $x$。(即编号为 $x$ 的桌子不能被 Bugcat 们使用。)

你能否提供一种配对方案,使得所有不同小组的 Bugcat 都能坐在不同的双人桌旁,且小 B 不需要移动?

输入格式

输入仅包含一行,有两个整数 $n, x$ ($1 \le n \le 20, 1 \le x \le 2^{n-1} + 1$)。

输出格式

输出的第一行应该是一个字符串 YESNO,表示是否存在这样的配对方案。

如果存在,输出 $2^{n-1}$ 行,每行包含两个整数 $x_i, y_i$,表示属性为 $x_i$ 和 $y_i$ 的 Bugcat 在同一个小组中。

小组可以按任何顺序输出。如果存在多个解,输出其中任意一个。

样例

输入样例 1

3 1

输出样例 1

YES
5 7
0 3
2 6
1 4

输入样例 2

2 1

输出样例 2

NO

输入样例 3

3 2

输出样例 3

NO

输入样例 4

1 2

输出样例 4

YES
0 1

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.