You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
64 lines
1.9 KiB
C++
64 lines
1.9 KiB
C++
#include <cstdio>
|
|
#include <cstring>
|
|
#include <algorithm>
|
|
#include <bitset>
|
|
using namespace std;
|
|
const int N = 1e3 + 5;
|
|
bitset<N> cover[N], vis;
|
|
bitset<4> visible[N];
|
|
struct Point
|
|
{
|
|
int x, y;
|
|
};
|
|
struct Rect
|
|
{
|
|
Point ld, ru;
|
|
} a[N];
|
|
bool PinR(const Point &p, const Rect &r)
|
|
{
|
|
return r.ld.x < p.x && p.x < r.ru.x && r.ld.y < p.y && p.y < r.ru.y;
|
|
}
|
|
int w, h, n;
|
|
int dfs(int x)
|
|
{
|
|
vis[x] = true;
|
|
int ans = 1;
|
|
for (int i = x + 1; i < n; i++)
|
|
if (cover[x][i] && !vis[i])
|
|
ans += dfs(i);
|
|
return ans;
|
|
}
|
|
int main()
|
|
{
|
|
memset(cover, 0, sizeof(cover));
|
|
memset(&visible, 0xffffffff, sizeof(visible));
|
|
scanf("%d%d%d", &w, &h, &n);
|
|
for (int i = 0; i < n; i++)
|
|
scanf("%d%d%d%d", &a[i].ld.x, &a[i].ld.y, &a[i].ru.x, &a[i].ru.y);
|
|
for (int i = 0; i < n; i++)
|
|
for (int j = 0; j < i; j++)
|
|
{
|
|
//if (a[j].ld.x < a[i].ru.x && a[j].ld.y < a[j].ru.y && a[j].ru.x > a[i].ld.x && a[j].ru.y > a[i].ld.y)
|
|
if (max(a[j].ld.x, a[i].ld.x) < min(a[j].ru.x, a[i].ru.x) && max(a[j].ld.y, a[i].ld.y) < min(a[j].ru.y, a[i].ru.y))
|
|
cover[j].set(i);
|
|
}
|
|
for (int i = 0; i < n; i++)
|
|
for (int j = i + 1; j < n; j++)
|
|
{
|
|
if (visible[i][0] && PinR(a[i].ld, a[j])) visible[i][0] = false;
|
|
if (visible[i][1] && PinR(a[i].ru, a[j])) visible[i][1] = false;
|
|
if (visible[i][2] && PinR(Point{a[i].ld.x, a[i].ru.y}, a[j])) visible[i][2] = false;
|
|
if (visible[i][3] && PinR(Point{a[i].ru.x, a[i].ld.y}, a[j])) visible[i][3] = false;
|
|
}
|
|
int ans1 = 0, ans2 = -1;
|
|
for (int i = 0; i < n; i++)
|
|
if (visible[i][0] || visible[i][1] || visible[i][2] || visible[i][3])
|
|
{
|
|
vis.reset();
|
|
int cur = dfs(i);
|
|
if (cur > ans1)
|
|
ans1 = cur, ans2 = i + 1;
|
|
}
|
|
printf("%d %d", ans1, ans2);
|
|
return 0;
|
|
} |