fork download
  1. #include <bits/stdc++.h>
  2. #include <ext/pb_ds/assoc_container.hpp>
  3. #include <ext/pb_ds/tree_policy.hpp>
  4. using namespace __gnu_pbds;
  5. using namespace std;
  6. #define Foreach(i, c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
  7. #define For(i,a,b) for(int (i)=(a);(i) < (b); ++(i))
  8. #define rof(i,a,b) for(int (i)=(a);(i) > (b); --(i))
  9. #define rep(i, c) for(auto &(i) : (c))
  10. #define x first
  11. #define y second
  12. #define pb push_back
  13. #define PB pop_back()
  14. #define iOS ios_base::sync_with_stdio(false)
  15. #define sqr(a) (((a) * (a)))
  16. #define all(a) a.begin() , a.end()
  17. #define error(x) cerr << #x << " = " << (x) <<endl
  18. #define Error(a,b) cerr<<"( "<<#a<<" , "<<#b<<" ) = ( "<<(a)<<" , "<<(b)<<" )\n";
  19. #define errop(a) cerr<<#a<<" = ( "<<((a).x)<<" , "<<((a).y)<<" )\n";
  20. #define coud(a,b) cout<<fixed << setprecision((b)) << (a)
  21. #define L(x) ((x)<<1)
  22. #define R(x) (((x)<<1)+1)
  23. #define umap unordered_map
  24. #define double long double
  25. typedef long long ll;
  26. typedef pair<int,int>pii;
  27. typedef vector<int> vi;
  28. typedef complex<double> point;
  29. template <typename T> using os = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
  30. template <class T> inline void smax(T &x,T y){ x = max((x), (y));}
  31. template <class T> inline void smin(T &x,T y){ x = min((x), (y));}
  32. const int maxn = 500 + 10;
  33. bool a[maxn][maxn];
  34. int n, m, q;
  35. int mx[maxn];
  36. inline void calc(int i){
  37. int cur = 0;
  38. mx[i] = 0;
  39. For(j,0,m){
  40. if(a[i][j])
  41. cur ++;
  42. else
  43. cur = 0;
  44. smax(mx[i], cur);
  45. }
  46. }
  47. int main(){
  48. iOS;
  49. cin >> n >> m >> q;
  50. For(i,0,n)
  51. For(j,0,m)
  52. cin >> a[i][j];
  53. For(i,0,n)
  54. calc(i);
  55. while(q--){
  56. int i, j;
  57. cin >> i >> j;
  58. -- i, -- j;
  59. a[i][j] = !a[i][j];
  60. calc(i);
  61. int ans = 0;
  62. For(i,0,n)
  63. smax(ans, mx[i]);
  64. cout << ans << '\n';
  65. }
  66. }
Success #stdin #stdout 0s 3488KB
stdin
Standard input is empty
stdout
Standard output is empty