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

【题意】

【题解】

分类讨论一波
设第一个数组的奇数个数为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. Chromium多线程模型设计和实现分析

    Chromium除了远近闻名的多进程架构之外,它的多线程模型也相当引人注目的.Chromium的多进程架构是为了解决网页的稳定性问题,而多线程模型则是为了解决网页的卡顿问题.为了达到这个目的,Chro ...

  2. Swift学习——变量var和let常量的用法(一)

    Swift中的变量var和let常量 首先介绍一下Swift中的 var 和 let (1)var 是 variable的缩写形式,是变量的意思 ,是可改变的.并非数据类型 比如: 注意每一个语句后面 ...

  3. 关于使用chrome插件改动全部的站点的响应responseHeaders头的注意

    1 眼下我掌握的调试技巧非常不方便,如今使用的是浏览器动作,每次都须要点击那个popup页面弹出,然后右键->查看元素,才干显示它的调试面板.一点击某些位置它又没有了; 2 改动响应报头的值时, ...

  4. map-reduce入门

    map-reduce入门 近期在改写mahout源代码,感觉自己map-reduce功力不够深厚,因此打算系统学习一下. map-reduce事实上是一种编程范式,从统计词频(wordCount)程序 ...

  5. 国内物联网平台初探(六) ——庆科云FogCloud

    平台定位 FogCloud 快速接入智能硬件 FogCloud为开发者提供便捷的智能硬件接入服务,真正实现敏捷开发,快速迭代. FogCloud提供功能强大的云端服务 包括 产品/APP管理 ,消息通 ...

  6. 【HDU 1847】 Good Luck in CET-4 Everybody!

    [题目链接] http://acm.hdu.edu.cn/showproblem.php?pid=1847 [算法] 我们知道,每一种状态,要么必胜,要么必败 记忆化搜索即可 [代码] #includ ...

  7. FZU2150 Fire Game

    题目: 两个熊孩子在n*m的平地上放火玩,#表示草,两个熊孩子分别选一个#格子点火,火可以向上向下向左向右在有草的格子蔓延,点火的地方时间为0,蔓延至下一格的时间依次加一.求烧完所有的草需要的最少时间 ...

  8. 在linux上加速git clone

    在linux上加速git clone 进入终端命令行模式,sudo vim /etc/hosts 编辑hosts文件,添加以下ip-域名,保存退出 151.101.44.249 github.glob ...

  9. 27. Remove Element[E]移除元素

    题目 Given an array nums and a value val, remove all instances of that value in-place and return the n ...

  10. Super超级ERP系统---(3)基础信息管理--商品管理

    商品管理主要包括商品的添加,修改,维护商品所在分类,单位,供应商,品牌,名称,价格,尺寸,规格等属性的维护.   1.商品添加 2.商品列表展示 商品列表界面左侧商品分类,右侧是商品信息