HDU-5702-Solving Order【2016CCPC女生专场】
2016-07-03 10:49
501 查看
Solving Order
Problem DescriptionWelcome 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.
Input
The first line is an integer T which indicates the case number.
And as for each case, the first line is an integer n, which is the number of problems.
Then there are n 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.
Output
For each case, you need to output a single line.
There should be n 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.
Sample Input
3
3
red 1
green 2
yellow 3
1
blue 83
2
red 2
white 1
Sample Output
yellow green red
blue
red white
题目链接:HDU-5702
题目大意:给出每种颜色的名称及分值。按分值递减输出颜色名称
题目思路:水题,从女生赛到现在很久没刷题了。明天开始集训orz,练练手.
以下是代码:
// // main.cpp // 2016-CCPC-GIRL // // Created by pro on 16/7/3. // Copyright (c) 2016年 loy. All rights reserved. // #include <iostream> #include <cstdio> #include <cmath> #include <vector> #include <cstring> #include <algorithm> #include <string> #include <set> #include <functional> #include <numeric> #include <sstream> #include <stack> #include <map> #include <queue> #include<iomanip> using namespace std; struct node { string name; int val; }p[105]; bool cmp(node a,node b) { return a.val > b.val; } int main() { int t; cin >> t; while(t--) { int n; cin >> n; for (int i = 0; i < n; i++) { cin >> p[i].name >> p[i].val; } sort(p, p + n, cmp); cout << p[0].name; for (int i = 1; i < n; i++) { cout << " " << p[i].name; } cout << endl; } return 0; }
相关文章推荐
- 【HDU 5366】The mook jong 详解
- 【HDU 2136】Largest prime factor 详细图解
- 【HDU 1568】Fibonacci 数学公式 详解
- HDU 1568
- HDU1290
- HDU1568(Fobonacci公式)
- HDU ACM Step 2.2.2 Joseph(约瑟夫环问题)
- HDU 1405
- HDU 1297
- hdu 1205
- hdu 2087
- hdu 1016
- HDU 4898 The Revenge of the Princess’ Knight ( 2014 Multi-University Training Contest 4 )
- HDU 5592 ZYB's Premutation 线段树(查找动态区间第K大)
- HDU 5240 Exam (好水的题)
- HDU5237 Base64 大模拟
- HDU 1000
- HDU 1001
- NOIP 2003 - 普及组 乒乓球 模拟+“高级”水题 重庆一中高2018级竞赛班第八次测试 2016.8.7 Problem 4
- Cpp环境【GRYZ2015】【Vijos3150】 足球联赛