Codeforces Round #205 (Div. 2) : A

题意:

要求找到最少次数的交换次数使得两组数都是偶数;

很明显答案要么是0,要么是1,或者不管怎么交换都不行(-1);

 

所以:

 1 #include<cstdio>
 2 #define maxn 105
 3 using namespace std;
 4 
 5 int n,x,y;
 6 
 7 int main()
 8 {
 9     scanf("%d",&n);
10     int a=0,b=0,c=0;
11     while(n--)
12     {
13         scanf("%d%d",&x,&y);
14         a+=x,b+=y;
15         c+=(y%2)!=(x%2);
16     }
17     if(a%2==0&&b%2==0)puts("0");
18     else if(c%2==0&&c>0)puts("1");
19     else puts("-1");
20     return 0;
21 }
View Code

 

posted @ 2013-10-12 18:45  Yours1103  阅读(130)  评论(0编辑  收藏  举报