zoukankan      html  css  js  c++  java
  • Let the Balloon Rise (STL)

    Contest time again! How excited it is to see balloons floating around. But to tell you a secret, the judges' favorite time is guessing the most popular problem. When the contest is over, they will count the balloons of each color and find the result.

    This year, they decide to leave this lovely job to you.


    Input

    Input contains multiple test cases. Each test case starts with a number N (0 < N < 1000) -- the total number of balloons distributed. The next N lines contain one color each. The color of a balloon is a string of up to 15 lower-case letters.

    A test case with N = 0 terminates the input and this test case is not to be processed.


    <b< dd="">

    Output

    For each case, print the color of balloon for the most popular problem on a single line. It is guaranteed that there is a unique solution for each test case.


    <b< dd="">

    Sample Input

    5
    green
    red
    blue
    red
    red
    3
    pink
    orange
    pink
    0


    <b< dd="">

    Sample Output

    red
    pink

    #include <bits/stdc++.h>
    using namespace std;
    const int maxn = 1e6+10;
    const int INF =0x3f3f3f3f;
    //#define LOCAL
    #define FOR(i,start,end) for(int i=start;i<=end;i++)
    #define FOR_(i,end,start) for(int i=end;i>=start;i--)
    #define TLE ios::sync_with_stdio(false)
    #define cc cout<<
    typedef long long ll;
    typedef struct node
    {
        char ch;
        struct node *l,*r;
    } node , *link;
    node no[60];
    string s1,s2;
    int j=0;
    void  creat(int st , int en)
    {
        int i;
        if(st>en) return ;
        for(i=0;i<en;i++)
            if(s2[i]==s1[j])
                break;
        j++;
        creat(st,i-1);
        creat (i+1,en);
        cout<<s2[i];
    }
    
    int main()
    {
        while(cin>>s1>>s2)
        {
            j=0;
            creat( 0,s2.length()-1 );
            cc  endl;
        }
    }
    所遇皆星河
  • 相关阅读:
    开源mvcpager分页控件分页实例
    「YNOI2016」自己的发明
    「SNOI2017」一个简单的询问
    势能分析(splay分析)
    「Ynoi2018」未来日记
    「JOISC 2016 Day 1」棋盘游戏
    「ZJOI2014」璀灿光华
    「ZJOI2019」线段树
    「科技」区间众数
    「ZJOI2017」树状数组
  • 原文地址:https://www.cnblogs.com/Shallow-dream/p/11632224.html
Copyright © 2011-2022 走看看