50pts 求助
查看原帖
50pts 求助
385260
平凡天梦楼主2020/11/29 16:40
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;

const int N=21000;
int m,n,k,l,d;
int tota,totb;
int aa[N],bb[N];

struct Nodea
{
	int sum;
	int id;
}a[N];

struct Nodeb
{
	int sum;
	int id;
}b[N];

bool cmpa(Nodea x,Nodea y)
{
	return x.sum>y.sum;
}

bool cmpb(Nodeb x,Nodeb y)
{
	return x.sum>y.sum;
}

bool cmpaa(Nodea x,Nodea y)
{
	return x.id<y.id;
}

bool cmpbb(Nodeb x,Nodeb y)
{
	return x.id<y.id;
}

int main()
{
	scanf("%d%d%d%d%d",&m,&n,&k,&l,&d);
	for(int i=1;i<=d;i++)
	{
		int t,r,p,q;
		scanf("%d%d%d%d",&t,&r,&p,&q);
		if(t==p) 
		{
			int h;
			h=min(r,q);
			b[h].id=h;
			b[h].sum++;
		}
		if(r==q) 
		{
			int h;
			h=min(t,p);
			a[h].id=h;
			a[h].sum++;
		}
	}
	sort(a+1,a+n+1,cmpa);sort(b+1,b+m+1,cmpb);
	sort(a+1,a+n+1,cmpaa);sort(b+1,b+m+1,cmpbb);
	for(int i=1;i<=n;i++) 
	{
		if(tota==k) break;
		if(!a[i].id) continue;
		printf("%d ",a[i].id);
		tota++;
	}
	printf("\n");
	for(int i=1;i<=m;i++) 
	{
		if(totb==l) break;
		if(!b[i].id) continue;
		printf("%d ",b[i].id);
		totb++;
	}
	return 0;
}
2020/11/29 16:40
加载中...