HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Contests > Epoka Science Olympiad 2016 > problem:


11-P5. 50910 - Flipping Coins

Epoka Science Olympiad 2016

Start: Apr.11.2016 at 02:07:57 PM
Finish: Apr.24.2016 at 05:00:00 AM
The contest is finished!
• Contest scoreboard

Guest
• Review clarifications (2)

Contest problems

• 11-2. 50968 - Number of Letters
• 11-3. 50969 - Chef and Feedback
• 11-4. 50970 - Marbles
• 11-5. 50971 - Belote Game
• 11-P1. 50906 - The Smallest Pair
• 11-P2. 50907 - Second Largest
• 11-P3. 50908 - Buy 1 Get 1
• 11-P4. 50909 - Gold Coins
• 11-P5. 50910 - Flipping Coins
• 6-1. 50937 - Calculate the Average
• 6-2. 50938 - Translate Score into Gr...
• 6-3. 50975 - Cinema Tickets
• 6-4. 50942 - Win or Lose
• 6-5. 50943 - Word Game
• 6-P1. 50881 - Exchange the Values
• 6-P3. 50883 - Win or Lose
• 6-P4. 50884 - Area and Perimeter Of...

Feedback

If you notice incorrect translations in Contester, please let author know.

Time limit 2000/4000/4000/4000 ms. Memory limit 65000/65000/65000/65000 Kb.

Flipping Coins

There are N coins kept on the table, numbered from 0 to N - 1. Initially, each coin is kept tails up. You have to perform two types of operations:

1) Flip all coins numbered between A and B inclusive. This is represented by the command "0 A B"

2) Answer how many coins numbered between A and B inclusive are heads up. This is represented by the command "1 A B".

Input:
The first line contains two integers, N and Q. Each of the next Q lines are either of the form "0 A B" or "1 A B" as mentioned above.

Output:
Output 1 line for each of the queries of the form "1 A B" containing the required answer for the corresponding query.

Sample Input1:

Sample Input2:

4 7

1 0 3

0 1 2

1 0 1

1 0 0

0 0 3

1 0 3

1 3 3

3 3

1 0 2

0 1 2

1 0 1

Sample  Output1:

Sample  Output2:

0
1
0
2
1

0

1

 

Для отправки решений необходимо выполнить вход.

www.contester.ru