Odd Even

All submissions for this problem are available.

Problem description.

A professor in NITD wants his students to sit in the front rows of the
class, but the students prefer to sit in the back. He has thus devised
a method of seating in which a student will be seated based on
whether the roll number of the student is odd or even. He has asked
your help for this. You will be given an array containing the roll
numbers of the students. The professor will ask you to tell him the
number of students with odd roll numbers, and the number of
students with even roll numbers in a particular range of the array.
However, since the students are your friends, they can ask you to
change their roll numbers in the array. Two students can have the
same roll number, since you don’t have to tell the professor the
actual roll numbers.

Input

The first line of input will be an integer T, denoting the number of
test cases. The first line of each test case will consist of two
integers N, the number of students, and Q, the number of queries.

The next line will contain N space separated integers ri, the roll
numbers of the student i for all i from 0 to N-1. The next Q lines will
have Q queries.

Queries are of two types. The type of query will be
specified by a character, which will be P for a query by the
professor, and S for a query by the student.

The query by the
professor will be followed by two numbers x and y in the same line
after the P, separated by a space, which will be the ranges of the
array.

A student query will be followed by two space separated
integers u and w in the same line after the S, where u is the index of
the array, and w is the new roll number which the student wishes to
assume.

Output

For each query by the professor, print two space separated integers
in a line, first the number of students in the given range with odd roll
numbers, and then the number of students with even roll numbers.

Comments

Please login at the top to post a comment.

SUCCESSFUL SUBMISSIONS

Fetching successful submissions

HELP

Program should read from standard input and write to standard output. After you submit a solution you can see your results by clicking on the [My Submissions] tab on the problem page. Below are the possible results:

Accepted Your program ran successfully and gave a correct answer. If there is a score for the problem, this will be displayed in parenthesis next to the checkmark.

Time Limit Exceeded Your program was compiled successfully, but it didn't stop before time limit. Try optimizing your approach.

Wrong Answer Your program compiled and ran succesfully but the output did not match the expected output.

Runtime Error Your code compiled and ran but encountered an error. The most common reasons are using too much memory or dividing by zero. For the specific error codes see the help section.

Compilation Error Your code was unable to compile. When you see this icon, click on it for more information.

CodeChef was created as a platform to help programmers make it big in the world of algorithms, computer programming and programming contests. At CodeChef we work hard to revive the geek in you by hosting a programming contest at the start of the month and another smaller programming challenge in the middle of the month. We also aim to have training sessions and discussions related to algorithms, binary search, technicalities like array size and the likes. Apart from providing a platform for programming competitions, CodeChef also has various algorithm tutorials and forum discussions to help those who are new to the world of computer programming.

Try your hand at one of our many practice problems and submit your solution in a language of your choice. Our programming contest judge accepts solutions in over 35+ programming languages. Preparing for coding contests were never this much fun! Receive points, and move up through the CodeChef ranks. Use our practice section to better prepare yourself for the multiple programming challenges that take place through-out the month on CodeChef.

Here is where you can show off your computer programming skills. Take part in our 10 day long monthly coding contest and the shorter format Cook-off coding contest. Put yourself up for recognition and win great prizes. Our programming contests have prizes worth up to INR 20,000 (for Indian Community), $700 (for Global Community) and lots more CodeChef goodies up for grabs.