Submission #7148101


Source Code Expand

#include <bits/stdc++.h>

using namespace std;

int main() {
  int n; cin >> n;
  map<string, int> v;
  for (int i = 0; i < n; i++) {
    string str; cin >> str;
    v[str]++;
  }

  string ans;
  int ans_n = 0;

  for(const auto& [key, value] : v) {
    if(value > ans_n) {
      ans_n = value;
      ans = key;
    }
  }

  cout << ans << endl;
}

Submission Info

Submission Time
Task B - 投票
User hossissippi
Language C++14 (GCC 5.4.1)
Score 0
Code Size 373 Byte
Status CE

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:16:19: error: expected unqualified-id before ‘[’ token
   for(const auto& [key, value] : v) {
                   ^
./Main.cpp:16:19: error: expected ‘;’ before ‘[’ token
./Main.cpp:16:20: error: ‘key’ was not declared in this scope
   for(const auto& [key, value] : v) {
                    ^
./Main.cpp:16:25: error: ‘value’ was not declared in this scope
   for(const auto& [key, value] : v) {
                         ^
./Main.cpp: In lambda function:
./Main.cpp:16:32: error: expected ‘{’ before ‘:’ token
   for(const auto& [key, value] : v) {
                                ^
./Main.cpp: In function ‘int main()’:
./Main.cpp:16:32: error: expected ‘;’ before ‘:’ token
./Main.cpp:16:32: error: expected primary-expression before ‘:’ token
./Main.cpp:16:32: error: expected ‘)’ before ‘:’ token
./Main.cpp:16:32: error: expected primary-expression before ‘:’ token