http://acm.hdu.edu.cn/showproblem.php?pid=5702

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.

 
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
 
代码:
#include <bits/stdc++.h>

using namespace std;

const int maxn = 1e5+10;
int n; struct Balloons
{
char color[11];
int num;
} s[maxn]; void display()
{
for(int i=1; i<=n; i++)
{
if(i!=n)
printf("%s ",s[i].color);
else
printf("%s\n",s[i].color);
}
} bool cmpNum(const Balloons& a,const Balloons& b)
{
return a.num>b.num;
} int main()
{
int T;
scanf("%d",&T);
for(int i=1; i<=T; i++)
{
scanf("%d",&n);
for(int j=1; j<=n; j++)
{
scanf("%s%d",&s[j].color,&s[j].num);
}
int L=1,R=n;
sort(s+L,s+R+1,cmpNum);
display();
}
return 0;
}

  

HDU 5702 Solving Order的更多相关文章

  1. HDU 5702 Solving Order (水题,排序)

    题意:给定几种不同的颜色和它的权值,按它的权值排序. 析:排序. 代码如下: #include <cstdio> #include <string> #include < ...

  2. hdu 3999 The order of a Tree (二叉搜索树)

    /****************************************************************** 题目: The order of a Tree(hdu 3999 ...

  3. <hdu - 3999> The order of a Tree 水题 之 二叉搜索的数的先序输出

    这里是杭电hdu上的链接:http://acm.hdu.edu.cn/showproblem.php?pid=3999  Problem Description: As we know,the sha ...

  4. HDU 3999 The order of a Tree

    The order of a Tree Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Othe ...

  5. HDU 3999 The order of a Tree (先序遍历)

    The order of a Tree Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Othe ...

  6. HDU 3999 The order of a Tree 二叉搜索树 BST

    建一个二叉搜索树,然后前序输出. 用链表建的,发现很久没做都快忘了... #include <cstdio> #include <cstdlib> struct Node{ i ...

  7. 2019的hdu暑假作业(欢迎纠错)

    1219 遍历计数. #include<bits/stdc++.h> #define QAQ 0 using namespace std; ]; ]; int main(){ )){ me ...

  8. 2016女生专场 ABCDEF题解 其他待补...

    GHIJ待补... A.HUD5702:Solving Order Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/3276 ...

  9. STL专题

    一.algorithm 1.sort 问题1:给你n个整数,请按从大到小的顺序输出其中前m大的数. Input:每组测试数据有两行,第一行有两个数n,m(0<n,m<1000000),第二 ...

随机推荐

  1. IO_ObjectOutputStream(对象的序列化)

    对象序列化就是将一些对象写入到硬盘中存储起来,以便下次复用 import java.io.FileInputStream; import java.io.FileOutputStream; impor ...

  2. remove-duplicates-from-sorted-list (删除)

    题意略: 思路:先造一个点它与所有点的值都不同,那么只要后面两个点的值相同就开始判断后面是不是也相同,最后将相同的拆下来就可以了. #include<iostream> #include& ...

  3. 控制input输入框光标的位置

    一:理解input, textarea元素在标准浏览器下两个属性selectionStart, selectionEnd. selectionStart: 该属性的含义是 选区开始的位置: selec ...

  4. PAT A1150 Travelling Salesman Problem (25 分)——图的遍历

    The "travelling salesman problem" asks the following question: "Given a list of citie ...

  5. nginx-1.13.12 源码配置清单

    configure命令支持以下参数: --help打印帮助信息. --prefix=安装路径定义一个将保留服务器文件的目录.这个相同的目录也将被用于由configure(由库源创建的路径除外)和ngi ...

  6. DHT11温度传感器应用电路

    DHT11应用电路: 注意点: Vcc和GND之间连接一个100 μF的一个电解电容(通常电容的取值在100μF-300μF之间,滤波) SWI接一个5K的上拉电阻,目的是增强驱动能力

  7. jmeter(十八)关联之XPath Extractor

    之前的博客,有介绍jmeter如何对请求进行关联的一种常见用法,即:后置处理器中的正则表达式提取器,下面介绍另一种关联方法,XPath Extractor! 所谓关联,从业务角度讲,即:某些操作步骤与 ...

  8. Android 由 android:launchMode="singleInstance“引发的界面无法返回的情况

    问题描述:现有A.B.C三个Activity.现在A跳转到B再由B跳转到C,然后依次返回.正常情况是C先返回B然后再返回的A.但现在的情况是C直接跳过B直接返回到A了. 解决办法:认真排查了A.B.C ...

  9. 自行实现高性能MVC

    wcf虽然功能多.扩展性强但是也面临配置忒多,而且restful的功能相当怪异,并且目前没法移植.asp.net core虽然支持webapi,但是功能也相对繁多.配置复杂.就没有一个能让码农们安安心 ...

  10. Artificial Intelligence Computing Conference(2018.09.12)

    时间:2018.09.12地点:北京国际饭店会议中心