hdu 5612 Jump and Jump

 

这是bestcoder #27的第一题,一般都是水题,由于本人仍是个渣渣,所以卡在了最后如何标记排序的序号上,犯了2个错误:

 

1,我是用结构体做的,记录每个人最大值排序后,不会改变相应编号,其实就是数组的套用,类似b[a[i].k]这样。(一直在纠结如何换过来,原来这么简单,自己太渣了)

2,在用标志变量的时候,为了方便,重复利用了一些,结果各种错,但是逻辑是对的,相当无奈,所以又重新定义了一些变量。(也不知道编译器是怎么处理的)

Jump and Jump...

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 120    Accepted Submission(s): 86


Problem Description
There are n kids and they want to know who can jump the farthest. For each kid, he can jump three times and the distance he jumps is maximum distance amount all the three jump. For example, if the distance of each jump is (10, 30, 20), then the farthest distance he can jump is 30. Given the distance for each jump of the kids, you should find the rank of each kid.
 


 

Input
There are multiple test cases. The first line of input contains an integer T (1T100) , indicating the number of test cases. For each test case: The first line contains an integer n (2n3) , indicating the number of kids. For the next n lines, each line contains three integers ai,bi and ci ( 1ai,bi,ci,300 ), indicating the distance for each jump of the i -th kid. It's guaranteed that the final rank of each kid won't be the same (ie. the farthest distance each kid can jump won't be the same).
 


 

Output
For each test case, you should output a single line contain n integers, separated by one space. The i -th integer indicating the rank of i -th kid.
 


 

Sample Input
  
  
2 3 10 10 10 10 20 30 10 10 20 2 3 4 1 1 2 1
 


 

Sample Output
  
  
3 1 2 1 2
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int b[1010];
struct E
{
    int n;
    int k;
}a[1010],c[1010];
int cmp(E a,E b)
{
    return a.n>b.n;
}
int main()
{
    int t,m,i,j;

    scanf("%d",&t);
    while(t--)
   {
       scanf("%d",&m);
       memset(b,0,sizeof(b));
       memset(a,0,sizeof(a));
       for(i=0;i<m;i++)
       {
           for(j=0;j<3;j++)
            scanf("%d",&a[j].n);
           sort(a,a+3,cmp);
            c[i].n=a[0].n;
            c[i].k=i+1;
       }
       sort(c,c+m,cmp);
     int r=1;
     for(i=0;i<m;i++)
        {
            b[c[i].k]=r++;
        }
     for(i=1;i<m;i++)
        printf("%d ",b[i]);
     printf("%d",b[m]);
       printf("\n");
   }
   return 0;
}


 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值