Submission #168913


Source Code Expand

Copy
#include <iostream>
#include <string>
#include <map>

using namespace std;

typedef map<string, int> M;

int main() {
    int n;
    int most = 0;
    string s;
    string candidate;
    M count;
    cin >> n;
    for (int i=0; i<n; i++) {
        cin >> s;
        if (count.find(s) == count.end()) {
            count[s] = 0;
        }
        count[s]++;
    }
    for (M::iterator iter=count.begin(); iter!=count.end(); iter++) {
        if (iter->second > most) {
            most = iter->second;
            candidate = iter->first;
        }
    }
    cout << candidate << endl;

    return 0;
}

Submission Info

Submission Time
Task B - 投票
User saltcandy123
Language C++ (G++ 4.6.4)
Score 100
Code Size 635 Byte
Status
Exec Time 22 ms
Memory 932 KB

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 sample_01.txt, sample_02.txt, sample_03.txt
All 100 / 100 sample_01.txt, sample_02.txt, sample_03.txt, case_01.txt, case_02.txt, case_03.txt, case_04.txt, case_05.txt, case_06.txt, case_07.txt, case_08.txt, case_09.txt, case_10.txt, case_11.txt, case_12.txt, case_13.txt, case_14.txt, case_15.txt
Case Name Status Exec Time Memory
case_01.txt 21 ms 800 KB
case_02.txt 21 ms 804 KB
case_03.txt 21 ms 800 KB
case_04.txt 21 ms 676 KB
case_05.txt 21 ms 676 KB
case_06.txt 21 ms 924 KB
case_07.txt 21 ms 928 KB
case_08.txt 20 ms 800 KB
case_09.txt 21 ms 924 KB
case_10.txt 21 ms 928 KB
case_11.txt 20 ms 928 KB
case_12.txt 20 ms 804 KB
case_13.txt 21 ms 796 KB
case_14.txt 20 ms 932 KB
case_15.txt 22 ms 924 KB
sample_01.txt 22 ms 788 KB
sample_02.txt 22 ms 928 KB
sample_03.txt 21 ms 920 KB