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. Matplotlib入门

    使用之前首先下载:pip install  Matplotlib 接着引入:import matplotlib.pylot as plt 绘图函数:plt.plot() 显示函数:plt.show() ...

  2. 转载 互斥体与互锁 <第五篇>

    互斥体实现了“互相排斥”(mutual exclusion)同步的简单形式(所以名为互斥体(mutex)).互斥体禁止多个线程同时进入受保护的代码“临界区”.因此,在任意时刻,只有一个线程被允许进入这 ...

  3. 扫盲记-第六篇--Normalization

    深度学习模型中的Normalization 数据经过归一化和标准化后可以加快梯度下降的求解速度,这就是Batch Normalization等技术非常流行的原因,Batch Normalization ...

  4. ingress-nginx 添加https证书

    1.配了一个证书,发现报错: kubectl logs  ingress-nginx-controller-96fnv   -n ingress-nginx unexpected error vali ...

  5. 推荐几本对于Python初学者比较好的书籍(内含PDF)

    我们提供一个初学者最好的Python书籍列表.Python是一个初级程序员可以学习编程的最友好语言之一.为了帮助您开始使用Python编程,我们分享此列表.泡一杯茶,选一本书阅读,开始使用Python ...

  6. Luogu3067 平衡的奶牛群 Meet in the middle

    题意:给出$N$个范围在$[1,10^8]$内的整数,问有多少种取数方案使得取出来的数能够分成两个和相等的集合.$N \leq 20$ 发现爆搜是$O(3^N)$的,所以考虑双向搜索. 先把前$3^\ ...

  7. RDLC报表显示存储于数据库的图片

    图片以二进制存储于数据库表中.在显示RDLC报表时,把图片呈现出来. 好吧. 把存储过程写好: CREATE PROCEDURE [dbo].[usp_File_Select] AS SELECT [ ...

  8. Dell Technology Summit(2018.10.17)

    时间:2018.10.17地点:北京国家会议中心

  9. 机器学习 第五篇:分类(kNN)

    K最近邻(kNN,k-NearestNeighbor)算法是一种监督式的分类方法,但是,它并不存在单独的训练过程,在分类方法中属于惰性学习法,也就是说,当给定一个训练数据集时,惰性学习法简单地存储或稍 ...

  10. Zabbix监控系统部署:源码安装

    1. 概述1.1 基础环境2. 部署过程2.1 创建用户组2.2 下载源码解压编译安装2.2.1 下载源码解压2.2.2 YUM安装依赖环境2.2.3 编译安装最新版curl2.2.4 更新GNU构建 ...