fork download
  1. #include <iostream>
  2. #include <vector>
  3. #include<stack>
  4. using namespace std;
  5. int find(vector<int> r)
  6. {
  7.  
  8. int res=0;
  9. stack<int> s;
  10. r.push_back(0);
  11. int i=0;
  12. while(i<r.size())
  13. {
  14. if(s.empty()||r[i]>r[s.top()]){s.push(i); i++;}
  15. else
  16. {
  17. int tmp = s.top();
  18. s.pop();
  19. res = max(res, r[tmp]*(s.empty()?i:i-s.top()-1));
  20. }
  21. }
  22. return res;
  23. }
  24. int main() {
  25. // your code goes here
  26. /*
  27. vector<int> r;
  28. r.push_back(2);
  29. r.push_back(1);
  30. r.push_back(5);
  31. r.push_back(6);
  32. r.push_back(2);
  33. r.push_back(3);
  34. int res = find(r);
  35. */
  36. vector<char> m;
  37. m.push_back('0');
  38. vector<vector<char> > matrix;
  39. matrix.push_back(m);
  40. int row = matrix.size();
  41. if(row==0) return 0;
  42. int col = matrix[0].size();
  43. if(col==0) return 0;
  44. vector<int> history, r;
  45. int res(0);
  46. for(int j=0; j<col; j++)
  47. {
  48. if(matrix[0][j]=='0'){history[j]=0;}
  49. else{history[j]=1;}
  50. }
  51. res = max(res, find(history));
  52. cout<<res<<endl;
  53. for(int i=1; i<row; i++)
  54. {
  55. for(int j=0; j<col; j++)
  56. {
  57. if(matrix[i][j]=='0'){r[j]=0;}
  58. else{r[j]=history[j]+1;}
  59. }
  60. res = max(res,find(r));
  61. swap(history, r);
  62. }
  63. cout<<res<<endl;
  64.  
  65. return 0;
  66. }
Runtime error #stdin #stdout 0s 3472KB
stdin
Standard input is empty
stdout
Standard output is empty