提交时间:2023-11-03 13:51:47
运行 ID: 108514
#include <iostream> #include <algorithm> using namespace std; int m, n, p, q, d; int x1, y1, x2, y2; struct node { int num, pos; }; node x[1005], y[1005]; bool cmp(node a, node b) { return a.num > b.num; } bool cmp_(node a, node b) { return a.pos < b.pos; } int main() { cin >> m >> n >> p >> q >> d; for (int i = 1; i <= d; i++) { cin >> x1 >> y1 >> x2 >> y2; if (x1 != x2) { x[min(x1, x2)].num++; x[min(x1, x2)].pos = min(x1, x2); } else { y[min(y1, y2)].num++; y[min(y1, y2)].pos = min(y1, y2); } } sort(x + 1, x + n + 1, cmp); sort(y + 1, y + m + 1, cmp); sort(x + 1, x + p + 1, cmp_); sort(y + 1, y + q + 1, cmp_); for (int i = 1; i <= p; i++) { cout << x[i].pos << " "; } cout << endl; for (int i = 1; i <= q; i++) { cout << y[i].pos << " "; } return 0; }