1104
备注:
|
1805
|
删除的内容标记成这样。 | 加入的内容标记成这样。 |
行号 1: | 行号 1: |
## page was renamed from 程序设计练习14——zju2104——Let the Balloon Rise | |
行号 2: | 行号 3: |
http://acm.zju.edu.cn/show_problem.php?pid=2104 |
|
行号 38: | 行号 41: |
http://acm.zju.edu.cn/show_problem.php?pid=2104 | |
行号 40: | 行号 43: |
{{{#!cplusplus #include <iostream> #include <string> #include <map> #include <algorithm> using namespace std; bool less_map(map<string, int>::value_type v1, map<string, int>::value_type v2)\ { return v1.second < v2.second; } int main() { while(1) { int n; cin >> n; if(n==0) break; map<string, int> colors; for(int i = 0; i < n; i++) { string color; cin >> color; colors[color]++; //automatic insert (color,0) pair when key color doesn't exist } cout << max_element(colors.begin(), colors.end(), less_map)->first << endl; } } }}} |
Let the Balloon Rise
http://acm.zju.edu.cn/show_problem.php?pid=2104
Time limit: 1 Seconds
Memory limit: 32768K
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.
1. 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.
2. 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.