fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int m, n;
  4. int main()
  5. {
  6. ios_base::sync_with_stdio(0);
  7. cin.tie(0);
  8. cout.tie(0);
  9. if(fopen("d13graph.inp","r"))
  10. {
  11. freopen("d13graph.inp","r",stdin);
  12. freopen("d13graph.out","w",stdout);
  13. }
  14. cin >> m >> n;
  15. vector<vector<int>> a(m + 1, vector<int>(n + 1));
  16. for(int i = 1; i <= m; i++)
  17. for(int j = 1; j <= n; j++)
  18. cin >> a[i][j];
  19. vector<int> h(n + 1, 0);
  20. int ans = 0;
  21. for(int i = 1; i <= m; i++)
  22. {
  23. for(int j = 1; j <= n; j++)
  24. if (i == 1 || a[i][j] != a[i-1][j])
  25. h[j] = 1;
  26. else
  27. h[j]++;
  28.  
  29. vector<int> h0, h1;
  30. for(int j = 1; j <= n; j++)
  31. if(a[i][j] == 0)
  32. h0.push_back(h[j]);
  33. else
  34. h1.push_back(h[j]);
  35.  
  36. sort(h0.rbegin(), h0.rend());
  37. sort(h1.rbegin(), h1.rend());
  38. for(size_t j = 0; j < h0.size(); j++)
  39. ans = max(ans, h0[j] * (int)(j+1));
  40. for(size_t j = 0; j < h1.size(); j++)
  41. ans = max(ans, h1[j] * (int)(j+1));
  42. }
  43. cout << ans;
  44. return 0 ;
  45. }
  46.  
Success #stdin #stdout 0s 5328KB
stdin
Standard input is empty
stdout
Standard output is empty