CodeForces 548B Mike and Fun (模拟)
题意:给定一个n*m的矩阵,都是01矩阵,然后每次一个询问,改变一个格的值,然后问你最大有数是多少。
析:就是按他说的模拟,要预处理,只要把每行的最大值记下来,当改变时,再更新这一行的最大值。
代码如下:
#include<bits/stdc++.h> using namespace std;
const int maxn = 500 + 5;
int a[maxn][maxn];
int num[maxn]; int main(){
int n, m, q, x, y;
while(cin >> n >> m >> q){
for(int i = 0; i < n; ++i)
for(int j = 0; j < m; ++j)
scanf("%d", &a[i][j]);
int mm = 0;
int tt ;
for(int i = 0; i < n; ++i){
int cnt = 0;
for(int j = 0; j < m; ++j){
if(a[i][j]) ++cnt;
else cnt = 0;
num[i] = max(num[i], cnt);
}
} while(q--){
scanf("%d %d", &x, &y);
--x, --y;
a[x][y] = a[x][y] ? 0 : 1;
int cnt = 0;
num[x] = 0;
for(int i = 0; i < m; ++i){
if(a[x][i]) ++cnt;
else cnt = 0;
num[x] = max(num[x], cnt);
}
mm = 0;
for(int i = 0; i < n; ++i) mm = max(mm, num[i]);
printf("%d\n", mm);
} }
return 0;
}
CodeForces 548B Mike and Fun (模拟)的更多相关文章
- Codeforces 548B Mike and Fun
传送门 B. Mike and Fun time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
- hdu4135-Co-prime & Codeforces 547C Mike and Foam (容斥原理)
hdu4135 求[L,R]范围内与N互质的数的个数. 分别求[1,L]和[1,R]和n互质的个数,求差. 利用容斥原理求解. 二进制枚举每一种质数的组合,奇加偶减. #include <bit ...
- codeforces 547E Mike and Friends
codeforces 547E Mike and Friends 题意 题解 代码 #include<bits/stdc++.h> using namespace std; #define ...
- CodeForces.158A Next Round (水模拟)
CodeForces.158A Next Round (水模拟) 题意分析 校赛水题的英文版,坑点就是要求为正数. 代码总览 #include <iostream> #include &l ...
- codeforces 689 Mike and Shortcuts(最短路)
codeforces 689 Mike and Shortcuts(最短路) 原题 任意两点的距离是序号差,那么相邻点之间建边即可,同时加上题目提供的边 跑一遍dijkstra可得1点到每个点的最短路 ...
- Codeforces 798C. Mike and gcd problem 模拟构造 数组gcd大于1
C. Mike and gcd problem time limit per test: 2 seconds memory limit per test: 256 megabytes input: s ...
- (CodeForces 548B 暴力) Mike and Fun
http://codeforces.com/problemset/problem/548/B Mike and some bears are playing a game just for fun. ...
- CodeForces 689A Mike and Cellphone (模拟+水题)
Mike and Cellphone 题目链接: http://acm.hust.edu.cn/vjudge/contest/121333#problem/E Description While sw ...
- Codeforces 747C:Servers(模拟)
http://codeforces.com/problemset/problem/747/C 题意:有n台机器,q个操作.每次操作从ti时间开始,需要ki台机器,花费di的时间.每次选择机器从小到大开 ...
随机推荐
- tomcat web.xml 配置
1<web-app> 2<error-page> 3<error-code>404</error-code> 4<location>/Not ...
- HDU 4869 Turn the pokers (2014 Multi-University Training Contest 1)
Turn the pokers Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)T ...
- 宏os_file_read_func
# define os_file_read(file, buf, offset, offset_high, n) \ os_file_read_func(file, buf, offset, offs ...
- css动画集合地址
CSS3 UI Lib库是由腾讯AlloyTeam前端开发团队建立,主要收集国内外友好体验和创意的界面组件Demo. 它除了使用CSS3技术外,还使用了HTML5,JS,JX,jQuery等技术,来达 ...
- Deferred的那些知识
在移动开发中的各种中,我们一定会遇到异步回调的问题,比如: 1:Css3执行动画完毕, 回调 2:Jquery Animate动画的执行完毕, 回调 3:Ajax的执行(并行.串行),回调 等等 ...
- hdu 4607 Park Visit(树上最长链)
求树上最长链:两遍搜索. 第一次从树上任意点开始,最远点必然是某一条最长链上的端点u. 第二次从u开始,最远点即该最长链的另一端点. 先在最长链上走,不足再去走支链. 把询问数m错打成n,狠狠wa了一 ...
- golang windows程序获取管理员权限(UAC ) via gocn
golang windows程序获取管理员权限(UAC ) 在windows上执行有关系统设置命令的时候需要管理员权限才能操作,比如修改网卡的禁用.启用状态.双击执行是不能正确执行命令的,只有右键以管 ...
- C# 委托总结
总结 委托的本质: 委托是一种特殊的数据类型,它表示某种特定类型的函数,并且可以表示多个函数,将这些函数串联起来.使用委托就好像函数调用一样. 委托实质上是一个类,编译器会根据关键字delegate自 ...
- android 触摸事件、点击事件的区别
针对屏幕上的一个View控件,Android如何区分应当触发onTouchEvent,还是onClick,亦或是onLongClick事件? 在Android中,一次用户操作可以被不同的View按次序 ...
- DevExpress控件使用小结 z
.TextEditor(barEditItem)取文本 string editValue = barEditItem1.EditValue.ToString(); //错误,返回null string ...