蒟蒻代码,5wa求调(悬赏一关)
查看原帖
蒟蒻代码,5wa求调(悬赏一关)
921176
leiwenjin1234楼主2023/9/30 21:41
#include<bits/stdc++.h>
using namespace std;
priority_queue<int,vector<int>,greater<int>> a1;
priority_queue<int,vector<int>,greater<int>> a2;
typedef struct M {
	int num;
	int a;
} M;
int n, m, k, s, d;
M l[10001], h[10001];
bool cmp(const M&a, const M&b) {
	return a.a < b.a;
}
int main() {
	cin >> m >> n >> k >> s >> d;
	for (int i = 1; i <= d; i++) {
		int x1, y1, x2, y2;
		cin >> y1 >> x1 >> y2 >> x2;

		if (y1 == y2) {
			l[min(x1, x2)].a++, l[min(x1, x2)].num = min(x1, x2);
		} else {
			h[min(y1, y2)].a++, h[min(y1, y2)].num = min(y1, y2);
		}
	}
	sort(l + 1, l + 1 + n, cmp);
	sort(h + 1, h + 1 + m, cmp);
	int t=0;
	for (int i = 1; i <= n; i++) {
		if ( h[i].num )a1.push(h[i].num),t++ ;
		if(t==k)break;
	}
	t=0;
	for (int i = 1; i <= m; i++) {
		if ( l[i].num )a2.push(l[i].num) ,t++;
		if(t==s)break;
	}
	while(!a1.empty()){
	    cout<<a1.top()<<" ";
	    a1.pop();
	}
	cout<<endl;
	while(!a2.empty()){
	    cout<<a2.top()<<" ";
	    a2.pop();
	}
}
/*
4 4 1 2 5
3 2 3 3
1 1 1 2
2 1 2 2
2 3 1 3
3 4 2 4

*/
2023/9/30 21:41
加载中...