fork(4) download
  1. #include <iostream>
  2. using namespace std;
  3. const int MAX = 505;
  4. int a[MAX][MAX], res[MAX];
  5. int n, m, q;
  6. void calc(int i)
  7. {
  8. res[i] = 0;
  9. int cnt = 0;
  10. for (int j = 0; j <= m; j++)
  11. if (a[i][j])
  12. cnt++;
  13. else
  14. {
  15. res[i] = max(res[i], cnt);
  16. cnt = 0;
  17. }
  18. }
  19. int main()
  20. {
  21. cin >> n >> m >> q;
  22. for (int i = 0; i < n; i++)
  23. {
  24. for (int j = 0; j < m; j++)
  25. cin >> a[i][j];
  26. calc(i);
  27. }
  28. while (q--)
  29. {
  30. int x, y;
  31. cin >> x >> y;
  32. a[x - 1][y - 1] ^= 1;
  33. calc(x - 1);
  34. int ans = 0;
  35. for (int i = 0; i < n; i++)
  36. ans = max(ans, res[i]);
  37. cout << ans << endl;
  38. }
  39. return 0;
  40. }
  41.  
Success #stdin #stdout 0s 4136KB
stdin
Standard input is empty
stdout
Standard output is empty