【链接】 我是链接,点我呀:)

【题意】

【题解】

分类讨论一波
设第一个数组的奇数个数为cnt1
第二个数组的奇数个数为cnt2
显然只有在(cnt1+cnt2)%2==0的情况下。
才可能第一个数组的和为偶数,第二个数组的和也为偶数
(因为奇数都要出现偶数次才可以。
所以只可能cnt1和cnt2都是偶数,那么输出0
否则,cnt1和cnt2都是奇数,看看有没有一个位置i只有a[i]或只有b[i]是奇数。有的话输出1.
其他情况都非法。

【代码】

#include <bits/stdc++.h>

using namespace std;

const int N = 1e2;

int n;
int x[N+10],y[N+10],cnt1,cnt2; int main()
{
#ifdef LOCAL_DEFINE
freopen("rush.txt","r",stdin);
#endif // LOCAL_DEFINE
ios::sync_with_stdio(0),cin.tie(0);
cin >> n;
for (int i = 1;i <= n;i++){
cin >> x[i] >> y[i];
if (x[i]&1) cnt1++;
if (y[i]&1) cnt2++;
}
if (cnt1%2==0 && cnt2%2==0){
cout<<0<<endl;
}else if ( (cnt1+cnt2)%2 != 0){
cout<<-1<<endl;
}else{
//cnt1+cnt2 == not odd
for (int i = 1;i <= n;i++){
if (x[i]&1 && y[i]%2==0)
return cout<<1<<endl,0;
if (x[i]%2==0 && y[i]&1)
return cout<<1<<endl,0;
}
cout<<-1<<endl;
} return 0;
}

【CodeForces 353 A】Domino的更多相关文章

  1. 【Codeforces Rockethon 2014】Solutions

    转载请注明出处:http://www.cnblogs.com/Delostik/p/3553114.html 目前已有[A B C D E] 例行吐槽:趴桌子上睡着了 [A. Genetic Engi ...

  2. 【57.97%】【codeforces Round #380A】Interview with Oleg

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  3. 【42.86%】【Codeforces Round #380D】Sea Battle

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  4. 【26.83%】【Codeforces Round #380C】Road to Cinema

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  5. 【17.76%】【codeforces round 382C】Tennis Championship

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  6. 【21.21%】【codeforces round 382D】Taxes

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  7. 【50.88%】【Codeforces round 382B】Urbanization

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  8. 【Codeforces Round 650】Codeforces #334 (Div. 1)

    模拟CF650,ABC三题,RK90 Codeforces 650 A 思路:首先看式子 \(\sqrt{(x_i-x_j)^2+(y_i-y_j)^2}=|x_i-x_j|+|y_i-y_j|\) ...

  9. 【Codeforces Round 725】Canada Cup 2016

    模拟Canada Cup 2016,ABC三题,Rank1376 第三题卡住了 Codeforces 725 C 求出两个相同字符的位置,记为x和y. 然后考虑把相同的那个字符放在第一行的什么地方, ...

随机推荐

  1. Win8下建立shortcut到開始界面

    在win8前建立開始菜单都非常easy,但到win8就有点不一样了.它的開始菜单是metro风格的.以下我们来看下详细的实现代码.有兴趣的朋友能够自己測试下,它的作用是设置shortcut到metro ...

  2. HDU 2586 How far away ?(LCA模板 近期公共祖先啊)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2586 Problem Description There are n houses in the vi ...

  3. java封装AES加密算法

    在实际coding中会常常遇到往数据库存入密码时加密.URL传參时的加密.由此简单封装了下java中的AES加密算法. 0.import类 import java.security.SecureRan ...

  4. int、bigint、smallint 和 tinyint范围

    int.bigint.smallint 和 tinyint范围使用整数数据的精确数字数据类型.bigint从 -2^63 (-9223372036854775808) 到 2^63-1 (922337 ...

  5. ORA-27301: OS failure message: Not enough space

    OS:HP-UNIX ORA-27300: OS system dependent operation:fork failed with status: 12  ORA-27301: OS failu ...

  6. Code Coverage and Unit Test in SonarQube

    概念 https://blog.ndepend.com/guide-code-coverage-tools/ Code Coverage Results Import (C#, VB.NET) Uni ...

  7. DNS通道检测 国内学术界研究情况——研究方法:基于特征或者流量,使用机器学习决策树分类算法居多

    http://xuewen.cnki.net/DownloadArticle.aspx?filename=BMKJ201104017&dbtype=CJFD<浅析基于DNS协议的隐蔽通道 ...

  8. LightOJ--1149--Factors and Multiples(二分图好题)

    Factors and Multiples Time Limit: 2000MS   Memory Limit: 32768KB   64bit IO Format: %lld & %llu ...

  9. The Triangle--nyoj 18

    The Triangle 时间限制:1000 ms  |  内存限制:65535 KB 难度:4 描述 7 3 8 8 1 0 2 7 4 4 4 5 2 6 5 (Figure 1) Figure ...

  10. Ubuntu搭建docker环境

    一丶自己搭建Ubuntu的虚拟机(网上很多教程) PS:下带图形化界面的Ubuntu镜像,这里只说一下要装那些工具和做那些配置   安装vim         sudo apt-get install ...