排座椅
作者:
jy9
,
2024-08-19 13:40:49
,
所有人可见
,
阅读 1
#include <iostream>
#include <algorithm>
using namespace std;
const int N = 1010;
int row[N], col[N], row3[N], col3[N];
struct node{
int num, val;
bool operator < (const node &p) const{
return val > p.val;
}
}row2[N], col2[N];
int m, n, k, l, d;
int main(){
cin >> m >> n >> k >> l >> d;
int x1, y1, x2, y2;
while (d --){
cin >> x1 >> y1 >> x2 >> y2;
if(x1 == x2)col[min(y1, y2)]++;
else if(y1 == y2)row[min(x1, x2)]++;
}
for (int i = 1; i <= m; i ++ ){
row2[i].num = i;
row2[i].val = row[i];
}
for (int i = 1; i <= n; i ++ ){
col2[i].num = i;
col2[i].val = col[i];
}
sort(row2+1, row2+1+m);
sort(col2+1, col2+1+n);
for (int i = 1; i <= k; i ++ ) row3[i] = row2[i].num;
for (int i = 1; i <= l; i ++ ) col3[i] = col2[i].num;
sort(row3 + 1, row3 + 1 + k);
sort(col3 + 1, col3 + 1 + l);
for (int i = 1; i <= k; i ++ ) cout << row3[i] << ' ';
cout << endl;
for (int i = 1; i <= l; i ++ ) cout << col3[i] << ' ';
cout << endl;
return 0;
}