CF353A.Domino

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Valera has got nn domino pieces in a row. Each piece consists of two halves — the upper one and the lower one. Each of the halves contains a number from 11 to 66 . Valera loves even integers very much, so he wants the sum of the numbers on the upper halves and the sum of the numbers on the lower halves to be even.

To do that, Valera can rotate the dominoes by 180180 degrees. After the rotation the upper and the lower halves swap places. This action takes one second. Help Valera find out the minimum time he must spend rotating dominoes to make his wish come true.

输入格式

The first line contains integer nn (1<=n<=100)(1<=n<=100) , denoting the number of dominoes Valera has. Next nn lines contain two space-separated integers xi,yix_{i},y_{i} (1<=xi,yi<=6)(1<=x_{i},y_{i}<=6) . Number xix_{i} is initially written on the upper half of the ii -th domino, yiy_{i} is initially written on the lower half.

输出格式

Print a single number — the minimum required number of seconds. If Valera can't do the task in any time, print 1-1 .

输入输出样例

  • 输入#1

    2
    4 2
    6 4
    

    输出#1

    0
    
  • 输入#2

    1
    2 3
    

    输出#2

    -1
    
  • 输入#3

    3
    1 4
    2 3
    4 4
    

    输出#3

    1
    

说明/提示

In the first test case the sum of the numbers on the upper halves equals 1010 and the sum of the numbers on the lower halves equals 66 . 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 33 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 1010 , and the sum on the lower halves will be equal to 88 .

首页