HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Sections > Unsorted > problem:


50910 - Flipping Coins

Guest
• Review clarifications (2)

Section problems

• 51106 - Polar Bear
• 50942 - Win or Lose
• 50971 - Belote Game
• 50886 - Even or Odd
• 50894 - ASCII Codes
• 50897 - Prime Number
• 50901 - Sum of Cubes-1
• 50907 - Second Largest
• 50910 - Flipping Coins
• 50950 - Biggest Number
• 50957 - Divisible by 3
• 50975 - Cinema Tickets
• 50959 - Draw the Pattern
• 50898 - Draw the Pattern
• 50961 - Order of 3 Runner
• 50963 - Append Two Arrays
• 50968 - Number of Letters

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