暴力 Codeforces Round #305 (Div. 2) B. Mike and Fun
/*
暴力:每次更新该行的num[],然后暴力找出最优解就可以了:)
*/
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <string>
using namespace std; const int MAXN = 5e2 + ;
const int INF = 0x3f3f3f3f;
int a[MAXN][MAXN];
int num[MAXN];
int n, m; int work(int x)
{
int res = ;
for (int j=;j<=m; ++j)
{
if (a[x][j] == )
{
int cnt = ;
while (a[x][j] == ) ++j, ++cnt;
res = max (res, cnt);
}
} return res;
} int main(void) //Codeforces Round #305 (Div. 2) B. Mike and Fun
{
int q;
while (scanf ("%d%d%d", &n, &m, &q) == )
{
for (int i=; i<=n; ++i)
{
for (int j=; j<=m; ++j) scanf ("%d", &a[i][j]);
}
int ans = ;
for (int i=; i<=n; ++i) num[i] = work (i);
while (q--)
{
int x, y;
scanf ("%d%d", &x, &y);
a[x][y] = - a[x][y]; num[x] = work (x);
int ans = ;
for (int i=; i<=n; ++i) ans = max (ans, num[i]);
printf ("%d\n", ans);
}
} return ;
} /*
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
*/
暴力 Codeforces Round #305 (Div. 2) B. Mike and Fun的更多相关文章
- 数论/暴力 Codeforces Round #305 (Div. 2) C. Mike and Frog
题目传送门 /* 数论/暴力:找出第一次到a1,a2的次数,再找到完整周期p1,p2,然后以2*m为范围 t1,t2为各自起点开始“赛跑”,谁落后谁加一个周期,等到t1 == t2结束 详细解释:ht ...
- set+线段树 Codeforces Round #305 (Div. 2) D. Mike and Feet
题目传送门 /* 题意:对于长度为x的子序列,每个序列存放为最小值,输出长度为x的子序列的最大值 set+线段树:线段树每个结点存放长度为rt的最大值,更新:先升序排序,逐个添加到set中 查找左右相 ...
- 字符串处理 Codeforces Round #305 (Div. 2) A. Mike and Fax
题目传送门 /* 字符串处理:回文串是串联的,一个一个判断 */ #include <cstdio> #include <cstring> #include <iostr ...
- Codeforces Round #305 (Div. 2) B. Mike and Fun 暴力
B. Mike and Fun Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/548/pro ...
- Codeforces Round #305 (Div. 2) A. Mike and Fax 暴力回文串
A. Mike and Fax Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/548/pro ...
- Codeforces Round #305 (Div. 1) A. Mike and Frog 暴力
A. Mike and Frog Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/547/pr ...
- Codeforces Round #305 (Div. 1) B. Mike and Feet 单调栈
B. Mike and Feet Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/547/pro ...
- Codeforces Round #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 ...
- Codeforces Round #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 ...
随机推荐
- jetty java文件无法删除 java文件占用 delete无效 运行时锁定静态资源的解决方法
前几天jetty下发现java无法删除文件,文件操作后一直被jvm占用,无奈换了tomcat问题消失. 今天又想起来,尝试网上的解决方法,经本人试验,直接修改配置文件有时不能生效,具体原因不清楚,建议 ...
- 常用SQL备忘录
联表删除: delete t1,t2 from table_name t1 left join t2 on t1.id=t2.id where t1.id=23 (ps:该语句在mysql 5.0之前 ...
- sbt is a build tool for Scala, Java, and more
http://www.scala-sbt.org/0.13/docs/index.html sbt is a build tool for Scala, Java, and more. It requ ...
- js-easyUI格式化时间
formatter : function(value, row) { if(value != null){ var date = new Date(value); var y = date.getFu ...
- VK Cup 2016 - Round 1 (Div. 2 Edition) C. Bear and Forgotten Tree 3
C. Bear and Forgotten Tree 3 time limit per test 2 seconds memory limit per test 256 megabytes input ...
- ulink函数的使用【学习笔记】
#include "apue.h" #include <fcntl.h> int main(void) { ) err_sys("open error&quo ...
- Getting Started with xUnit.net (desktop)
https://xunit.github.io/docs/getting-started-desktop.html In this article, we will demonstrate getti ...
- java时间类型转换 JsonValueProcessor
问题描述: java里面时间类型转换成json数据就成这样了:"createTime":{"date":30,"day":3,"h ...
- hdu(1007) 最近点对 分治法
最近点对一般想到枚举 ,一一枚举时间复杂度为n^2:枚举时候一些操作是多余的,有了分治算法的思想 ,把一些问题分个击破,再回到整体. 题目链接 以这道题为例,我们可以把他按照x轴的升序分成多个子区域 ...
- File System Programming --- (一)
About Files and Directories The file system is an important part of any operating system. After all, ...