洛谷 P1056 排座椅
/*
P1056 排座椅
*/
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int main() {
int m, n, k, l, d; cin >> m >> n >> k >> l >> d;
int* row = new int[m]();
int* column = new int[n]();
for(int i = 0; i < d; i++) {
int x, y, p, q; scanf("%d%d%d%d", &x,&y,&p,&q);
if(x == p) {
column[min(y, q)] ++;
} else {
row[min(x, p)] ++;
}
}
int* row_line = new int[m]();
int* column_line = new int[n]();
for(int i = 0; i < k; i++) {
int max = -1, temp = -1;
for(int j = 0; j < m; j++) {
if(row[j] > max) {
max = row[j];
temp = j;
}
}
row[temp] = 0;
row_line[temp] ++;
}
for(int i = 0; i < l; i++) {
int max = -1, temp = -1;
for(int j = 0; j < n; j++) {
if(column[j] > max) {
max = column[j];
temp = j;
}
}
column[temp] = 0;
column_line[temp] ++;
}
int cnt = 0;
for(int i = 0; i < m; i++) {
if(row_line[i]) {
cout << i; cnt ++;
if(cnt != k) cout << " ";
}
}
cout << endl;
cnt = 0;
for(int i = 0; i < n; i++) {
if(column_line[i]) {
cout << i; cnt ++;
if(cnt != l) cout << " ";
}
}
cout << endl;
delete[] row;
delete[] column;
delete[] row_line;
delete[] column_line;
return 0;
}