BestCoder Round #67 (div.2) N bulbs(hdu 5600)
N bulbs
Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 559 Accepted Submission(s): 298
in order to save electricity, you should turn off all the lights, but you're lazy.
coincidentally,a passing bear children paper(bear children paper means the naughty boy), who want to pass here from the first light bulb to the last one and leave.
he starts from the first light and just can get to the adjacent one at one step.
But after all,the bear children paper is just a bear children paper. after leaving a light bulb to the next one, he must touch the switch, which will change the status of the light.
your task is answer whether it's possible or not to finishing turning off all the lights, and make bear children paper also reach the last light bulb and then leave at the same time.
For each test case, there are 2 lines.
The first line of each test case contains 1 integers n.
In the following line contains a 01 sequence, 0 means off and 1 means on.
* 1≤T≤10
* 1≤N≤1000000
The i-th line should only contain "YES" or "NO" to answer if it's possible to finish.
Child's path is: 123234545
all switchs are touched twice except the first one.
#include<stdio.h>
#include<string.h>
#include<string>
#include<math.h>
#include<algorithm>
#define LL long long
#define PI atan(1.0)*4
#define DD doublea
#define MAX 1001000
#define mod 10007
using namespace std;
int light[MAX];
int main()
{
int n,m,j,i,s,t;
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
s=0;
for(i=0;i<n;i++)
scanf("%d",&light[i]);
if(n==1)
{
if(light[0]==1)
printf("YES\n");
else
printf("NO\n");
continue;
}
for(i=0;i<n;i++)
{
if(!light[i]) s++;
}
if(s&1) printf("NO\n");
else printf("YES\n");
}
return 0;
}
BestCoder Round #67 (div.2) N bulbs(hdu 5600)的更多相关文章
- BestCoder Round #70 Jam's math problem(hdu 5615)
Problem Description Jam has a math problem. He just learned factorization. He is trying to factorize ...
- CF Round #600 (Div 2) 解题报告(A~E)
CF Round #600 (Div 2) 解题报告(A~E) A:Single Push 采用差分的思想,让\(b-a=c\),然后观察\(c\)序列是不是一个满足要求的序列 #include< ...
- BestCoder Round #74 (div.1) 1002Shortest Path(hdoj5636)
哈哈哈哈,我就知道这道题目再扔给我,我还是不会,就是这么菜,哈哈哈 一开始官方题解就没搞懂-然后就看了一下别人的代码,水水过就算了.今天拿到-GG: 题意: 一开始,有一张原图,有一条长度为n的链. ...
- Codeforces Round #378 (Div. 2) D题(data structure)解题报告
题目地址 先简单的总结一下这次CF,前两道题非常的水,可是第一题又是因为自己想的不够周到而被Hack了一次(或许也应该感谢这个hack我的人,使我没有最后在赛后测试中WA).做到C题时看到题目情况非常 ...
- Codeforces Round #367 (Div. 2) A. Beru-taxi (水题)
Beru-taxi 题目链接: http://codeforces.com/contest/706/problem/A Description Vasiliy lives at point (a, b ...
- Codeforces Round #617 (Div. 3) String Coloring(E1.E2)
(easy version): 题目链接:http://codeforces.com/contest/1296/problem/E1 题目一句话就是说,两种颜色不同的字符可以相互换位, 问,对这字符串 ...
- BestCoder Round #67 (div.2) N*M bulbs
问题描述 N*M个灯泡排成一片,也就是排成一个N*M的矩形,有些开着,有些关着,为了节约用电,你要关上所有灯,但是你又很懒. 刚好有个熊孩纸路过,他刚好要从左上角的灯泡走去右下角的灯泡,然后离开. 但 ...
- hdu 5600 BestCoder Round #67 (div.2)
N bulbs Accepts: 275 Submissions: 1237 Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 655 ...
- hdu5601 BestCoder Round #67 (div.2)
N*M bulbs Accepts: 94 Submissions: 717 Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 655 ...
随机推荐
- shell/bash 让vi/vim显示空格,及tab字符
shell/bash 让vi/vim显示空格,及tab字符 Vim 可以用高亮显示空格和TAB.文件中有 TAB 键的时候,你是看不见的.要把它显示出来::set listTAB 键显示为 ^I, ...
- CodeForces Round #278 (Div.2) (待续)
A 这么简单的题直接贴代码好了. #include <cstdio> #include <cmath> using namespace std; bool islucky(in ...
- JS创建Ajax的XMLHttpRequest对象的通用方法
function createXMLHttpRequest() { var request = false; if(window.XMLHttpRequest) { request = new XML ...
- 试图从数据库 ‘UFData_001_2003' 中提取的逻辑页 (1:10720) 属于对象 '0',而非对象 'syscolumns'
数据库可以使用,可以备份,但对备份进行恢复时报错,使用sp_attach_db对两个物理文件进行连接时,报同样错误: 服务器: 消息 605,级别 21,状态 1,行 1 试图从数据库 ‘UFData ...
- Java知识点:琐碎知识点(3)
零碎 switch(x),x只可以是enum或byte.short.char.int. 枚举在switch-case语句作为标签时必须是枚举常量的非限定名称,否则Compile Error. Enum ...
- 转载RabbitMQ入门(6)--远程调用
远程过程调用(RPC) (使用Java客户端) 在指南的第二部分,我们学习了如何使用工作队列将耗时的任务分布到多个工作者中. 但是假如我们需要调用远端计算机的函数,等待结果呢?好吧,这又是另一个故事了 ...
- delphi 注册 dcc70.dll
@echo 开始注册copy dcc70.dll %windir%\system32\regsvr32 %windir%\system32\dcc70.dll /s@echo dcc70.dll注册成 ...
- MySQL基础之第8章 视图
8.1.视图简介 视图由数据库中的一个表,视图或多个表,视图导出的虚拟表.其作用是方便用户对数据的操作. 8.2.创建视图必须要有CREATE VIEW 和 SELECT 权限SELECT selec ...
- Android-监听sdcard状态
public class MyService extends Service { private static final String TAG = "MyService"; Fi ...
- [Everyday Mathematics]20150208
对 $f\in C^2(\bbR)$ 适合 $$\bex \vlm{|x|}f(x)=0, \eex$$ 试证: $$\bex \int_{\bbR} |f'|^p\rd x \leq (p-1)^\ ...