[luoguP1056] 排座椅(sort + 模拟)

传送门

 

nc题,一直sort就过了

 

代码

#include <cstdio>
#include <iostream>
#include <algorithm>
#define N 2001
#define min(x, y) ((x) < (y) ? (x) : (y))

int n, m, k, l, d;

struct node
{
	int v, id;
}p1[N], p2[N];

inline int read()
{
	int x = 0, f = 1;
	char ch = getchar();
	for(; !isdigit(ch); ch = getchar()) if(ch == '-') f = -1;
	for(; isdigit(ch); ch = getchar()) x = (x << 1) + (x << 3) + ch - '0';
	return x * f;
}

inline bool cmp(node x, node y)
{
	return x.v > y.v;
}

inline bool cmp1(node x, node y)
{
	return x.id < y.id;
}

int main()
{
	int i, x1, x2, y1, y2;
	n = read();
	m = read();
	k = read();
	l = read();
	d = read();
	for(i = 1; i < n; i++) p1[i].id = i;
	for(i = 1; i < m; i++) p2[i].id = i;
	for(i = 1; i <= d; i++)
	{
		x1 = read();
		y1 = read();
		x2 = read();
		y2 = read();
		if(x1 ^ x2) p1[min(x1, x2)].v++;
		if(y1 ^ y2) p2[min(y1, y2)].v++;
	}
	std::sort(p1 + 1, p1 + n, cmp);
	std::sort(p1 + 1, p1 + k + 1, cmp1);
	for(i = 1; i <= k; i++) printf("%d ", p1[i].id);
	puts("");
	std::sort(p2 + 1, p2 + m, cmp);
	std::sort(p2 + 1, p2 + l + 1, cmp1);
	for(i = 1; i <= l; i++) printf("%d ", p2[i].id);
	puts("");
	return 0;
}

  

posted @ 2017-06-26 15:43  zht467  阅读(122)  评论(0编辑  收藏  举报