蒟蒻结构体贪心10分求助
查看原帖
蒟蒻结构体贪心10分求助
727008
lwx20211103楼主2022/11/20 16:01

找不出错误在哪里awa

#include<bits/stdc++.h>
using namespace std;

struct stu
{
	int person, cnt;
};

stu a[114514], b[114514];

bool compare1(stu x, stu y)
{
	return x.person > y.person;
}

bool compare2(stu x, stu y)
{
	return x.cnt < y.cnt;
}

int main()
{
	int m, n, k, l, d;
	int i;
	cin >> m >> n >> k >> l >> d;
	for (i = 0; i < d; i++)
	{
		int x1, y1, x2, y2;
		cin >> x1 >> y1 >> x2 >> y2;
		if (x1 == x2)
		{
			a[min(y1, y2)].cnt = min(y1, y2);
			a[min(y1, y2)].person++;
		}
		else
		{
			b[min(x1, x2)].cnt = min(x1, x2);
			b[min(x1, x2)].person++;
		}
	}
	sort(a, a + 10000, compare1);
	sort(b, b + 10000, compare1);
	sort(a, a + k, compare2);
	sort(b, b + l, compare2);
	for (i = 0; i < k; i++)
	{
		cout << a[i].cnt << " ";
	}
	cout << "\n";
	for (i = 0; i < l; i++)
	{
		cout << b[i].cnt << " ";
	}
	return 0;
}
2022/11/20 16:01
加载中...