QOJ.ac

QOJ

時間限制: 1.0 s 記憶體限制: 512 MB 總分: 100

#81. קישוט פירמידה

统计

ישנן $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\quad N\\ A_1\quad B_1\\ \vdots\\ A_N\quad 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.