CF353A Domino
题目描述
## 【问题描述】
Hades与Dionysus在狂饮后玩起了多米诺骨牌的小游戏。
现在桌上有n块多米诺骨牌,每块多米诺骨牌上半部分和下半部分上都有一个整数。每次翻转可让一块多米诺骨牌上下翻转,即上下部分数交换。Hades想让n块骨牌上半部分的数加起来是一个偶数,而Dionysus想让这n块骨牌下半部分的数加起来是一个偶数。喝醉的两人都不肯退让,非要达到自己的目的。路过的Hephaestus在扫了一眼桌上的骨牌后瞬间给出了一个让两人都满意且翻转次数最少的方案,便转身离去,留下迟滞的二人。可这还没完,喝得烂醉的二人很快忘记了Hephaestus所说的方案,Hades说他还记得最少的翻转次数,Dionysus不愿被比下去,只好来请教你了。
输入格式
第一行包含一个整数n,表示多米诺骨牌的数量。之后n行每行包含两个分隔的整数xi,yi,初始时xi在上方,yi在下方。
输出格式
一个整数,表示所需的最少翻转次数。若无法达到目的,输出-1。
说明/提示
In the first test case the sum of the numbers on the upper halves equals $ 10 $ and the sum of the numbers on the lower halves equals $ 6 $ . Both numbers are even, so Valera doesn't required to do anything.
In the second sample Valera has only one piece of domino. It is written $ 3 $ on the one of its halves, therefore one of the sums will always be odd.
In the third case Valera can rotate the first piece, and after that the sum on the upper halves will be equal to $ 10 $ , and the sum on the lower halves will be equal to $ 8 $ .