[CF] 25A - IQ test

My Very First CF problemset
My Solution
Idea: we don’t need information from previous numbers, we only need three information:
- the common eveness
a
- the current number
b
- the index of the current number
num
We also have a special case for when the first two numbers are different, in this situation we don’t know which number is the more common one. Thus we only need to look at the 3rd number.
1 |
|
Official Solution
count the number of odd numbers and even numbers, store the last odd and last even, and do it bruteforcely.
Thoughts
I guess the two solutions start from two different ways but they probably have a similar time and space achievement.
This problem is my first problem in codeforces (since university), and it reminded me of how Olympiad was like :D