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 nm 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

Input
5 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 3
Output
3
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的更多相关文章

  1. cf#305 Mike and Foam(容斥)

    C. Mike and Foam time limit per test 2 seconds memory limit per test 256 megabytes input standard in ...

  2. 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 ...

  3. 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 ...

  4. 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 ...

  5. codeforces 361 A - Mike and Cellphone

    原题: Description While swimming at the beach, Mike has accidentally dropped his cellphone into the wa ...

  6. codeforces 361 B - Mike and Shortcuts

    原题: Description Recently, Mike was very busy with studying for exams and contests. Now he is going t ...

  7. CodeForces 689C Mike and Chocolate Thieves (二分)

    原题: Description Bad news came to Mike's village, some thieves stole a bunch of chocolates from the l ...

  8. Codeforces 548B Mike and Fun

    传送门 B. Mike and Fun time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  9. 美国插画家Mike Bear作品欣赏

    Mike Bear,美国插画师兼概念艺术家,在漫画和游戏界从业6年有余,分别为包括Popcap.Rockstar Games.Hasbro.EA等在内的业界巨头创建作品.他的画风较为抽象,大胆想象出一 ...

  10. hdu4135-Co-prime & Codeforces 547C Mike and Foam (容斥原理)

    hdu4135 求[L,R]范围内与N互质的数的个数. 分别求[1,L]和[1,R]和n互质的个数,求差. 利用容斥原理求解. 二进制枚举每一种质数的组合,奇加偶减. #include <bit ...

随机推荐

  1. HttpServletRequest接口是怎么实现的

    request只是规范中的一个名称而已.不是SUN提供的,这是由各个不同的Servlet提供商编写的,SUN只是规定这个类要实现HttpServletRequest接口,并且规定了各个方法的用途,但具 ...

  2. flask如何设置模板语言Jinjia?如何查看路由视图函数映射?

    首先flask的模板和静态文件命名必须是确定的templates和static pycharm的模板语言设置

  3. 转:NetBeans的远程Linux C开发实践

    转: http://blog.csdn.net/jacktan/article/details/9268535 一直以来总觉得NetBeans生活在Eclipse的阴影下,同样做为一款不错的基于Jav ...

  4. hdu 5338 ZZX and Permutations (贪心+线段树+二分)

    ZZX and Permutations Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/O ...

  5. c++面试题总结(4)

    一.找错题 试题1: void test1() { ]; "; strcpy( string, str1 ); } 试题2: void test2() { ],str1[]; int i; ...

  6. 这个捕鱼游戏制作的真心不错,原创音乐,AV动作,让人流连忘返啊呵呵

     女生看完这篇文章后果断地命令男朋友打开电脑和手机 2014-10-10 茶娱饭后 本人纯屌丝宅男一名.专注游戏十年有余,玩过无数大大小小的游戏,对捕鱼游戏情有独钟.我不想说在捕鱼游戏方面有多专业 ...

  7. openwrt gstreamer实例学习笔记(四. gstreamer Bins)

    1)概述 Bins是一种容器element.你可以往Bins中添加element.由于Bins本身也是一种element,所以你可以像普通element一样 操作Bins.因此,先前关element的 ...

  8. Hihocoder #1527 : 快速乘法 DP

    时间限制:20000ms 单点时限:1000ms 内存限制:256MB 描述 在写代码时,我们经常要用到类似 x × a 这样的语句( a 是常数).众所周知,计算机进行乘法运算是非常慢的,所以我们需 ...

  9. armel、armhf和arm64

    1 这些名词是什么的缩写 1.1 armel 是arm eabi little endian的缩写.eabi是软浮点二进制接口,这里的e是embeded,是对于嵌入式设备而言. 1.2 armhf 是 ...

  10. UISegmentedControl方法与属性的总结

    SegmentedControl又被称作分段控制器,是IOS开发中经常用到的一个UI控件. 初始化方法:传入的数组可以是字符串也可以是UIImage对象的图片数组 - (instancetype)in ...