文档章节

×_7_12_2013 I: Light on or off

電泡泡
 電泡泡
发布于 2013/07/19 18:16
字数 480
阅读 8
收藏 0

Problem I: Light on or off

Time Limit: 1 Sec   Memory Limit: 128 MB
Submit: 11   Solved: 1
[ Submit][ Status][ Web Board]

Description

There is N lights on the wall of Dreamone’s house from left to right.Initially,some lights on and some lights 
off, and we use ‘1’ represented the light on, use ‘0’ represented the light off. As we know, there is a cat in 
dremone’s house, and she is very naught. She always change the status continuously from Ath light to Bth 
one. (1<=A, B<=N).If the light is on, then the light will be off, If the light is off, then the light will be on. 
Actually, she can do it K times like this. Then the cat puts forward another problem: How many lights on 
from Cth light to Dth (1<=C, D<=N) one? For example: 
When N=4 K=2, and the initial status is assumed as: 
1 0 1 1 
‘1’ represented on,’0’ represented off. 
From the initial status we can get: There is 3 lights on from 1st light to 4th, 2 lights on from 2nd to 4th and so 
on. Then we assume the first operation that we change the status from 2nd to 4th, and then the status will be: 
1 1 0 0 
Then there are 2 lights on from 1st light to 4th one, 1 light on from 2nd to 4th one and so on. Then the second 
operation is assumed as from the 1st to 2nd .Then the status will be 0 0 0 0. And there will be no lights on. 
Can you get the main idea? Can you help the naught cat? 

Input

The first line of input will be a positive integer indicating how many test cases will be included (T) and T 
will be less than 10. Each of the next T cases will contain two parts: 
The first part: two integer N, K (1<=N<=100000, 1<=K<=100000) 
The second part: N numbers (which is ‘0’ or ‘1’) represented the initial status from left to right. 
Then third part: K lines. Each line will be X C D (1<=C, D<=N) X is a letter which is either ‘Q’ or ‘C’. If 
X=’Q’, you will be output the numbers of lights on from Cth to Dth, and if X=’C’, you will be change the 
status of lights as the rules described above. 

Output

For each query,(when X=’Q’),you should output the numbers of lights on. What’s more, you must output a 
blank line after you have processed a test case

Sample Input

2

 4 3 

 1 0 1 1

 Q 2 4 

 C 2 3 

 Q 1 4 

 4 1

 1 0 1 1

 Q 2 4

Sample Output

 3


 2


© 著作权归作者所有

共有 人打赏支持
電泡泡
粉丝 23
博文 183
码字总数 69717
作品 0
衡阳
私信 提问
旷视&清华大学提出新型两步检测器Light-Head R-CNN

近日,来自旷视和清华的研究者提出一种新型两步检测器 Light-Head R-CNN,改变两步检测器头重脚轻(heavy-head)的设计,实现速度和准确率的双重突破。 近期基于 CNN 的目标检测器可以分为一...

zchang81
2017/11/24
0
0
synopsys的license程序在Centos6.8下的问题

外地研发中心新增几台工作站,按照惯例对cadence、synopsys、mentor的license进行和谐后,启动license就可以使用了,有人反应synopsys在某台Server上有问题,根据他们的描述,于是远程连过去...

cruelers
2017/04/17
0
0
Course4-week1-convolutional neural network

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/robinXushuai/article/details/80631021 1 - Computer vision Computer vision problem: images recognition ......

_席达_
2018/06/09
0
0
14种16阶群、13种60阶群的结构与表示(2014-5-25,5-28,5-29)(附GAP软件的使用)

共有14个不同的16阶群,其中交换群有5个,其余9个为非交换群。 gap> L:=Factors(16); [ 2, 2, 2, 2 ] gap> G:=AbelianGroup(L);;IdGroup(G);AbelianInvariants(G); [ 16, 14 ] [ 2, 2, 2, 2 ......

wangxuwei
2018/06/07
0
0
Very Deep Convolutional Networks for Large-Scale Image Recognition—中英文对照

文章作者:Tyan 博客:noahsnail.com | CSDN | 简书 翻译论文汇总:https://github.com/SnailTyan/deep-learning-papers-translation Very Deep Convolutional Networks for Large-Scale Im......

SnailTyan
2017/08/18
0
0

没有更多内容

加载失败,请刷新页面

加载更多

100行Python代码理解深度学习关键概念:从头构建恶性肿瘤检测网络

在构建乳腺癌预测神经网络过程中,我们主要分为3大部分: 1.用Python从零开始创建一个神经网络,并使用梯度下降算法训练模型。 2.在该神经网络中使用威斯康星乳腺癌数据集,根据9种不同的特征...

阿里云官方博客
32分钟前
0
0
数据库表结构查询SQL

今天给大家送上两个SQL查询的方法,也许在项目中你都用过,但是,没关系,仅仅记录下,以便后面不用去查找。针对与经常写SQL的同行来说,应该是非常简单的。 查询表结构数据 SELECTt.COLU...

摘星族
37分钟前
3
0
Maven常用命令

NAME       mvn - software project management and comprehension toolDESCRIPTION       usage: mvn [options] [<goal(s)>] [<phase(s)>]OPTIONS       -am,--a......

吴伟祥
39分钟前
1
0
在Centos7中安装mysql 5.6的一些注意点

在Centos7中安装mysql 5.6的一些注意点 2018年04月08日 11:45:11 去看日出 阅读数:408 在Centos7中安装mysql 5.6的一些注意点 2015/07/18 | 数据库 | shenyi| 4 条评论 | 19733 views 1、C...

rootliu
45分钟前
4
0
关于360插件化Replugin 2.3.1版本的AS配置解决方案

编译错误:No signature of method: com.android.build.gradle.internal.scope.VariantScopeImpl.getMergeAssetsTask() is applicable for argument types: () values: [] 解决方案:加入热心......

Gemini-Lin
今天
1
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部