Sicily 1299 Academy Awards (map + vector container)

Source: Internet
Author: User

Link: http://soj.me/show_problem.php? Pid = 1299 & cid =

Description

Selected from 3,850 teams from 1,329 universities in 68 countries competing at 106 sites and preliminary contests worldwide, sixty-eight teams competed for bragging rights and prizes at The 27th Annual ACM International Collegiate Programming Contest World Finals sort sored by IBM on March 25,200 3, in Hollywood, California. the 2003 World Champion is Warsaw University. and Zhongshan University won the 8th place. during those days, another world famous event was held in the same place. it was the 75th Annual Academy Awards. it's also known as Oscar.

We always say that the Best Picture is the most important award of all the awards. before the Oscar Night, we can't tell which film will win Best Picture. fortunately, we can dope it out from the Nominee List of all the awards other than the Best Picture. I suggest that you shoshould follow my 3 rules here.

L All the films in the list have chances to win the Best Picture

L The film which will win the Best Picture is the film which has been nominated the most times in the list

L If there are more than one film which have been nominated the most times in the list, we will choose the first one which appears in the list

Let's see such a List below.

VISUAL EFFECTS

The lord of the rings: THE TWO TOWERS

SPIDER-MAN

STAR WARS EPISODE II ATTACK OF THE CLONES

SOUND EDITING

The lord of the rings: THE TWO TOWERS

MINORITY REPORT

ROAD TO PERDITION

From the list, we can find thatThe lord of the rings: THE TWO TOWERSHas been nominated twice. And each of the other films has been nominated only once. So we can sayThe lord of the rings: THE TWO TOWERSWill win the Best Picture.

Your task is to write a program to figure out the anticipatory winner from the list.

Input

The input file will consist of several lists. the first line of each list contains only one integer n (1 ≤ n ≤ 100), representing the number of awards in the list. then you get n blocks. each block indicated the nominees of a distinct award. the first line of each block is the name of the award which is not longer than 80. the second line is mi (1 ≤ mi ≤ 10, 1 ≤ I ≤ n)-the number of nominated films. in the following lines are mi film names, one per line. for make the question simple, you can assume that there isn't any space in the film names.

The input is terminated by a line with one zero.

Output

For each list, you are supposed to figure out the winner of Best Picture in a single line.

Sample Input CZ records? Http://www.bkjia.com/kf/ware/vc/ "target =" _ blank "class =" keylink "> placement =" brush: java; "> 2visual_javasts3the_lord_of_the_rings: _ THE_TWO_TOWERSSPIDER-MANSTAR_WARS_EPISODE_II_ATTACK_OF_THE_CLONESSOUND_EDITING3THE_LORD_OF_THE_RINGS: _ THE_TWO_TOWERSMINORITY_REPORTROAD_TO_PERDITION0Sample Output
THE_LORD_OF_THE_RINGS:_THE_TWO_TOWERS

Analysis: the name of the most frequently-occurring movie is counted, and the data range is not big. The time complexity is O (n * m)

# Include
 
  
# Include
  
   
# Include
   
    
# Include
    
     
# Include
     # Include
      
        # Include
       
         # Include
        
          # Define RST (N) memset (N, 0, sizeof (N) using namespace std; vector
         
           V; map
          
            Mp; map
           
             : Iterator it; string award, file, flag; // award name, movie name, most frequently-used movie name; int n, m; // number of awards, total number of movie names that have won each award; int main () {while (cin> n & n) {mp. clear (), v. clear (); // initialize the container; while (n --) {cin> award; cin> m; for (int I = 0; I
            
              > File; v. push_back (file); it = mp. find (file); // locate the location where the movie appears in the map container; if (it! = Mp. end () mp [file] ++; // locate, increase the frequency by 1; else mp [file] = 1; // not found, and the frequency is 1; and added to the map container;} int max = 0; for (int I = 0; I
             
               Second> max) {max = it-> second; flag = it-> first ;}}cout <flag <endl ;}return 0 ;}
             
            
           
          
         
        
       
      
    
   
  
 

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.