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. 机器C盘临时区

    系统的临时区里:C:\Documents and Settings\Administrator(用户名)\Local Settings\Temporary Internet Files 这是临时文件夹 ...

  2. IDEA多线程下多个线程切换断点运行调试的技巧

    多线程调试设置可以参考:http://www.cnblogs.com/leodaxin/p/7710630.html 1 断点设置如图: 2 测试代码,然后进行debug package com.da ...

  3. 快速对Mysql添加索引的五个方法

    1.添加PRIMARY KEY(主键索引) mysql>ALTER TABLE `table_name` ADD PRIMARY KEY ( `column` ) 2.添加UNIQUE(唯一索引 ...

  4. win7(64位)Sql server 用T-sql读取本地数据文件dbf的数据文件

    原文地址:https://www.cnblogs.com/cl1006/p/9924066.html 第一步启用Ad Hoc Distributed Queries  在SQLserver执行以下的语 ...

  5. http请求的全过程

    参考资料 http://blog.jobbole.com/106632/ https://www.cnblogs.com/engeng/articles/5959335.html https://ww ...

  6. 查看mysql执行的线程,并杀掉他

    文章转自https://www.cnblogs.com/weiok/p/5672238.html 1.进入mysql/bin目录下输入mysqladmin processlist; 2.启动mysql ...

  7. 关于Nginx

    访问 www.a.com 自动跳到 www.b.com(301跳转设置) server { listen 80; server_name www.a.com; rewrite ^/(.*)$  htt ...

  8. C++ 指针常量和常量指针

    1.指针常量(*const):对应指针变量,即指针本身是常量,指针指向的内容可以被修改. 2.常量指针(const*):常量的指针,即指针指向的内容不能被修改,但指针本身是变量,可以被修改.

  9. Spring对JSON请求加解密

    Spring中处理JSON请求通常使用@RequestBody和@ResponseBody注解,针对JSON请求加解密和过滤字符串,Spring提供了RequestBodyAdvice和Respons ...

  10. Android 去掉ScrollView、GridView、ListView向上 滑动时顶部的投影/阴影

    在ScrollView.GridView.ListView向上滑动的过程中,这些控件的顶部会出现一个系统默认的白色阴影,有些时候这个白色的阴影看上去好看,那么就需要除去. 去掉方法:在ScrollVi ...