暴力 Codeforces Round #305 (Div. 2) B. Mike and Fun

时间:2023-03-10 08:44:43
暴力 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
*/