提交时间:2023-11-02 13:26:46
运行 ID: 108347
#include <iostream> using namespace std; struct People { int num, cnt; }x[1005], y[1005]; bool cmpx(People a, People b) { return a.num > b.num; } bool cmpy(People a, People b) { return a.cnt < b.cnt; } int main() { int a , b; int n , m; int N; int x1, y1, x2, y2; cin >> a >> b; cin >> n >> m; cin >> N; for (int i = 1; i <= N; i++) { cin >> x1 >> y1 >> x2 >> y2; if (x1 != x2) { x[min(x1, x2)].num++; x[min(x1, x2)].cnt = min(x1, x2); } else { y[min(y1, y2)].num++; y[min(y1, y2)].cnt = min(y1, y2); } } sort(x + 1, x + b + 1, cmpx); sort(y + 1, y + a + 1, cmpx); sort(x + 1, x + n + 1, cmpy); sort(y + 1, y + m + 1, cmpy); for (int i = 1; i <= n; i++) cout << x[i].cnt << " "; cout << endl; for (int i = 1; i <= m; i++) cout << y[i].cnt << " "; return 0; }