Start: Jul, 05, 2019 08:40:00
2019年度暑期短学期达标测试
End: Jul, 05, 2019 11:40:00
Time elapsed:
Time remaining:

Problem_ID: K
Result: Accepted
Time: 123ms
Memory: 8280kB
Author: CT12810341281
In contest: 1281

#include<bits/stdc++.h>
using namespace std;
int h;
const int maxx = 1e5+10;
struct Stu1{
	int id;
	int zs,yz;
	int tot;
}stu1[maxx];
struct Stu2{
	int id;
	int zs,yz;
	int tot;
}stu2[maxx];
struct Stu3{
	int id;
	int zs,yz;
	int tot;
}stu3[maxx];
struct Stu4{
	int id;
	int zs,yz;
	int tot;
}stu4[maxx];
int cmp1(Stu1 a,Stu1 b)
{
	if(a.tot == b.tot)
	{
		if(a.zs == b.zs)
			return a.id < b.id;
		return a.zs > b.zs;
	}
	return a.tot > b.tot;
}
int cmp2(Stu2 a,Stu2 b)
{
	if(a.tot == b.tot)
	{
		if(a.zs == b.zs)
			return a.id < b.id;
		return a.zs > b.zs;
	}
	return a.tot > b.tot;
}
int cmp3(Stu3 a,Stu3 b)
{
	if(a.tot == b.tot)
	{
		if(a.zs == b.zs)
			return a.id < b.id;
		return a.zs > b.zs;
	}
	return a.tot > b.tot;
}
int cmp4(Stu4 a,Stu4 b)
{
	if(a.tot == b.tot)
	{
		if(a.zs == b.zs)
			return a.id < b.id;
		return a.zs > b.zs;
	}
	return a.tot > b.tot;
}
int main()
{
	int n,l;
	int ans1 = 0,ans2 = 0,ans3 = 0,ans4 = 0;
	scanf("%d %d %d",&n,&l,&h);
	int a,b,c;
	for(int i = 1;i <= n;++i)
	{
		scanf("%d %d %d",&a,&b,&c);
		if(b>=l && c>=l)
		{
			if(b>=h && c>=h)
			{
				stu1[ans1].id = a;
				stu1[ans1].zs = b;
				stu1[ans1].yz = c;
				stu1[ans1].tot = b+c;
				ans1++;
			}
			else if(b>=h && c<h)
			{
				stu2[ans2].id = a;
				stu2[ans2].zs = b;
				stu2[ans2].yz = c;
				stu2[ans2].tot = b+c;
				ans2++;
			}
			else if(b<h && c<h && b>=c)
			{
				stu3[ans3].id = a;
				stu3[ans3].zs = b;
				stu3[ans3].yz = c;
				stu3[ans3].tot = b+c;
				ans3++;
			}
			else
			{
				stu4[ans4].id = a;
				stu4[ans4].zs = b;
				stu4[ans4].yz = c;
				stu4[ans4].tot = b+c;
				ans4++;
			}
		}
	}
	sort(stu1,stu1+ans1,cmp1);
	sort(stu2,stu2+ans2,cmp2);
	sort(stu3,stu3+ans3,cmp3);
	sort(stu4,stu4+ans4,cmp4);
	printf("%d\n",ans1+ans2+ans3+ans4);
	for(int i = 0;i < ans1;++i)
		printf("%d %d %d\n",stu1[i].id,stu1[i].zs,stu1[i].yz);
	for(int i = 0;i < ans2;++i)
		printf("%d %d %d\n",stu2[i].id,stu2[i].zs,stu2[i].yz);
	for(int i = 0;i < ans3;++i)
		printf("%d %d %d\n",stu3[i].id,stu3[i].zs,stu3[i].yz);
	for(int i = 0;i < ans4;++i)
		printf("%d %d %d\n",stu4[i].id,stu4[i].zs,stu4[i].yz);
	return 0;
}