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