-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMaximumBuildingI.cpp
44 lines (37 loc) · 952 Bytes
/
MaximumBuildingI.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include <bits/stdc++.h>
#define ll long long
#define vi vector<int>
#define vii vector<vi>
using namespace std;
int main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int n, m;
cin >> n >> m;
char c;
vi k(m, 0);
stack<pair<int ,int>> s;
ll MAX = 0;
for(int i = 1; i < n + 1; i++){
for(int j = 0; j < m; j++){
cin >> c;
if(c == '*'){
k[j] = 0;
}
else{
k[j] += 1;
}
int l = j;
while(!s.empty() && s.top().first > k[j]){
MAX = max(MAX, (ll) (j - s.top().second) * s.top().first);
l = s.top().second;
s.pop();
}
s.push({k[j], l});
}
while(!s.empty()){
MAX = max(MAX, (ll) (m - s.top().second) * s.top().first);
s.pop();
}
}
cout << MAX << '\n';
}