#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <cstring>
#include <set>
#include <cmath>
#include <map>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
const int MN = 65005;
const int MAXN = 1000005;
const int INF = 0x3f3f3f3f;
#define reg register
#define IOS ios::sync_with_stdio(false)
int M, N, L, K, D;
struct point {
int pos, n;
point() {
pos = 0;
n = 0;
}
} x[1001], y[1001];
bool cmp1(point a, point b) {
return a.n > b.n;
}
int main() {
scanf("%d %d %d %d %d", &M, &N, &K, &L, &D);
int x1, x2, y1, y2;
for (int i = 1; i <= D; i++) {
scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
if (x1 == x2) {
if (y1 < y2) {
y[y1].n++;
y[y1].pos = y1;
} else {
y[y2].n++;
y[y2].pos = y2;
}
} else if (y1 == y2) {
if (x1 < x2) {
x[x1].n++;
x[x1].pos = x1;
} else {
x[x2].n++;
x[x2].pos = x2;
}
}
}
sort(x + 1, x + M + 1, cmp1);
sort(y + 1, y + N + 1, cmp1);
int xx[1001], yy[1001];
int tmp1 = K, tmp2 = L;
for (int i = 1;; i++) {
if (x[i].n == 0 || tmp1 == 0) {
break;
}
xx[i] = x[i].pos;
tmp1--;
}
for (int i = 1;; i++) {
if (y[i].n == 0 || tmp2 == 0) {
break;
}
yy[i] = y[i].pos;
tmp2--;
}
K -= tmp1;
L -= tmp2;
sort(xx + 1, xx + K + 1);
sort(yy + 1, yy + L + 1);
for (int i = 1; i <= K; i++) {
printf("%d ", xx[i]);
}
printf("\n");
for (int i = 1; i <= L; i++) {
printf("%d ", yy[i]);
}
return 0;
}
P1056 [NOIP2008 普及组] 排座椅(贪心)
最新推荐文章于 2024-03-11 13:28:20 发布