标签:
1 /*
2 暴力:每次更新该行的num[],然后暴力找出最优解就可以了:)
3 */
4 #include <cstdio>
5 #include <cstring>
6 #include <iostream>
7 #include <algorithm>
8 #include <string>
9 using namespace std;
10
11 const int MAXN = 5e2 + 10;
12 const int INF = 0x3f3f3f3f;
13 int a[MAXN][MAXN];
14 int num[MAXN];
15 int n, m;
16
17 int work(int x)
18 {
19 int res = 0;
20 for (int j=1;j<=m; ++j)
21 {
22 if (a[x][j] == 1)
23 {
24 int cnt = 0;
25 while (a[x][j] == 1) ++j, ++cnt;
26 res = max (res, cnt);
27 }
28 }
29
30 return res;
31 }
32
33 int main(void) //Codeforces Round #305 (Div. 2) B. Mike and Fun
34 {
35 int q;
36 while (scanf ("%d%d%d", &n, &m, &q) == 3)
37 {
38 for (int i=1; i<=n; ++i)
39 {
40 for (int j=1; j<=m; ++j) scanf ("%d", &a[i][j]);
41 }
42 int ans = 0;
43 for (int i=1; i<=n; ++i) num[i] = work (i);
44 while (q--)
45 {
46 int x, y;
47 scanf ("%d%d", &x, &y);
48 a[x][y] = 1 - a[x][y]; num[x] = work (x);
49 int ans = 0;
50 for (int i=1; i<=n; ++i) ans = max (ans, num[i]);
51 printf ("%d\n", ans);
52 }
53 }
54
55 return 0;
56 }
57
58 /*
59 5 4 5
60 0 1 1 0
61 1 0 0 1
62 0 1 1 0
63 1 0 0 1
64 0 0 0 0
65 1 1
66 1 4
67 1 1
68 4 2
69 4 3
70 */
暴力 Codeforces Round #305 (Div. 2) B. Mike and Fun
标签:
原文地址:http://www.cnblogs.com/Running-Time/p/4534179.html