Best code #54 div 2 A water

Source: Internet
Author: User

A Problem of sortingaccepts:443submissions:1696Time limit:2000/1000 MS (java/others)Memory limit:65536/65536 K (java/others)Problem Description

There is many people ' s name and birth in a list. Your task is-to-print the name from young-to-old. (There is no pair of both have the the same age.)

Input

First line contains a single integer t≤100t \leqT≤100 which denotes the number of test CA Ses.

For each test case, there was an positive integern (1≤n≤100) n (1 \leq n \leq) n (1≤ n≤100< Span class= "Mclose") which denotes the number of People,and next nn< Span class= "katex-html" >n Lines,each Line have a name and a birth ' s year ( 1900-2015) separated by one space.

The length of name is positive and not larger than 100100100.Notice name only contain letter (s), digit ( s) and space (s).

Output

For each case, output nnn lines.

Sample Input
21FancyCoder 19962FancyCoder 1996xyz111 1997
#include <iostream> #include <cstring> #include <cstdio> #include <algorithm> #include <map    > #include <queue>using namespace std;struct node{Char name[105];    int birthday;    friend bool Operator < (node A,node b) {return a.birthday<b.birthday;    }};node Q1,q2;priority_queue<node>q;int Main () {int t,n;            while (scanf ("%d", &t)!=eof) {for (int i=1; i<=t; i++) {scanf ("%d", &n);            GetChar ();                for (int j=1; j<=n; J + +) {char str[105],strr[105];                int birth;                memset (strr,0,sizeof (STRR));                memset (str,0,sizeof (str));                Cin.getline (str,105);                int Len=strlen (str);                birth=str[len-1]-' 0 ' + (str[len-2]-' 0 ') *10+ (str[len-3]-' 0 ') *100+ (str[len-4]-' 0 ') *1000;                for (int k=0; k<=len-1-5; k++) {strr[k]=str[k];           }     strcpy (Q1.NAME,STRR);                Q1.birthday=birth;            Q.push (Q1);                } while (!q.empty ()) {q2=q.top ();                Q.pop ();            cout<<q2.name<<endl; }}} return 0;}

Best code #54 div 2 A water

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.