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

【题意】

【题解】

分类讨论一波
设第一个数组的奇数个数为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. [WPF]c#调用默认浏览器打开网址

    //调用系统默认的浏览器 System.Diagnostics.Process.Start("http://www.zhaokeli.com");

  2. tiny4412开机动画、开机界面的定制 【原创】

    关键词:Android  linux 开机logo 开机动画  平台信息:内核:linux3.0.68 系统:android/android5.1平台:tiny4412 作者:庄泽彬(欢迎转载,请注明 ...

  3. php简单表格函数

    php简单表格函数 代码 <?php //ctrl+shift+j /** * @param unknown $rows * @param unknown $cols * @param stri ...

  4. CNN中的局部连接(Sparse Connectivity)和权值共享

    局部连接与权值共享 下图是一个很经典的图示,左边是全连接,右边是局部连接. 对于一个1000 × 1000的输入图像而言,如果下一个隐藏层的神经元数目为10^6个,采用全连接则有1000 × 1000 ...

  5. C#编译器优化

    C#编译器优化 https://www.cnblogs.com/podolski/p/8987595.html 使用C#编写程序,给最终用户的程序,是需要使用release配置的,而release配置 ...

  6. day63-webservice 07.07.如何修改cxf配置文件路径

    为什么第一次访问http://localhost:8080/cxf-web-server/service有点慢?证明第一次访问的时候CXFServlet被初始化了被加载了.一般是让CXFServlet ...

  7. java使用FileUtils文件操作神器

    前言: 在工作当中我们往往遇到很多文件的操作,我们也习惯写一些自己定义的工具类来简化文件操作,其实apache的commons的FileUtils类就是这样一个工具类,使用它能大大的简化我们对文件的操 ...

  8. Hibernate中实体对象的状态

    实体对象的状态 这里的实体对象是指Hibernate的O/R映射关系中的域对象(即O/R中的O).实体对象的生命周期是指实体对象由产生到被GC回收的一段过程,实体对象的生命周期包括3种状态:自由状态( ...

  9. [lua]异步串行流程*协程

    local function param_pack( params, callback ) table.insert(params, callback) return params end local ...

  10. java exception 异常错误记录

    //异常:Could not obtain transaction-synchronized Session for current thread 做定时器的时候用ApplicationContext ...