zju2104

Let the Balloon Rise

http://acm.zju.edu.cn/show_problem.php?pid=2104

   1 /*Written by czk*/
   2 #include <iostream>
   3 #include <string>
   4 #include <map>
   5 #include <algorithm>
   6 using namespace std;
   7 
   8 bool less_map(map<string, int>::value_type v1, map<string, int>::value_type v2) {
   9     return v1.second < v2.second;
  10 }
  11 
  12 int main() {
  13     while (true) {
  14         int n;
  15         cin >> n;
  16         if (n==0) 
  17             break;
  18         map<string, int> colors;
  19         for (int i = 0; i < n; i++) {
  20             string color;
  21             cin >> color;
  22             colors[color]++;
  23         }
  24         cout << max_element(colors.begin(), colors.end(), less_map)->first << endl;
  25     }

}

zju2104 (2008-06-01 13:23:49由czk编辑)