QOJ.ac

QOJ

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

#13881. 用餐灾难

الإحصائيات

诺克萨斯和皮尔特沃夫的代表正在举行会议,讨论他们对底城的政策。他们聚集在一个房间里,那里有一张自西向东延伸的长桌,两侧各有 $N$ 个座位。代表们正准备坐下来讨论,但没有代表愿意坐在另一个人的相邻位置或正对面,以免让局面变得尴尬。注意,允许坐在另一个人的斜对面。已有 $K$ 个代表坐在了指定的座位上。请找到一种安排方案,在不让局面尴尬的前提下,在桌旁安置尽可能多的额外代表。

输入格式

第一行包含两个空格分隔的整数 $N$ ($1 \le N \le 2 \cdot 10^5$) 和 $K$ ($0 \le K \le 2N$)。

接下来的 $K$ 行以 $a_i\ b_i$ 的形式指定已就座代表之一的位置:

  • $a_i$ 为 1 或 2,分别表示该代表在桌子的北侧或南侧。
  • $b_i$ ($1 \le b_i \le N$) 表示该代表的座位号,其中 1 表示最西侧的座位,$N$ 表示最东侧的座位。

保证现有的 $K$ 个代表中,没有任意两个代表相邻或相对。

输出格式

第一行包含一个整数 $M$,表示可以在桌旁就座的最大代表人数(包括输入中给出的代表)。

第二行包含 $N$ 个字符,其中如果北侧的第 $i$ 个座位被占用,则第 $i$ 个字符为 X,否则为 .

第三行包含 $N$ 个字符,其中如果南侧的第 $i$ 个座位被占用,则第 $i$ 个字符为 X,否则为 .

如果存在多种可以达到最大人数的就座方案,你可以输出其中任意一种。

样例

输入样例 1

5 3
1 1
2 3
1 5

输出样例 1

3
X...X
..X..

输入样例 2

10 3
2 1
1 5
2 7

输出样例 2

8
.X..X..X.X
X.X...X.X.

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.