B. Power video machines


We require a person is video machines if and only if every word repetition before a person to say what he said.
We require a person is video machines if and only if every word repetition before a person to say what he said.
We require a person is video machines if and only if every word repetition before a person to say what he said.
The provisions of a repetition of proficiency as how much repetition number. Now to give you some chat history, you find out who the repeater.
The provisions of a repetition of proficiency as how much repetition number. Now to give you some chat history, you find out who the repeater.
The provisions of a repetition of proficiency as how much repetition number. Now to give you some chat history, you find out who the repeater.

Input Format

Input T group, ( . 1 T 10 )
a first input line of each a positive integer N , denotes the length of the chat ( . 1 N 10000 ) .
Next N lines of two strings, the first string of a name, a character of the record.
To ensure that all the string length does not exceed 50 , to ensure that all the strings contain only lowercase letters.

Output Format

If there is no repetition, the output "Unbelievable!" (Without the quotes)
otherwise in accordance with proficiency descending output all video machines, if the same proficiency, from small to large output in lexicographic order.

Sample

Input
1
4
codancer iamsovegetable
dicer iamsovegetable
todest iamsovegetable
capryang iamsovegetable
Output
capryang
dicer
todest

prompt

The above data to ensure bigwigs are saying is nonsense.

Just saw this when the subject can feel, see, and then you can write buckle nearly two hours did not write it, then listen to what others say when finds himself at fault (TM), and then wrote a N multilateral ,, and finally the AC

Ideas: 1 first person to speak must not Repeater

     2 If a person is repetition, so he could speak, a person must be repeated before then;

     3 If a person begins to repeat the previous one, it looked a bit like a repeater. But then did not repeat in front of a person, then he is not a repeater.

#include <the iostream> 
#include <Map> 
#include <algorithm> 
#include < String > the using namespace STD;
 const int N = 10010 ;
 struct STU 
{ String A; // save the name of the repeater int B; // save repetition machine proficiency 
 //     BOOL Friend operator <(const & STU X, Y & const STU) {
 //         IF (Yb = XB!) return XB> Yb;
 //         return XA <Ya; // built heavy duty, direct ordering defined rules may also be written on the outside of a cmp 
     // } } ARR [N];
 BOOL

  
    
    
CMP (STU X, Y STU) {
         IF (! XB = Yb) return XB> Yb;
         return XA < Ya; 
    } 
 
 
 
int main () 
{ 
    int T; 
    CIN >> T;
     the while (T-- ) { 
        Map < String , int > mp1, mp2; // determines whether mp1 repetition flag is not used for human video machines, mp2 video machines for marking proficiency 
        Map < String , int > :: Iterator IT;
         int n-; 
        CIN >> n-;
         String C [N], D [N];
        for ( int I = 0 ; I <n-; I ++ ) { 
            CIN >> C [I] >> D [I];
             IF (I == 0 ) { 
                MP1 [C [I]] = . 1 ; // first occurrences of certain not repeater 
            }
             the else MP1 [C [I]] = 0 ; // repetition flag is 0; 
        } 
        int POS = 0 ;
         for ( int I = . 1 ; I <n-; I ++ ) {
             IF (D [I] == D [I- . 1 ] && MP1 [C [I]]! = . 1  ) {// If the person i repeated before a person, and then he is not a repeater
                MP2 [C [I]] ++ ; 
            } 
            the else { 
                MP1 [C [I]] = . 1 ; // not a repetition flag is 0; 
            } 
        } 
      // convert proficiency with repeater names to the array structure  
for (= mp1.begin (); mp1.end IT = ();! IT ++ ) { IF (IT-> SECOND =! . 1 ) { ARR [POS] II.A = IT-> First; ARR [POS] .B MP2 = [IT-> First]; POS ++ ; } } IF (POS == 0 ) { COUT <<"! Unbelievable " << endl; } the else { // Sort (ARR, ARR + POS); // if the built-in function, then use this sort Sort (ARR, ARR + POS, cmp); // External cmp with this sort for ( int I = 0 ; I <POS; I ++ ) { COUT << ARR [I] II.A << endl; } } mp1.clear (); mp2.clear (); } return 0 ; }

 

 

 

 

Guess you like

Origin www.cnblogs.com/Accepting/p/11223808.html