HDU 5162Jump and Jump...

来源:互联网 发布:投资软件 编辑:程序博客网 时间:2024/05/21 10:30

Jump and Jump...

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


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
2310 10 1010 20 3010 10 2023 4 11 2 1
 

Sample Output
3 1 21 2
Hint
For the first case, the farthest distance each kid can jump is 10, 30 and 20. So the rank is 3, 1, 2.
 

Source
BestCoder Round #27
 

Recommend
hujie   |   We have carefully selected several similar problems for you:  5165 5164 5161 5160 5159 
 

#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdlib>
#include<vector>
#include<cmath>
#include<stdlib.h>
#include<iomanip>
#include<list>
#include<deque>
#include<map>
#include <stdio.h>
#include <queue>
#include <stack>
#define maxn 10000+5
#define ull unsigned long long
#define ll long long
#define reP(i,n) for(i=1;i<=n;i++)
#define rep(i,n) for(i=0;i<n;i++)
#define cle(a) memset(a,0,sizeof(a))
#define mod 90001
#define PI 3.141592657
#define INF 1<<30
const ull inf = 1LL << 61;
const double eps=1e-5;

using namespace std;
struct node
{
int id;
int v;
int t;
}nod[10];
bool cmp(node a,node b){
return a.v>b.v;
}
int t,n;
int a,b,c;
int main()
{
//freopen("in.txt","r",stdin);
//freopen("out.txt","w",stdout);
cin>>t;
while(t--)
{
cin>>n;
for(int i=1;i<=n;i++)
{
cin>>a>>b>>c;
nod[i].v=max(a,max(b,c));
nod[i].id=i;
}
sort(nod+1,nod+1+n,cmp);
for(int i=1;i<=n;i++)
{
nod[nod[i].id].t=i;
}
for(int i=1;i<n;i++)
{
cout<<nod[i].t<<" ";
}
cout<<nod[n].t<<endl;
}
return 0;
}

最近才用到离散化,这个题目有点那个意思
0 0
原创粉丝点击