You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
1.4 KiB
40 lines
1.4 KiB
#include <bits/stdc++.h>
|
|
|
|
using namespace std;
|
|
struct point {
|
|
int x, n;//x表示要分离线所在的行或列 n指这条线能分开说话人的数量
|
|
} y[1001], x[1001];//x是行 y为列
|
|
bool cmp1(point a, point b) {
|
|
return a.n > b.n;//排序时将分离数量大的放前面保证最优
|
|
}
|
|
|
|
bool cmp2(point a, point b) {
|
|
return a.x < b.x;//出答案时要求列数(行数)小的在前
|
|
}
|
|
|
|
int main() {
|
|
int m, n, k, l, d;//同题
|
|
scanf("%d %d %d %d %d", &m, &n, &k, &l, &d);
|
|
int x1, y1, p1, q1;//同题
|
|
for (int i = 1; i <= d; i++) {//
|
|
scanf("%d %d %d %d", &x1, &y1, &p1, &q1);
|
|
if (x1 == p1) {//辨别是纵向还是横向,若横向相同则分离线为纵向
|
|
y[min(y1, q1)].x = min(y1, q1);//标记分离线所在列数
|
|
y[min(y1, q1)].n++;//y[min(y1,q1)].x保证相同列数分离线叠加
|
|
}
|
|
if (y1 == q1) {//同理
|
|
x[min(x1, p1)].x = min(x1, p1);
|
|
x[min(x1, p1)].n++;
|
|
}
|
|
}
|
|
sort(x + 1, x + 1 + 1000, cmp1);//分离数大的在前
|
|
sort(y + 1, y + 1 + 1000, cmp1);
|
|
sort(x + 1, x + 1 + k, cmp2);//将答案进行整理(行数或列数小在前)
|
|
sort(y + 1, y + 1 + l, cmp2);
|
|
for (int i = 1; i <= k; i++)
|
|
printf("%d ", x[i].x);
|
|
printf("\n");//输出中间换行
|
|
for (int i = 1; i <= l; i++)
|
|
printf("%d ", y[i].x);
|
|
return 0;
|
|
} |