签到题它又来了
原题链接https://nuoyanli.com/contest/32/problem/C
将每一组长方体数据录入结构体中,并加入一个数据来进行判断是否要输出
遍历结构体 如果有一样的长方体就只留下一个,
sort按题目要求排序 输出
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<iostream>
using namespace std;
struct node
{
long long c;
long long k;
long long id;
long long p;
}stu[10001];
bool cmp(node xx,node yy)
{
if(xx.id==yy.id)
{
if(xx.c==yy.c)
{
return xx.k<yy.k;
}
return xx.c<yy.c;
}
return xx.id<yy.id;
}
int main()
{
long long n;
long long m;
scanf("%lld",&n);
while(n--)
{
long long i,j,a,b,z;
memset(stu,0,sizeof(stu));
scanf("%lld",&m);
for(i=0;i<m;i++)
{
scanf("%lld %lld %lld",&stu[i].id,&a,&b);
if(a>=b)
{
stu[i].c=a;
stu[i].k=b;
}
else if(a<b)
{
stu[i].c=b;
stu[i].k=a;
}
stu[i].p=1;
}
for(i=0;i<m;i++)
{
for(j=i;j<m;j++)
{
if(stu[i].c==stu[j].c&&stu[i].id==stu[j].id&&stu[i].k==stu[j].k&&i!=j)
{
stu[i].p=0;
}
}
}
sort(stu,stu+m,cmp);
for(i=0;i<m;i++)
{
if(stu[i].p==1)
{
printf("%lld %lld %lld\n",stu[i].id,stu[i].c,stu[i].k);
}
}
}
return 0;
}