Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- ifstream fin ("dreptunghi1.in");
- ofstream fout ("dreptunghi1.out");
- int n, m, z, v[10001], lin, col;
- bitset <10001> a[10001];
- long long x, ans = -1;
- long long MaxArea()
- {
- stack <int> st;
- int i = 0;
- long long area = 0, maxi = -1;
- while (i < m)
- {
- if (st.empty() || v[st.top()] <= v[i])
- st.push(i++);
- else
- {
- int top = st.top();
- st.pop();
- area = v[top] * (st.empty() ? i : i - st.top() - 1);
- if (area > maxi)
- maxi = area;
- }
- }
- while (!st.empty())
- {
- int top = st.top();
- st.pop();
- area = v[top] * (st.empty() ? i : i - st.top() - 1);
- if (area > maxi)
- maxi = area;
- }
- return maxi;
- }
- int main()
- {
- fin >> n >> m >> z;
- for (int i = 1; i <= z; i++)
- {
- fin >> lin >> col;
- a[lin][col] = 1;
- }
- for (int i = 1; i <= n; i++)
- {
- for (int j = 1; j <= m; j++)
- v[j - 1] = (a[i][j] == 0? v[j - 1] + 1 : 0);
- int x = MaxArea();
- if (x > ans)
- ans = x;
- }
- fout << ans;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement