QOJ.ac

QOJ

Time Limit: 1.0 s Memory Limit: 512 MB Total points: 100

#81. การตกแต่งพีระมิด

Statistics

มีก้อนหินทั้งหมด $L \times (L+1) \times (L+2)/6$ ก้อน Snuke นำก้อนหินเหล่านี้มาเรียงซ้อนกันเป็นทรงสี่หน้า (วัตถุสามมิติที่ประกอบด้วยหน้ารูปสามเหลี่ยมสี่หน้า) ตำแหน่งของก้อนหินแทนด้วยอันดับสามของจำนวนเต็ม $(i,j,k)$ ($1\le k\le j\le i\le L$) เมื่อ $i<L$ ก้อนหินที่ตำแหน่ง $(i,j,k)$ จะวางอยู่บนก้อนหินสามก้อนที่ตำแหน่ง $(i+1,j,k)$, $(i+1,j+1,k)$ และ $(i+1,j+1,k+1)$

Snuke ระบายสีก้อนหินเหล่านี้ด้วยวิธีต่อไปนี้ เริ่มจากระบายสีก้อนหินทุกก้อนในชั้นล่างสุด สำหรับแต่ละ $i$ ($1\le i\le N$) เขาระบายก้อนหินที่ตำแหน่ง $(L,A_i,B_i)$ เป็นสีดำ และระบายก้อนหินอื่น ๆ ในชั้นล่างสุดเป็นสีขาว จากนั้นเขาระบายสีก้อนหินที่เหลือจากล่างขึ้นบน โดยระบายก้อนหินที่ตำแหน่ง $(i,j,k)$ เป็นสีดำ หากจำนวนก้อนหินสีดำที่อยู่ข้างใต้ ($(i+1,j,k)$, $(i+1,j+1,k)$ และ $(i+1,j+1,k+1)$) เท่ากับศูนย์หรือสอง มิฉะนั้นจะระบายก้อนหินนั้นเป็นสีขาว

จงหาสีของก้อนหินที่อยู่บนสุด

ข้อมูลนำเข้า

$$\begin{gathered} L\ N \\ A_1\ B_1 \\ \vdots \\ A_N\ B_N\end{gathered}$$

  • $2\le L\le 10^9$
  • $0\le N\le \min(1000,L\times(L+1)/2)$
  • $1\le B_i\le A_i\le L$
  • อันดับคู่ $(A_i,B_i)$ แตกต่างกันทุกคู่

ข้อมูลส่งออก

พิมพ์ "Iori" หากก้อนหินบนสุดเป็นสีดำ มิฉะนั้นให้พิมพ์ "Yayoi"

ตัวอย่าง

ข้อมูลนำเข้า 1

2 2
2 1
1 1

ข้อมูลส่งออก 1

Iori

ข้อมูลนำเข้า 2

3 0

ข้อมูลส่งออก 2

Yayoi

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.