Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fstream>
- using namespace std;
- ifstream f("hambar.in");
- ofstream g("hambar.out");
- pair <short, short> a[1002];
- short n, m;
- int smax;
- short caut(short l1, short c1, short l2, short c2, short k) {
- while(k <= m)
- if(a[k].first >= l1 && a[k].first <= l2 && a[k].second <= c2 && a[k].second >= c1)
- return k;
- else k++;
- return 0;
- }
- void div(short l1, short c1, short l2, short c2, short p) {
- int sa = (l2-l1+1)*(c2-c1+1);
- if(smax < sa) {
- p = caut(l1, c1, l2, c2, p);
- if(p == 0) { if(smax < sa) smax = sa; }
- else {
- div(l1, c1, l2, a[p].second - 1, p + 1);
- div(l1, a[p].second + 1, l2, c2, p + 1);
- div(l1, c1, a[p].first - 1, c2, p + 1);
- div(a[p].first + 1, c1, l2, c2, p + 1);
- }
- }
- }
- int main() {
- f >> n >> m;
- for(int i = 1; i <=m; ++i) f >> a[i].first >> a[i].second;
- div(1, 1, n, n, 1);
- g << smax;
- g.close();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement