Universal Cup Judging System

Universal Cup

Süre Sınırı: 1.0 s Bellek Sınırı: 1024 MB Toplam puan: 100
İstatistikler

שני חברים אספו $n^2$ צדפים בחוף הים וסידרו אותם ברשת של $n$ שורות ו-$n$ עמודות. לאחר מכן הם ציירו כמה קווים אופקיים וכמה קווים אנכיים בחול, שחילקו את החוף לאזורים, כאשר בכל אזור יש מספר חיובי של צדפים מהאוסף שלהם.

כעת החברים משחקים במשחק הידוע נים (Nim). הם מבצעים מהלכים לסירוגין; בכל מהלך, שחקן לוקח מספר חיובי של צדפים מאזור יחיד כלשהו. השחקן שלוקח את הצדפים האחרונים מנצח.

החברים יודעים שכדי לקבוע האם לשחקן הראשון יש אסטרטגיית ניצחון ואיזה מהלך הוא אופטימלי, יש לספור את מספר הצדפים בכל אזור ולחשב את ה-XOR הסיביתי (bitwise xor) של מספרים אלה. זה נשמע כמו הרבה עבודה. עזרו להם!

קלט

השורה הראשונה של הקלט מכילה מספר שלם אחד $n$ ($1 \le n \le 10^6$). אנו מניחים שהשורות ממוספרות מ-$1$ עד $n$, מלמעלה למטה. גם העמודות ממוספרות מ-$1$ עד $n$, משמאל לימין.

השורה השנייה מכילה מחרוזת של $n - 1$ ספרות 0 או 1; הספרה ה-$i$ ($1 \le i < n$) היא 1 אם יש קו אופקי בין שורה $i$ לשורה $i + 1$.

השורה השלישית מכילה מחרוזת של $n - 1$ ספרות 0 או 1; הספרה ה-$i$ ($1 \le i < n$) היא 1 אם יש קו אנכי בין עמודה $i$ לעמודה $i + 1$.

פלט

פלטו מספר שלם יחיד, ה-XOR הסיביתי של מספרי הצדפים בכל האזורים.

דוגמה

קלט

4
001
101

פלט

4

הערה

ישנם שישה אזורים, שבהם $3, 1, 6, 2, 3, 1$ צדפים בהתאמה. ה-XOR הסיביתי שווה ל-$3 \oplus 1 \oplus 6 \oplus 2 \oplus 3 \oplus 1 = 4$.

problem_17151_63470f9cad36964d6ae33239c4295829.png

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
#1050EditorialOpen题解jianglyView

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.