QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 256 MB Total points: 100

#22345. החלפת מצבי אורות

Statistics

Farmer John שומר על חדות הפרות באמצעות צעצועי חשיבה. אחד הגדולים הוא אורות האסם. מעל כל אחד מ־$N$ $(2 \le N \le 500)$ התאים הממוספרים בנוחות $1,\ldots,N$ אור צבעוני.

בתחילת הערב כולם כבויים. הפרות משתמשות ב־$N$ מתגי לחצן שהופכים מצבים; לחיצה על $i$ משנה אור $i$ מכבוי לדולק או להפך.

הפרות קוראות ומבצעות $M$ $(1 \le M \le 2,000)$ פעולות המסומנות באחד משני שלמים $(0 \le operation \le 1)$.

הראשונה (פקודה 0) כוללת אחריה $S_{i}$ ו־$E_{i}$ $(1 \le S_{i} \le E_{i} \le N)$ למתג ההתחלה והסיום. לוחצים על כל לחצן מ־$S_{i}$ עד $E_{i}$ כולל בדיוק פעם אחת.

השנייה (פקודה 1) סופרת אורות דולקים בטווח כולל הקצוות שקובעים השלמים $S_{i}$ ו־$E_{i}$ $(1 \le S_{i} \le E_{i} \le N)$.

עזרו ל־FJ לבדוק תשובות: עבדו את הרשימה והפיקו ספירות נכונות.

קלט

  • שורה 1: שני שלמים $N$ ו־$M$ מופרדים ברווח.
  • שורות $2,\ldots,M+1$: כל פעולה שלושה שלמים מופרדים ברווחים: operation, $S_{i}$ ו־$E_{i}$.

פלט

  • שורות לשאילתות $1,\ldots,number$: לכל שאילתת פלט הדפיסו את הספירה כשלם יחיד בשורה נפרדת.

דוגמאות

קלט 1

4 5
0 1 2
0 2 4
1 2 3
0 2 4
1 1 4

פלט 1

1
2

הערה

ארבעה אורות וחמש פקודות. זה הרצף לעיבוד:

            אורות
            1 2 3 4
  התחלה:     O O O O   O = כבוי  * = דולק
  0 1 2 ->  * * O O  הפוך אורות 1 ו־2
  0 2 4 ->  * O * *
  1 2 3 ->  1        ספור אורות דולקים בטווח 2..3
  0 2 4 ->  * * O O  הפוך אורות 2, 3 ו־4
  1 1 4 ->  2        ספור אורות דולקים בטווח 1..4

מחבר הבעיה: LongFan, 2008

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.