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 ...
随机推荐
- Java服务器获取客户端的ip
原文:http://www.open-open.com/code/view/1454133120089 /** * 获取登录用户IP地址 * * @param request * @return */ ...
- iOS Application Security
文章分A,B,C,D 4个部分. A) iOS Application Security 下面介绍iOS应用安全,如何分析和动态修改app. 1)iOS Application security Pa ...
- C/C++中static关键字作用总结 && 指针与引用的比较
static作用: 常规答案: 1. 全局变量的隐藏:2. 函数体内记忆功能:3.类所有实例共享,static函数不接受this指针,只能访问static成员变量. 拓展:1.全局变量的隐藏,因为在其 ...
- [转]gzip,bzip2,tar,zip命令使用方法详解
原文:http://blog.chinaunix.net/uid-20779720-id-2547669.html 1 gzipgzip(1) 是GNU的压缩程序.它只对单个文件进行压缩.基本用法如下 ...
- 创建pycharm项目时项目解释器的选择
创建pycharm项目时项目解释器的选择 Location下面有一个Project Interpreter: Python3.6,打开之后有两个选项, 如果选择了第一个,项目创建之后,在cmd中pip ...
- SpringCloud中Redis的使用
1.引入redis相关jar包 <dependency> <groupId>org.springframework.boot</groupId> <artif ...
- Ubuntu搭建Android开发环境
前言 由于迁移到新的笔记本,所以Android开发环境须要又一次配置了.android官网有配置教程,我正好回想一遍 配置Java环境 下载jdk.官网地址:http://www.oracle.com ...
- HDU 5327 Olympiad (多校)
Olympiad Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Su ...
- 服务器返回JSON,IE出现下载问题
我向来的观点,IE就是个奇葩. 服务器返回json,chrome处理得好地地,但IE却奇葩地向你请求是否要保存这个JSON文件? 之所以出现这种弱智现象,是因为IE无法识别一个所谓的响应头部:appl ...
- HBase在滴滴出行的应用场景和最佳实践
摘要: 主要介绍了HBase和Phoenix在滴滴内部的一些典型案例.文章已在CSDN极客头条和<程序员>杂志发表,应朋友邀请,分享到云栖社区,希望给大家带来启发和帮助. 背景 对接业务类 ...