답안 #390768

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
390768 2021-04-16T21:26:04 Z Sorting Languages (IOI10_languages) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#include "grader.h"
#include "lang.h"

using namespace std;

typedef double ld;
const int N = 100;
const int LANG = 64;
const int MAX_CHAR = 65536;

int *e;
int cnt[LANG];
map<pair<int, int>, int> pair_cnt[LANG];
int char_cnt[LANG][MAX_CHAR];

void excerpt(int *_e){
    e = _e;

    map<int, int> mp;
    for(int i = 0; i < N; ++i)
        mp[e[i]]++;
    map<pair<int, int>> mp2;
    for(int i = 0; i < N - 1; ++i)
        mp2[{e[i], e[i + 1]}]++;

    ld best_sim = DBL_MAX;
    int best_guess = 0;
    for(int guess = 0; guess < 56; ++guess){
        if(!cnt[guess]) continue;

        ld curr_sim = 0;
        for(auto [p, cnt_p]: mp2)
            curr_sim += abs((ld)pair_cnt[guess][p] / (ld)cnt[guess] - (ld)cnt_p);
        for(auto [x, cnt_x]: mp)
            curr_sim += abs((ld)char_cnt[guess][x] / (ld)cnt[guess] - (ld)cnt_x);
        if(curr_sim < best_sim){
            best_sim = curr_sim;
            best_guess = guess;
        }
    }

    int ans = language(best_guess);
    ++cnt[ans];
     for(int i = 0; i < N - 1; ++i)
         pair_cnt[ans][{e[i], e[i + 1]}]++;
    for(int i = 0; i < N; ++i)
        char_cnt[ans][e[i]]++;
}

Compilation message

lang.cpp: In function 'void excerpt(int*)':
lang.cpp:23:22: error: wrong number of template arguments (1, should be at least 2)
   23 |     map<pair<int, int>> mp2;
      |                      ^~
In file included from /usr/include/c++/9/map:61,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:81,
                 from lang.cpp:1:
/usr/include/c++/9/bits/stl_map.h:100:11: note: provided for 'template<class _Key, class _Tp, class _Compare, class _Alloc> class std::map'
  100 |     class map
      |           ^~~
lang.cpp:25:29: error: invalid types 'int[<brace-enclosed initializer list>]' for array subscript
   25 |         mp2[{e[i], e[i + 1]}]++;
      |                             ^
lang.cpp:33:30: error: 'begin' was not declared in this scope
   33 |         for(auto [p, cnt_p]: mp2)
      |                              ^~~
lang.cpp:33:30: note: suggested alternatives:
In file included from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:95,
                 from lang.cpp:1:
/usr/include/c++/9/valarray:1224:5: note:   'std::begin'
 1224 |     begin(const valarray<_Tp>& __va)
      |     ^~~~~
In file included from /usr/include/c++/9/filesystem:38,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:129,
                 from lang.cpp:1:
/usr/include/c++/9/bits/fs_dir.h:516:3: note:   'std::filesystem::__cxx11::begin'
  516 |   begin(recursive_directory_iterator __iter) noexcept
      |   ^~~~~
lang.cpp:33:30: error: 'end' was not declared in this scope
   33 |         for(auto [p, cnt_p]: mp2)
      |                              ^~~
lang.cpp:33:30: note: suggested alternatives:
In file included from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:95,
                 from lang.cpp:1:
/usr/include/c++/9/valarray:1244:5: note:   'std::end'
 1244 |     end(const valarray<_Tp>& __va)
      |     ^~~
In file included from /usr/include/c++/9/filesystem:38,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:129,
                 from lang.cpp:1:
/usr/include/c++/9/bits/fs_dir.h:520:3: note:   'std::filesystem::__cxx11::end'
  520 |   end(recursive_directory_iterator) noexcept
      |   ^~~