zoukankan      html  css  js  c++  java
  • "巴卡斯杯" 中国大学生程序设计竞赛

    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 TT which indicates the case number. 
    And as for each case, the first line is an integer nn, which is the number of problems. 
    Then there are nn lines followed, with a string and an integer in each line, in the ii-th line, the string means the color of ballon for the ii-th problem, and the integer means the ballon numbers. 

    It is guaranteed that: 
    TT is about 100. 
    1≤n≤101≤n≤10. 
    1≤1≤ string length ≤10≤10. 
    1≤1≤ bolloon numbers ≤83≤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 nn 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<iostream>
    #include<cstring>
    #include<algorithm>
    using namespace std;
    
    struct AC
    {
    	char color[100];
    	int num;
    }a[1000];
    
    bool cmp(AC a,AC b)
    {
    	return a.num>b.num;
    }
    
    int main()
    {
    	int n,m,j,k,i,T;
    	scanf("%d",&T);
    	while (T--)
    	{
    		scanf("%d",&n);
    		getchar();
    		for (i=0;i<n;i++)
    		{
    			scanf("%s %d",a[i].color,&a[i].num);
    		}
    		sort(a,a+n,cmp);
    		for (i=0;i<n-1;i++)
    		{
    			printf("%s ",a[i].color);
    		}
    		printf("%s
    ",a[n-1].color);
    	}
    	
    	
    	return 0;
    }
    
    
    
    
    
    
    
  • 相关阅读:
    Rails 5 Test Prescriptions 第6章Adding Data to Tests
    Rails 5 Test Prescriptions 第4章 什么制造了伟大的测试
    Rails 5 Test Prescriptions 第3章Test-Driven Rails
    VisualBasic6.0程序设计教程(第4版)(普通高等教育“十一五”国家级规划教材)
    Word Excel PPT 2016三合一办公应用实战从入门到精通 超值版
    R语言数据挖掘方法及应用
    Word--Excel 2016商务办公实战从新手到高手
    妙哉!Excel数据分析与处理就该这么学
    Visual C++串口通信开发入门与编程实践
    Hello C 语言
  • 原文地址:https://www.cnblogs.com/Romantic-Chopin/p/12451222.html
Copyright © 2011-2022 走看看