zoukankan      html  css  js  c++  java
  • HDU 5702 Solving Order

    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.
    1n10.
    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
    ",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;
    }
    

      

  • 相关阅读:
    linux 查看父进程号
    gitlab
    诺基亚C6常识详解
    C#.net书籍列表
    表链接
    Limu:JavaScript的那些书(转载)
    Oracle 多行记录合并/连接/聚合字符串的几种方法
    关于有锁iPhone的常识(转载)
    not in与not exists性能比较
    多表连接查询
  • 原文地址:https://www.cnblogs.com/zlrrrr/p/9232284.html
Copyright © 2011-2022 走看看