HDU 5702 Solving Order
http://acm.hdu.edu.cn/showproblem.php?pid=5702
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.
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.
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.
green 2
yellow 3
white 1
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的更多相关文章
- HDU 5702 Solving Order (水题,排序)
题意:给定几种不同的颜色和它的权值,按它的权值排序. 析:排序. 代码如下: #include <cstdio> #include <string> #include < ...
- hdu 3999 The order of a Tree (二叉搜索树)
/****************************************************************** 题目: The order of a Tree(hdu 3999 ...
- <hdu - 3999> The order of a Tree 水题 之 二叉搜索的数的先序输出
这里是杭电hdu上的链接:http://acm.hdu.edu.cn/showproblem.php?pid=3999 Problem Description: As we know,the sha ...
- 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 ...
- 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 ...
- HDU 3999 The order of a Tree 二叉搜索树 BST
建一个二叉搜索树,然后前序输出. 用链表建的,发现很久没做都快忘了... #include <cstdio> #include <cstdlib> struct Node{ i ...
- 2019的hdu暑假作业(欢迎纠错)
1219 遍历计数. #include<bits/stdc++.h> #define QAQ 0 using namespace std; ]; ]; int main(){ )){ me ...
- 2016女生专场 ABCDEF题解 其他待补...
GHIJ待补... A.HUD5702:Solving Order Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/3276 ...
- STL专题
一.algorithm 1.sort 问题1:给你n个整数,请按从大到小的顺序输出其中前m大的数. Input:每组测试数据有两行,第一行有两个数n,m(0<n,m<1000000),第二 ...
随机推荐
- attachBaseContext
at android.content.ContextWrapper.attachBaseContext(ContextWrapper.java:66) at android.view.ContextT ...
- cenos下安装MySQL最新版(5.7.18)记录。附卸载老版本过程
首先说明:老版本数据库没有数据,所以无数据备份过程.如果你在升级数据库过程里,需要备份数据,请另外自行处理. 1.下载最新版MySQL.解压待用 wget https://dev.mysql.com/ ...
- PHP开发api接口安全验证方法一
前台想要调用接口,需要使用几个参数生成签名.时间戳:当前时间随机数:随机生成的随机数 签名:特定方法生成的sign签名 算法规则在前后台交互中,算法规则是非常重要的,前后台都要通过算法规则计算出签名, ...
- 20145203盖泽双 《网络对抗技术》实践九:Web安全基础实践
20145203盖泽双 <网络对抗技术>实践九:Web安全基础实践 1.实践目标 1.理解常用网络攻击技术的基本原理. 2.Webgoat下进行相关实验:SQL注入攻击.XSS攻击.CSR ...
- (转)解决k8s集群提示docker login问题(同样适用于Rancher)
文章转自 https://blog.liv1020.com/ 参考文档:https://kubernetes.io/docs/concepts/containers/images/#configuri ...
- 20175105 2018-2019-2 《Java程序设计》第八周学习总结
20175105 2018-2019-2 <Java程序设计>第八周学习总结 教材学习内容总结 第十五章主要内容有:泛型.链表.堆栈.散列映射.树集以及树映射. 泛型:可以使用class名 ...
- CommonJS, AMD, CMD是什么及区别--简单易懂有实例
CommonJS, AMD, CMD都是JS模块化的规范. CommonJS是服务器端js模块化的规范,NodeJS是这种规范的实现. AMD(异步模块定义)和CMD(通用模块定义)都是浏览器端js模 ...
- Zabbix 3.4.2 install && Configuration
原理: 1)zabbix server:负责接收agent发送的报告信息的核心组件,所有配置.统计数据及操作数据都由它组织进行: 2)database storage:专用于存储所有配置信息,以及由z ...
- PAM unable to dlopen(/lib/security/pam_limits.so): /lib/security/pam_limits.so: wrong ELF class: ELFCLASS32
systemctl status sshd● sshd.service - OpenSSH server daemon Loaded: loaded (/usr/lib/systemd/system/ ...
- SkylineGlobe的PopupMessage里面嵌入的网页如何与主页面交互通讯
1.主页面调用PopupMessage,如果需要传值,就是普通的页面间的传值就可以实现了. a.html页面调用PopupMessage创建方法,url传入b.html?x=111&y=22; ...