1.用x,y数组存放切了几对学生,用数组的下标记录切的位置
2.按照题目要求k和l依次取出最大的数组的值,并将其变为-1,
再次循环取出第二大的值,之后所有下标为-1的的下标就是切的学生对多的
3.切的意思是把两个学生分开
#include <bits/stdc++.h>
using namespace std;
int x[1005], y[1005];
int main() {
int m, n, k, l, d;
cin >> m >> n >> k >> l >> d;
for (int i = 0; i < d; i++) {
int aa, ab, ba, bb;
cin >> aa >> ab >> ba >> bb;
if (aa == ba)//竖着切
y[min(ab, bb)]++;
else//横着切
x[min(aa, ba)]++;
}
//L是纵向,K是横向
while (k--) {
int max = 0,p;
for (int i = 1; i <= m; i++) {
if (x[i] > max) {
max = x[i];
p = i;
}
}
x[p] = -1;
}
while (l--) {
int max = 0, p;
for (int i = 1; i <= m; i++) {
if (y[i] > max) {
max = y[i];
p = i;
}
}
y[p] = -1;
}
for (int i = 1; i <= m; i++) {
if (x[i] == -1)
cout << i << ' ';
}
cout << endl;
for (int i = 1; i <= n; i++) {
if (y[i] == -1)
cout << i << ' ';
}
return 0;
}
标签:aa,ab,ba,bb,int,max,NOIP2008,座椅,P1056
From: https://blog.csdn.net/2303_79812533/article/details/142304844