HDU
来源:互联网 发布:钢筋笼计算软件 编辑:程序博客网 时间:2024/06/03 19:27
Solving Order
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1245 Accepted Submission(s): 817
Problem Description
Welcome to HDU to take part in the first CCPC girls' competition!
As a pretty special competition, many volunteers are preparing for it with high enthusiasm.
One thing they need to do is blowing the balloons.
Before sitting down and starting the competition, you have just passed by the room where the boys are blowing the balloons. And you have found that the number of balloons of different colors are strictly different.
After thinking about the volunteer boys' sincere facial expressions, you noticed that, the problem with more balloon numbers are sure to be easier to solve.
Now, you have recalled how many balloons are there of each color.
Please output the solving order you need to choose in order to finish the problems from easy to hard.
You should print the colors to represent the problems.
As a pretty special competition, many volunteers are preparing for it with high enthusiasm.
One thing they need to do is blowing the balloons.
Before sitting down and starting the competition, you have just passed by the room where the boys are blowing the balloons. And you have found that the number of balloons of different colors are strictly different.
After thinking about the volunteer boys' sincere facial expressions, you noticed that, the problem with more balloon numbers are sure to be easier to solve.
Now, you have recalled how many balloons are there of each color.
Please output the solving order you need to choose in order to finish the problems from easy to hard.
You should print the colors to represent the problems.
Input
The first line is an integer T which indicates the case number.
And as for each case, the first line is an integern , which is the number of problems.
Then there aren lines followed, with a string and an integer in each line, in the i -th line, the string means the color of ballon for the i -th problem, and the integer means the ballon numbers.
It is guaranteed that:
T is about 100.
1≤n≤10 .
1≤ string length ≤10 .
1≤ bolloon numbers ≤83 .(there are 83 teams :p)
For any two problems, their corresponding colors are different.
For any two kinds of balloons, their numbers are different.
And as for each case, the first line is an integer
Then there are
It is guaranteed that:
For any two problems, their corresponding colors are different.
For any two kinds of balloons, their numbers are different.
Output
For each case, you need to output a single line.
There should ben strings in the line representing the solving order you choose.
Please make sure that there is only a blank between every two strings, and there is no extra blank.
There should be
Please make sure that there is only a blank between every two strings, and there is no extra blank.
Sample Input
33red 1green 2yellow 31blue 832red 2white 1
Sample Output
yellow green redbluered white
用sort排结构体即可
#include<stdio.h>#include<iostream>#include<algorithm>using namespace std;struct AP{ char boloon[100]; int x;} a[1000];bool compare(AP a,AP b);int main(){ int N; cin>>N; while(N--) { int n; cin>>n; for(int i=0; i<n; i++) cin>>a[i].boloon>>a[i].x; sort(a,a+n,compare); cout<<a[0].boloon; for(int i=1; i<n; i++) cout<<' '<<a[i].boloon; cout<<endl; } return 0;}bool compare(AP a,AP b){ return a.x>b.x;}
阅读全文
0 0
- hdu
- hdu
- HDU
- hdu ()
- hdu
- hdu
- HDU
- HDU
- hdu
- hdu
- HDU
- Hdu
- hdu
- hdu-
- hdu
- hdu
- hdu
- HDU
- Java IO2
- DFS- SDUT1269 走迷宫
- 【8086汇编】基础排序之希尔排序
- ubuntu下php环境安装
- 存储系统
- HDU
- Ubuntu16.04+Cuda8.0+1080ti+caffe+免OpenCV+faster-rcnn教程
- HDU-1257 最少拦截系统
- 封斋第一天
- SSM-maven-IntelliJ搭建
- 解决VS Code保存时候自动格式化
- iOS攻防
- POJ
- 【XML解析】(2)利用DOM解析技术对XML文档进行增删改查操作