B - Mike and Fun
Time Limit:2000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u
Description
Mike and some bears are playing a game just for fun. Mike is the judge. All bears except Mike are standing in an n × m grid, there's exactly one bear in each cell. We denote the bear standing in column number j of row number i by (i, j). Mike's hands are on his ears (since he's the judge) and each bear standing in the grid has hands either on his mouth or his eyes.
They play for q rounds. In each round, Mike chooses a bear (i, j) and tells him to change his state i. e. if his hands are on his mouth, then he'll put his hands on his eyes or he'll put his hands on his mouth otherwise. After that, Mike wants to know the score of the bears.
Score of the bears is the maximum over all rows of number of consecutive bears with hands on their eyes in that row.
Since bears are lazy, Mike asked you for help. For each round, tell him the score of these bears after changing the state of a bear selected in that round.
Input
The first line of input contains three integers n, m and q (1 ≤ n, m ≤ 500 and 1 ≤ q ≤ 5000).
The next n lines contain the grid description. There are m integers separated by spaces in each line. Each of these numbers is either 0(for mouth) or 1 (for eyes).
The next q lines contain the information about the rounds. Each of them contains two integers i and j (1 ≤ i ≤ n and 1 ≤ j ≤ m), the row number and the column number of the bear changing his state.
Output
After each round, print the current score of the bears.
Sample Input
Input5 4 5
0 1 1 0
1 0 0 1
0 1 1 0
1 0 0 1
0 0 0 0
1 1
1 4
1 1
4 2
4 3Output3
4
3
3
4
题意:
有n*m只萌熊做运♂动,有蒙眼和捂嘴两种表情,给出q个坐标,每个坐标对应的熊变换一下表情,求单行最长连续蒙眼熊的个数。
爆爆爆!!!
附AC代码:
#include<iostream>
#include<cstring>
#include<cmath>
using namespace std; int a[][]; int main(){
int n,m,q,x,y,ans;
cin>>n>>m>>q;
for(int i=;i<=n;i++){
for(int j=;j<=m;j++){
cin>>a[i][j];
}
}
for(int i=;i<q;i++){
cin>>x>>y;
a[x][y]=!a[x][y];//表情转换
int MAXN=-;
for(int s=;s<=n;s++){
ans=;
for(int t=;t<=m;t++){
if(a[s][t]==)
ans=;
else
ans++;
MAXN=max(MAXN,ans);//记录最大值
}
}
cout<<MAXN<<endl;
}
return ;
}
B - Mike and Fun的更多相关文章
- cf#305 Mike and Foam(容斥)
C. Mike and Foam time limit per test 2 seconds memory limit per test 256 megabytes input standard in ...
- CF #305(Div.2) D. Mike and Feet(数学推导)
D. Mike and Feet time limit per test 1 second memory limit per test 256 megabytes input standard inp ...
- CF #305 (Div. 2) C. Mike and Frog(扩展欧几里得&&当然暴力is also no problem)
C. Mike and Frog time limit per test 1 second memory limit per test 256 megabytes input standard inp ...
- codeforces 361 E - Mike and Geometry Problem
原题: Description Mike wants to prepare for IMO but he doesn't know geometry, so his teacher gave him ...
- codeforces 361 A - Mike and Cellphone
原题: Description While swimming at the beach, Mike has accidentally dropped his cellphone into the wa ...
- codeforces 361 B - Mike and Shortcuts
原题: Description Recently, Mike was very busy with studying for exams and contests. Now he is going t ...
- CodeForces 689C Mike and Chocolate Thieves (二分)
原题: Description Bad news came to Mike's village, some thieves stole a bunch of chocolates from the l ...
- Codeforces 548B Mike and Fun
传送门 B. Mike and Fun time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
- 美国插画家Mike Bear作品欣赏
Mike Bear,美国插画师兼概念艺术家,在漫画和游戏界从业6年有余,分别为包括Popcap.Rockstar Games.Hasbro.EA等在内的业界巨头创建作品.他的画风较为抽象,大胆想象出一 ...
- hdu4135-Co-prime & Codeforces 547C Mike and Foam (容斥原理)
hdu4135 求[L,R]范围内与N互质的数的个数. 分别求[1,L]和[1,R]和n互质的个数,求差. 利用容斥原理求解. 二进制枚举每一种质数的组合,奇加偶减. #include <bit ...
随机推荐
- [Oracle] 获取运行计划的各方法总结
总的结论: 一.获取运行计划的6种方法(具体步骤已经在每一个样例的开头凝视部分说明了): 1. explain plan for获取: 2. set autotrace on . 3. stati ...
- C#如何实现挂机锁
首先在主窗体中设置一个子窗体的实例,然后当点击挂机之后,隐藏当前窗体,同时显示子窗体. 把子窗体的背景窗体设置如下属性(主要是背景随便改成一个图片,然后FormBorderStyle改成None, ...
- Android4.42-Setting源代码分析之蓝牙模块Bluetooth(下)
接着上一篇Android4.42-Settings源代码分析之蓝牙模块Bluetooth(上) 继续蓝牙模块源代码的研究 THREE.蓝牙模块功能实现 switch的分析以及本机蓝牙重命名和可见性的分 ...
- 【转载】分布式系统理论基础 - 一致性、2PC和3PC
引言 狭义的分布式系统指由网络连接的计算机系统,每个节点独立地承担计算或存储任务,节点间通过网络协同工作.广义的分布式系统是一个相对的概念,正如Leslie Lamport所说[1]: What is ...
- UIAutomation使用測试入门
自己主动化測试的优点: 1.自己主动化能够自己主动測试,不须要人的干预.同一时候还能够不断地反复某一个动作. 2.自己主动化測试在添加了新的功能之后.还能够回归到原理的功能,使其原来的功能不会受到影响 ...
- 11892 - ENimEN(博弈)
UVA 11892 - ENimEN 题目链接 题意:给定n堆石头.两人轮流取,每次仅仅能取1堆的1到多个.假设上一个人取了一堆没取完.那么下一个人必须继续取这堆.取到最后一个石头的赢,问谁赢 思路: ...
- Linux fcntl函数详解
功能描述:根据文件描述词来操作文件的特性. 文件控制函数 fcntl -- file control 头文件: #include <unistd.h> #include ...
- java工具类(四)之实现日期随意跳转
Java实现日期随意跳转 项目开发过程中.须要进行订单提醒日期的设置.主要包含设置每月指定的日期或者指定的天数,代码例如以下: public static String DateOperation(S ...
- 01背包+卡精度 Hdu 2955
<span style="color:#3333ff;">/* ---------------------------------------------------- ...
- 【php】读取"文件列表"按时间倒序显示,并递归显示各层文件夹、!
思路: 1.读取该php所在文件夹的文件列表,用"改动时间.文件名称"做键值对,塞入数组.对"改动时间"倒序.(貌似不能直接按时间倒序读取文件列表,此处为间接方 ...