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
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 3Output
- 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的更多相关文章
- 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 ...
随机推荐
- [转] sql 删除表数据的drop、truncate和delete用法
删除表数据的关键字,大家记得最多的可能就是delete.然而,我们做数据库开发,读取数据库数据.对另外的drop.truncate用得就比较少了. 1 drop 出没场合:drop table ta ...
- android 获得电池状态
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools= ...
- Websocket -- JS的前端页面
一个html5 WebSocket + JS的简单Echo例子,例子代码演示效果猛戳链接:websocket例子(打开页面,稍等一会) 使用一个文本编辑器,把下面代码复制保存在一个 websocket ...
- git-flow 工作流 备忘清单
关于 git-flow 是一个 git 扩展集,按 Vincent Driessen 的分支模型提供高层次的库操作. 查看详情 ★ ★ ★ 这个备忘清单展示了 git-flow 的基本操作和效果. ★ ...
- open-falcon的插件机制
Plugin可以看做是对agent功能的扩充.对于业务系统的监控指标采集,最好不要做成plugin,而是把采集脚本放到业务程序发布包中,随着业务代码上线而上线,随着业务代码升级而升级,这样会比较容易管 ...
- 创建注记图层C# IFeatureWorkspaceAnno
http://blog.csdn.net/mydriverc/article/details/1675613 //IFeatureWorkspaceAnno Example //The ...
- SpringCloud中Rabbitmq的使用
1.pom配置,添加以来jar包 <dependency> <groupId>org.springframework.cloud</groupId> <art ...
- 《大话操作系统——做坚实的project实践派》(7)
写操作系统内核须要了解一个详细计算平台的CPU,包含这个CPU里的寄存器和异常中断处理机制
- CS 和 BS 的区别和优缺点(转)
转自:http://www.cnblogs.com/scnuyz/p/5808808.html bs是浏览器(browser)和服务器(server) cs是静态客户端程序(client)和服务器(s ...
- LeetCode题解(20)--Valid Parentheses
https://leetcode.com/problems/valid-parentheses/ 原题: Given a string containing just the characters ' ...