| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 476819 | WeissBlume | Languages (IOI10_languages) | C++17 | Compilation error | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include"grader.h"
#include"lang.h"
#include<queue>
#include<array>
#include<algorithm>
#include<unordered_map>
#define ALL(X) begin(X),end(X)
using namespace std;
constexpr uint32_t n = 100;
constexpr uint32_t m = 56;
constexpr uint32_t k = 7;
array<unordered_map<uint64_t, uint32_t>, k> kgram;
array<unordered_map<uint64_t, int64_t>, k> fs_kgram;
array<unordered_map<uint64_t, array<uint64_t, m>>, k> f_kgram;
void build_kgram(uint8_t k, int32_t *e) {
kgram[k].clear();
auto& counter = kgram[k];
for (int i = k-1; i < n; i++) {
__uint128_t h = 0;
for (int j = k-1; j >= 0; j--)
h = h << 16 | e[i-j];
++counter[h % 0X9E3779B97F4A7C15UL];
}
}
void build(int32_t *e) {
for (int k: {2, 3, 4, 6}) build_kgram(k, e);
}
void update(auto lang) {
for (int k = 2; k < ::k; k++) if (not kgram[k].empty()) {
auto const& grams = kgram[k];
auto& freqs = f_kgram[k];
auto& fsums = fs_kgram[k];
for (auto&[gram, count]: grams) {
freqs[gram][lang] += 1;
fsums[gram] += count;
}
}
}
auto guess() {
array<double, m> score {};
for (int k = 2; k < ::k; k++) if (not kgram[k].empty()) {
auto const& grams = kgram[k];
auto const& freqs = f_kgram.at(k);
auto const& fsums = fs_kgram.at(k);
for (auto&[gram, count]: grams) if (freqs.count(gram)) {
auto const& freq = freqs.at(gram);
auto const& sum = fsums.at(gram);
for (int i = 0; i < m; i++)
score[i] += count * (freq[i] / (1. + sum));
}
}
return language(max_element(ALL(score)) - begin(score));
}
void excerpt(int32_t *e) {
build(e);
update(guess());
}
Compilation message (stderr)
lang.cpp:9:11: error: 'uint32_t' does not name a type; did you mean 'u_int32_t'?
9 | constexpr uint32_t n = 100;
| ^~~~~~~~
| u_int32_t
lang.cpp:10:11: error: 'uint32_t' does not name a type; did you mean 'u_int32_t'?
10 | constexpr uint32_t m = 56;
| ^~~~~~~~
| u_int32_t
lang.cpp:11:11: error: 'uint32_t' does not name a type; did you mean 'u_int32_t'?
11 | constexpr uint32_t k = 7;
| ^~~~~~~~
| u_int32_t
lang.cpp:13:21: error: 'uint64_t' was not declared in this scope; did you mean 'u_int64_t'?
13 | array<unordered_map<uint64_t, uint32_t>, k> kgram;
| ^~~~~~~~
| u_int64_t
lang.cpp:13:31: error: 'uint32_t' was not declared in this scope; did you mean 'u_int32_t'?
13 | array<unordered_map<uint64_t, uint32_t>, k> kgram;
| ^~~~~~~~
| u_int32_t
lang.cpp:13:39: error: template argument 1 is invalid
13 | array<unordered_map<uint64_t, uint32_t>, k> kgram;
| ^
lang.cpp:13:39: error: template argument 2 is invalid
lang.cpp:13:39: error: template argument 3 is invalid
lang.cpp:13:39: error: template argument 4 is invalid
lang.cpp:13:39: error: template argument 5 is invalid
lang.cpp:13:42: error: 'k' was not declared in this scope
13 | array<unordered_map<uint64_t, uint32_t>, k> kgram;
| ^
lang.cpp:13:43: error: template argument 1 is invalid
13 | array<unordered_map<uint64_t, uint32_t>, k> kgram;
| ^
lang.cpp:13:43: error: template argument 2 is invalid
lang.cpp:14:21: error: 'uint64_t' was not declared in this scope; did you mean 'u_int64_t'?
14 | array<unordered_map<uint64_t, int64_t>, k> fs_kgram;
| ^~~~~~~~
| u_int64_t
lang.cpp:14:38: error: template argument 1 is invalid
14 | array<unordered_map<uint64_t, int64_t>, k> fs_kgram;
| ^
lang.cpp:14:38: error: template argument 3 is invalid
lang.cpp:14:38: error: template argument 4 is invalid
lang.cpp:14:38: error: template argument 5 is invalid
lang.cpp:14:41: error: 'k' was not declared in this scope
14 | array<unordered_map<uint64_t, int64_t>, k> fs_kgram;
| ^
lang.cpp:14:42: error: template argument 1 is invalid
14 | array<unordered_map<uint64_t, int64_t>, k> fs_kgram;
| ^
lang.cpp:14:42: error: template argument 2 is invalid
lang.cpp:15:21: error: 'uint64_t' was not declared in this scope; did you mean 'u_int64_t'?
15 | array<unordered_map<uint64_t, array<uint64_t, m>>, k> f_kgram;
| ^~~~~~~~
| u_int64_t
lang.cpp:15:37: error: 'uint64_t' was not declared in this scope; did you mean 'u_int64_t'?
15 | array<unordered_map<uint64_t, array<uint64_t, m>>, k> f_kgram;
| ^~~~~~~~
| u_int64_t
lang.cpp:15:47: error: 'm' was not declared in this scope
15 | array<unordered_map<uint64_t, array<uint64_t, m>>, k> f_kgram;
| ^
lang.cpp:15:47: error: template argument 1 is invalid
lang.cpp:15:47: error: template argument 2 is invalid
lang.cpp:15:48: error: template argument 1 is invalid
15 | array<unordered_map<uint64_t, array<uint64_t, m>>, k> f_kgram;
| ^~
lang.cpp:15:48: error: template argument 2 is invalid
lang.cpp:15:48: error: template argument 3 is invalid
lang.cpp:15:48: error: template argument 4 is invalid
lang.cpp:15:48: error: template argument 5 is invalid
lang.cpp:15:52: error: 'k' was not declared in this scope
15 | array<unordered_map<uint64_t, array<uint64_t, m>>, k> f_kgram;
| ^
lang.cpp:15:53: error: template argument 1 is invalid
15 | array<unordered_map<uint64_t, array<uint64_t, m>>, k> f_kgram;
| ^
lang.cpp:15:53: error: template argument 2 is invalid
lang.cpp:17:6: error: variable or field 'build_kgram' declared void
17 | void build_kgram(uint8_t k, int32_t *e) {
| ^~~~~~~~~~~
lang.cpp:17:18: error: 'uint8_t' was not declared in this scope; did you mean 'u_int8_t'?
17 | void build_kgram(uint8_t k, int32_t *e) {
| ^~~~~~~
| u_int8_t
lang.cpp:17:37: error: expected primary-expression before '*' token
17 | void build_kgram(uint8_t k, int32_t *e) {
| ^
lang.cpp:17:38: error: 'e' was not declared in this scope
17 | void build_kgram(uint8_t k, int32_t *e) {
| ^
lang.cpp: In function 'void build(int32_t*)':
lang.cpp:29:28: error: 'build_kgram' was not declared in this scope
29 | for (int k: {2, 3, 4, 6}) build_kgram(k, e);
| ^~~~~~~~~~~
lang.cpp: At global scope:
lang.cpp:32:13: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
32 | void update(auto lang) {
| ^~~~
lang.cpp: In function 'void update(auto:1)':
lang.cpp:33:24: error: '::k' has not been declared
33 | for (int k = 2; k < ::k; k++) if (not kgram[k].empty()) {
| ^
lang.cpp:33:45: error: invalid types 'int[int]' for array subscript
33 | for (int k = 2; k < ::k; k++) if (not kgram[k].empty()) {
| ^
lang.cpp:34:28: error: invalid types 'int[int]' for array subscript
34 | auto const& grams = kgram[k];
| ^
lang.cpp:35:24: error: invalid types 'int[int]' for array subscript
35 | auto& freqs = f_kgram[k];
| ^
lang.cpp:36:25: error: invalid types 'int[int]' for array subscript
36 | auto& fsums = fs_kgram[k];
| ^
lang.cpp: In function 'auto guess()':
lang.cpp:45:16: error: 'm' was not declared in this scope
45 | array<double, m> score {};
| ^
lang.cpp:45:17: error: template argument 2 is invalid
45 | array<double, m> score {};
| ^
lang.cpp:46:24: error: '::k' has not been declared
46 | for (int k = 2; k < ::k; k++) if (not kgram[k].empty()) {
| ^
lang.cpp:46:45: error: invalid types 'int[int]' for array subscript
46 | for (int k = 2; k < ::k; k++) if (not kgram[k].empty()) {
| ^
lang.cpp:47:28: error: invalid types 'int[int]' for array subscript
47 | auto const& grams = kgram[k];
| ^
lang.cpp:48:31: error: request for member 'at' in 'f_kgram', which is of non-class type 'int'
48 | auto const& freqs = f_kgram.at(k);
| ^~
lang.cpp:49:32: error: request for member 'at' in 'fs_kgram', which is of non-class type 'int'
49 | auto const& fsums = fs_kgram.at(k);
| ^~
lang.cpp:54:10: error: invalid types 'int[int]' for array subscript
54 | score[i] += count * (freq[i] / (1. + sum));
| ^
lang.cpp:7:23: error: no matching function for call to 'begin(int&)'
7 | #define ALL(X) begin(X),end(X)
| ^
lang.cpp:57:30: note: in expansion of macro 'ALL'
57 | return language(max_element(ALL(score)) - begin(score));
| ^~~
In file included from /usr/include/c++/10/bits/stl_deque.h:63,
from /usr/include/c++/10/deque:67,
from /usr/include/c++/10/queue:60,
from lang.cpp:3:
/usr/include/c++/10/initializer_list:90:5: note: candidate: 'template<class _Tp> constexpr const _Tp* std::begin(std::initializer_list<_Tp>)'
90 | begin(initializer_list<_Tp> __ils) noexcept
| ^~~~~
/usr/include/c++/10/initializer_list:90:5: note: template argument deduction/substitution failed:
lang.cpp:7:23: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
7 | #define ALL(X) begin(X),end(X)
| ^
lang.cpp:57:30: note: in expansion of macro 'ALL'
57 | return language(max_element(ALL(score)) - begin(score));
| ^~~
In file included from /usr/include/c++/10/deque:68,
from /usr/include/c++/10/queue:60,
from lang.cpp:3:
/usr/include/c++/10/bits/range_access.h:51:5: note: candidate: 'template<class _Container> constexpr decltype (__cont.begin()) std::begin(_Container&)'
51 | begin(_Container& __cont) -> decltype(__cont.begin())
| ^~~~~
/usr/include/c++/10/bits/range_access.h:51:5: note: template argument deduction/substitution failed:
/usr/include/c++/10/bits/range_access.h: In substitution of 'template<class _Container> constexpr decltype (__cont.begin()) std::begin(_Container&) [with _Container = int]':
lang.cpp:57:30: required from here
/usr/include/c++/10/bits/range_access.h:51:50: error: request for member 'begin' in '__cont', which is of non-class type 'int'
51 | begin(_Container& __cont) -> decltype(__cont.begin())
| ~~~~~~~^~~~~
/usr/include/c++/10/bits/range_access.h:61:5: note: candidate: 'template<class _Container> constexpr decltype (__cont.begin()) std::begin(const _Container&)'
61 | begin(const _Container& __cont) -> decltype(__cont.begin())
| ^~~~~
/usr/include/c++/10/bits/range_access.h:61:5: note: template argument deduction/substitution failed:
/usr/include/c++/10/bits/range_access.h: In substitution of 'template<class _Container> constexpr decltype (__cont.begin()) std::begin(const _Container&) [with _Container = int]':
lang.cpp:57:30: required from here
/usr/include/c++/10/bits/range_access.h:61:56: error: request for member 'begin' in '__cont', which is of non-class type 'const int'
61 | begin(const _Container& __cont) -> decltype(__cont.begin())
| ~~~~~~~^~~~~
/usr/include/c++/10/bits/range_access.h:90:5: note: candidate: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::begin(_Tp (&)[_Nm])'
90 | begin(_Tp (&__arr)[_Nm])
| ^~~~~
/usr/include/c++/10/bits/range_access.h:90:5: note: template argument deduction/substitution failed:
lang.cpp:7:23: note: mismatched types '_Tp [_Nm]' and 'int'
7 | #define ALL(X) begin(X),end(X)
| ^
lang.cpp:57:30: note: in expansion of macro 'ALL'
57 | return language(max_element(ALL(score)) - begin(score));
| ^~~
In file included from /usr/include/c++/10/deque:68,
from /usr/include/c++/10/queue:60,
from lang.cpp:3:
/usr/include/c++/10/bits/range_access.h:107:31: note: candidate: 'template<class _Tp> _Tp* std::begin(std::valarray<_Tp>&)'
107 | template<typename _Tp> _Tp* begin(valarray<_Tp>&);
| ^~~~~
/usr/include/c++/10/bits/range_access.h:107:31: note: template argument deduction/substitution failed:
lang.cpp:7:23: note: mismatched types 'std::valarray<_Tp>' and 'int'
7 | #define ALL(X) begin(X),end(X)
| ^
lang.cpp:57:30: note: in expansion of macro 'ALL'
57 | return language(max_element(ALL(score)) - begin(score));
| ^~~
In file included from /usr/include/c++/10/deque:68,
from /usr/include/c++/10/queue:60,
from lang.cpp:3:
/usr/include/c++/10/bits/range_access.h:108:37: note: candidate: 'template<class _Tp> const _Tp* std::begin(const std::valarray<_Tp>&)'
108 | template<typename _Tp> const _Tp* begin(const valarray<_Tp>&);
| ^~~~~
/usr/include/c++/10/bits/range_access.h:108:37: note: template argument deduction/substitution failed:
lang.cpp:7:23: note: mismatched types 'const std::valarray<_Tp>' and 'int'
7 | #define ALL(X) begin(X),end(X)
| ^
lang.cpp:57:30: note: in expansion of macro 'ALL'
57 | return language(max_element(ALL(score)) - begin(score));
| ^~~
lang.cpp:7:30: error: no matching function for call to 'end(int&)'
7 | #define ALL(X) begin(X),end(X)
| ^
lang.cpp:57:30: note: in expansion of macro 'ALL'
57 | return language(max_element(ALL(score)) - begin(score));
| ^~~
In file included from /usr/include/c++/10/bits/stl_deque.h:63,
from /usr/include/c++/10/deque:67,
from /usr/include/c++/10/queue:60,
from lang.cpp:3:
/usr/include/c++/10/initializer_list:101:5: note: candidate: 'template<class _Tp> constexpr const _Tp* std::end(std::initializer_list<_Tp>)'
101 | end(initializer_list<_Tp> __ils) noexcept
| ^~~
/usr/include/c++/10/initializer_list:101:5: note: template argument deduction/substitution failed:
lang.cpp:7:30: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
7 | #define ALL(X) begin(X),end(X)
| ^
lang.cpp:57:30: note: in expansion of macro 'ALL'
57 | return language(max_element(ALL(score)) - begin(score));
| ^~~
In file included from /usr/include/c++/10/deque:68,
from /usr/include/c++/10/queue:60,
from lang.cpp:3:
/usr/include/c++/10/bits/range_access.h:71:5: note: candidate: 'template<class _Container> constexpr decltype (__cont.end()) std::end(_Container&)'
71 | end(_Container& __cont) -> decltype(__cont.end())
| ^~~
/usr/include/c++/10/bits/range_access.h:71:5: note: template argument deduction/substitution failed:
/usr/include/c++/10/bits/range_access.h: In substitution of 'template<class _Container> constexpr decltype (__cont.end()) std::end(_Container&) [with _Container = int]':
lang.cpp:57:30: required from here
/usr/include/c++/10/bits/range_access.h:71:48: error: request for member 'end' in '__cont', which is of non-class type 'int'
71 | end(_Container& __cont) -> decltype(__cont.end())
| ~~~~~~~^~~
/usr/include/c++/10/bits/range_access.h:81:5: note: candidate: 'template<class _Container> constexpr decltype (__cont.end()) std::end(const _Container&)'
81 | end(const _Container& __cont) -> decltype(__cont.end())
| ^~~
/usr/include/c++/10/bits/range_access.h:81:5: note: template argument deduction/substitution failed:
/usr/include/c++/10/bits/range_access.h: In substitution of 'template<class _Container> constexpr decltype (__cont.end()) std::end(const _Container&) [with _Container = int]':
lang.cpp:57:30: required from here
/usr/include/c++/10/bits/range_access.h:81:54: error: request for member 'end' in '__cont', which is of non-class type 'const int'
81 | end(const _Container& __cont) -> decltype(__cont.end())
| ~~~~~~~^~~
/usr/include/c++/10/bits/range_access.h:100:5: note: candidate: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::end(_Tp (&)[_Nm])'
100 | end(_Tp (&__arr)[_Nm])
| ^~~
/usr/include/c++/10/bits/range_access.h:100:5: note: template argument deduction/substitution failed:
lang.cpp:7:30: note: mismatched types '_Tp [_Nm]' and 'int'
7 | #define ALL(X) begin(X),end(X)
| ^
lang.cpp:57:30: note: in expansion of macro 'ALL'
57 | return language(max_element(ALL(score)) - begin(score));
| ^~~
In file included from /usr/include/c++/10/deque:68,
from /usr/include/c++/10/queue:60,
from lang.cpp:3:
/usr/include/c++/10/bits/range_access.h:109:31: note: candidate: 'template<class _Tp> _Tp* std::end(std::valarray<_Tp>&)'
109 | template<typename _Tp> _Tp* end(valarray<_Tp>&);
| ^~~
/usr/include/c++/10/bits/range_access.h:109:31: note: template argument deduction/substitution failed:
lang.cpp:7:30: note: mismatched types 'std::valarray<_Tp>' and 'int'
7 | #define ALL(X) begin(X),end(X)
| ^
lang.cpp:57:30: note: in expansion of macro 'ALL'
57 | return language(max_element(ALL(score)) - begin(score));
| ^~~
In file included from /usr/include/c++/10/deque:68,
from /usr/include/c++/10/queue:60,
from lang.cpp:3:
/usr/include/c++/10/bits/range_access.h:110:37: note: candidate: 'template<class _Tp> const _Tp* std::end(const std::valarray<_Tp>&)'
110 | template<typename _Tp> const _Tp* end(const valarray<_Tp>&);
| ^~~
/usr/include/c++/10/bits/range_access.h:110: