QOJ.ac

QOJ

Süre Sınırı: 2 s Bellek Sınırı: 256 MB Toplam puan: 100

#22345. 照明の切り替え

İstatistikler

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.