Jump and Jump...
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1219 Accepted Submission(s): 613
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 (1≤T≤100)
, indicating the number of test cases. For each test case: The first line contains an integer
n (2≤n≤3)
, indicating the number of kids. For the next
n
lines, each line contains three integers
ai,bi
and
ci
(
1≤ai,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
/**
此题不难,但是刚看到的时候给我一种无从下手的感觉,此处总结一下
首先要抽取真正有用的数据,那就是每个人跳的最远距离,然后在循环
中进行统计就可以了,当时一直想用set做,但思路并不清晰,所以碰到
题还是要老老实实的采取最常规的解题方法!!!
*/
#include<stdio.h>
#include<algorithm>
#include<string.h>
using namespace std;
int opt[1000];
int ans[1000];
int max3(int a,int b,int c)
{
return max(max(a,b),c);
}
int main()
{
int N;
scanf("%d",&N);
while(N--)
{
int n,a,b,c;
scanf("%d",&n);
for(int i = 0; i < n; i++)
{
scanf("%d%d%d",&a,&b,&c);
opt[i] = max3(a,b,c);
}
memset(ans,0,sizeof(ans));
for(int i = 0; i < n; i++)
for(int j = 0; j < n; j++)
{
if(opt[j] > opt[i])
ans[i]++;
}
printf("%d",ans[0]+1);
for(int i = 1; i < n; i++)
printf(" %d",ans[i]+1);
printf("\n");
}
return 0;
}