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

【题意】

【题解】

分类讨论一波
设第一个数组的奇数个数为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. [Javascript Crocks] Safely Access Nested Object Properties with `propPath`

    In this lesson, we’ll look at the propPath utility function. We’ll ask for a property multiple level ...

  2. 使用Android Studio 1.3 版本号进行NDK开发

    众所周知Android Studio 1.3 版本号新增了NDK支持,能够非常方便的在上面开发C++或者C代码了,但是预览版功能不是非常完好,须要非常多步骤,另一些奇怪的BUG,整了半天最终能够使用A ...

  3. Linux下清屏的方法

    转自“https://blog.csdn.net/lis_12/article/details/54943626” clear,刷新屏幕,本质上是让终端显示页向后翻了一页,如果向上滚动屏幕还可以看到之 ...

  4. 10.TCPIP监听器

    给它做代理之后你这个端口是什么? 做一个代理. Local monitoring port:本地的监听端口.你要给谁做代理,那么给它做代理之后,你这个代理的端口是什么? 现在要给百度做一个代理. 能看 ...

  5. Web进行压力测试的小工具

    在Linux下对Web进行压力测试的小工具有很多,比较出名的有AB.虽然AB可以运行在windows下,但对于想简单界面操作的朋友有点不太习惯.其实vs.net也提供压力测试功能但显然显得太重了,在测 ...

  6. 如何让音频跟视频在ios跟android上自动播放

    如何让音频跟视频在ios跟android上自动播放 <audio autoplay ><source src="audio/alarm1.mp3" type=&q ...

  7. Lucene中Analyzer语句分析

    Lucene中Analyzer语句分析,利用lucene中自带的词法分析工具Analyzer,进行对句子的分析. 源代码如下: package com.test; import java.io.IOE ...

  8. guice 整合ninja framework(七)

    ninja是一个优秀的,轻量级的mvc框架,它与google guice整合比较好.下面看一下例子: 我们在web.xml 配置一下: <listener> <listener-cl ...

  9. SQL使用总结——集合操作函数

    Oracle中集合操作符专门用于合并多条select 语句的结果,包括:UNION, UNION ALL, INTERSECT, MINUS.当使用集合操作符时,必须确保不同查询的列个数和数据类型匹配 ...

  10. Jenkins 打包 java项目时 丢失 配置文件(resource)

    使用IDEA开发的spring boot 项目在本地打包运行可以,但是利用Jenkins打包运行提示读取不到配置文件中的变量,打开jar包发现里面没有配置文件.解决方法是在pom中增加如下配置 < ...