⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 2272191_tle.cc

📁 北大大牛代码 1240道题的原代码 超级权威
💻 CC
字号:
#include <stdio.h>
#include <algorithm>

struct node
{
	int d;
	int id;
	int c;
}hotel[10001], tmp[10001];

bool cmp(struct node a,struct node b)
{
	return a.d<b.d;
}

bool Cmp(struct node a,struct node b)
{
	return a.c<b.c;
}

int main()
{
	int ans;
	int res[10001];
	bool m1, m2;
	int i, j, n;

	while(scanf("%d",&n)&&n)
	{
		ans = 0;
		for(i = 0; i < n; i++)
		{
			scanf("%d%d",&hotel[i].d,&hotel[i].c);
			hotel[i].id = i;
			res[i] = 0;
			tmp[i] = hotel[i];
		}
		std::sort(hotel,hotel+n,cmp);
		std::sort(tmp,tmp+n,Cmp);
		for(i = 0; i < n; i++)
		{
			m1 = 1;
			for(j = i-1; j >= 0; j--)
				if(hotel[j].d==hotel[i].d)
					continue;
				else
					if(hotel[j].c<=hotel[i].c)
					{
						m1 = 0;
						break;
					}
			res[hotel[i].id] += m1;
			m2 = 1;
			for(j = i-1; j >= 0; j--)
				if(tmp[j].c==tmp[i].c)
					continue;
				else
					if(tmp[j].d<=tmp[i].d)
					{
						m2 = 0;
						break;
					}
			res[tmp[i].id] += m2;
		}
		for(i = 0; i < n; i++)
			if(res[i]==2)
				ans++;
		printf("%d\n",ans);
	}
	return 1;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -