Submission #10141650


Source Code Expand

Copy
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
using namespace std;

int main() {
  ios::ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
  int n;
  cin >> n;
  map<string, int> mp;
  int mx = 0;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    mx = max(mx, ++mp[s]);
  }
  vector<string> ans;
  for (auto&& [key, val] : mp) {
    if (val == mx) {
      ans.push_back(key);
    }
  }
  sort(ans.begin(), ans.end());
  for (auto&& e : ans) {
    cout << e << '\n';
  }
}

Submission Info

Submission Time
Task C - Poll
User Ununus
Language C++14 (GCC 5.4.1)
Score 0
Code Size 579 Byte
Status CE

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:20:15: error: expected unqualified-id before ‘[’ token
   for (auto&& [key, val] : mp) {
               ^
./Main.cpp:20:15: error: expected ‘;’ before ‘[’ token
./Main.cpp:20:16: error: ‘key’ was not declared in this scope
   for (auto&& [key, val] : mp) {
                ^
./Main.cpp:20:21: error: ‘val’ was not declared in this scope
   for (auto&& [key, val] : mp) {
                     ^
./Main.cpp: In lambda function:
./Main.cpp:20:26: error: expected ‘{’ before ‘:’ token
   for (auto&& [key, val] : mp) {
                          ^
./Main.cpp: In function ‘int main()’:
./Main.cpp:20:26: error: expected ‘;’ before ‘:’ token
./Main.cpp:20:26: error: expected primary-expression before ‘:’ token
./Main.cpp:20:26: error: expected ‘)’ before ‘:’ token
./Main.cpp:20:26: error: expected primary-expression before ‘:’ token