1 #include<iostream>
2 #include<algorithm>
3 #include<memory.h>
4 using namespace std;
5
6 typedef struct Tri{
7 int id;
8 int l;
9 int w;
10 Tri():id(0),l(0),w(0){}
11 }Tri;
12
13
14
15 bool cmp(Tri a, Tri b)
16 {
17 return a.id < b.id ||(a.id == b.id && a.l < b.l) || (a.id == b.id && a.l == b.l && a.w < b.w);
18 }
19
20 int main()
21 {
22 // freopen("in.txt","r",stdin);
23 int n,m,i;
24 cin>>n;
25 while(n--)
26 {
27 Tri tr[1001];
28 int a[10001];
29 memset(a,0,sizeof(a));
30 cin>>m;
31 for(i = 1; i <= m; ++i)
32 {
33 cin>>tr[i].id>>tr[i].l>>tr[i].w;
34 if(tr[i].l < tr[i].w) swap(tr[i].l,tr[i].w); //若长<宽: 交换
35 a[tr[i].id] = a[tr[i].id] < tr[i].l ? tr[i].l : a[tr[i].id];
36 }
37 sort(tr+1,tr+m+1,cmp); //排序
38 for(i = 1; i <= m; ++i)
39 {
40 if(tr[i].id == tr[i-1].id && tr[i].l == tr[i-1].l && tr[i].l != a[tr[i].id]) continue; //不输出,根据所给的条件
41 else if(tr[i].id != tr[i-1].id || tr[i].l != tr[i-1].l || tr[i].w != tr[i-1].w) //与上一个不相等,则输出
42 cout<<tr[i].id<<" "<<tr[i].l<<" "<<tr[i].w<<endl;
43 }
44 }
45 return 0;
46 }
2 #include<algorithm>
3 #include<memory.h>
4 using namespace std;
5
6 typedef struct Tri{
7 int id;
8 int l;
9 int w;
10 Tri():id(0),l(0),w(0){}
11 }Tri;
12
13
14
15 bool cmp(Tri a, Tri b)
16 {
17 return a.id < b.id ||(a.id == b.id && a.l < b.l) || (a.id == b.id && a.l == b.l && a.w < b.w);
18 }
19
20 int main()
21 {
22 // freopen("in.txt","r",stdin);
23 int n,m,i;
24 cin>>n;
25 while(n--)
26 {
27 Tri tr[1001];
28 int a[10001];
29 memset(a,0,sizeof(a));
30 cin>>m;
31 for(i = 1; i <= m; ++i)
32 {
33 cin>>tr[i].id>>tr[i].l>>tr[i].w;
34 if(tr[i].l < tr[i].w) swap(tr[i].l,tr[i].w); //若长<宽: 交换
35 a[tr[i].id] = a[tr[i].id] < tr[i].l ? tr[i].l : a[tr[i].id];
36 }
37 sort(tr+1,tr+m+1,cmp); //排序
38 for(i = 1; i <= m; ++i)
39 {
40 if(tr[i].id == tr[i-1].id && tr[i].l == tr[i-1].l && tr[i].l != a[tr[i].id]) continue; //不输出,根据所给的条件
41 else if(tr[i].id != tr[i-1].id || tr[i].l != tr[i-1].l || tr[i].w != tr[i-1].w) //与上一个不相等,则输出
42 cout<<tr[i].id<<" "<<tr[i].l<<" "<<tr[i].w<<endl;
43 }
44 }
45 return 0;
46 }