题目传送门

 /*
暴力:每次更新该行的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的更多相关文章

  1. 数论/暴力 Codeforces Round #305 (Div. 2) C. Mike and Frog

    题目传送门 /* 数论/暴力:找出第一次到a1,a2的次数,再找到完整周期p1,p2,然后以2*m为范围 t1,t2为各自起点开始“赛跑”,谁落后谁加一个周期,等到t1 == t2结束 详细解释:ht ...

  2. set+线段树 Codeforces Round #305 (Div. 2) D. Mike and Feet

    题目传送门 /* 题意:对于长度为x的子序列,每个序列存放为最小值,输出长度为x的子序列的最大值 set+线段树:线段树每个结点存放长度为rt的最大值,更新:先升序排序,逐个添加到set中 查找左右相 ...

  3. 字符串处理 Codeforces Round #305 (Div. 2) A. Mike and Fax

    题目传送门 /* 字符串处理:回文串是串联的,一个一个判断 */ #include <cstdio> #include <cstring> #include <iostr ...

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

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

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

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

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

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

随机推荐

  1. appium第一个安卓自动化工程

    转自:https://university.utest.com/how-to-set-up-your-first-android-automation-project-with-appium/ App ...

  2. VC++中全局变量的问题(转)

    全局变量一般这样定义:1.在一类的.cpp中定义 int myInt;然后再在要用到的地方的.cpp里extern int myInt:这样就可以用了. 2.在stdafx.cpp中加入:int my ...

  3. iOS优秀博文合集

    一.优化篇 Xcode7中你一定要知道的炸裂调试神技 iOS使用Instrument-Time Profiler工具分析和优化性能问题 dSYM 文件分析工具 二.功能篇 3分钟实现iOS语言本地化/ ...

  4. Spark SQL is a Spark module for structured data processing.

    http://spark.apache.org/docs/latest/sql-programming-guide.html

  5. ios 短音效的使用

    1.通用短音效ID的获取 #import <Foundation/Foundation.h> @interface MJAudioTool : NSObject /** * 播放音效 * ...

  6. 简单的JDBC编程步骤

    1.加载数据库驱动(com.mysql.jdbc.Driver) 2.创建并获取数据库链接(Connection) 3.创建jdbc statement对象(PreparedStatement) 4. ...

  7. WAS:服务器停电后,重启DMGR,控制台访问不了

    1.   今天有现场WAS服务器停电,重启DMGR后,控制台网页打不开: 后来得知,防火墙可能有问题.(虽然之前该机器上防火墙是关着的,但掉电后,防火墙会重启规则) 关掉防火墙后,问题解决. 2.   ...

  8. hdu2063 二分图(基础题)

    这个题目适合刚刚接触二分图的同学做哦: 给一个题目链接 点击打开链接. 题目大意,有K个男女匹配方式, 输入数据的第一行是三个整数K , M , N,分别表示可能的组合数目,女生的人数,男生的人数.0 ...

  9. BZOJ_4609_[Wf2016]Branch Assignment_决策单调性+带权二分

    BZOJ_4609_[Wf2016]Branch Assignment_决策单调性+带权二分 Description 要完成一个由s个子项目组成的项目,给b(b>=s)个部门分配,从而把b个部门 ...

  10. [BZOJ 3697] 采药人的路径

    [题目链接] https://www.lydsy.com/JudgeOnline/problem.php?id=3697 [算法] 首先 , 将黑色的边变成1 ,白色的边变成-1 那么 , 问题就转化 ...