nyoj 8

http://acm.nyist.net/JudgeOnline/problem.php?pid=8

 1 #include<stdio.h>
 2 #include<iostream>
 3 #include<string>
 4 #include<algorithm>
 5 using namespace std;
 6 struct node
 7 {
 8     int s;
 9     int l;
10     int r;
11 }t[1001];
12 int max(int x,int y )
13 {
14     return x>y?x:y;
15 }
16 int min(int x,int y)
17 {
18     return x<y?x:y;
19 }
20 bool cmp(node x,node y)
21 {
22     if(x.s!=y.s)
23     {
24         return x.s<y.s;
25     }
26     else 
27     {
28         if(x.l!=y.l)
29             return x.l<y.l;
30         else
31             return x.r<y.r;
32     }
33 }
34 int main()
35 {
36     int t1,i,a,b,c,n;
37     scanf("%d",&t1);
38     while(t1--)
39     {
40         scanf("%d",&n);
41         for(i=0;i<n;i++)
42             scanf("%d %d %d",&t[i].s,&a,&b),
43             t[i].l=max(a,b),
44             t[i].r=min(a,b);
45         sort(t,t+n,cmp);
46         for(i=0;i<n;i++)
47         {
48             while(t[i+1].l==t[i].l&&t[i].l==t[i+1].l&&t[i].r==t[i+1].r&&i+1<n)i++;
49             printf("%d %d %d\n",t[i].s,t[i].l,t[i].r);
50         }    
51     }
52     //system("pause");
53     return 0;
54 }
View Code

 

posted @ 2014-04-04 20:23  陈泽泽  阅读(152)  评论(0编辑  收藏  举报