#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("O3")
#pragma GCC target("sse4,avx2,fma,avx")
#define FOR(i, x, y) for (int i = x; i < y; i++)
typedef long long ll;
using namespace std;
#include "grader.h"
#include "lang.h"
const int SZ = 100, LANGS = 56;
unordered_map<ll, float> prev_letters[LANGS];
int prev_cnt[LANGS];
void excerpt(int *E) {
unordered_map<ll, float> curr_letters;
FOR(i, 2, SZ) {
curr_letters[E[i]]++;
curr_letters[(E[i - 1] << 15) + E[i]]++;
curr_letters[(E[i - 2] << 31) + (E[i - 1] << 15) + E[i]]++;
}
int best_lang = 0;
float best_diff = 1e18;
FOR(i, 0, LANGS) if (prev_cnt[i]) {
float curr_diff = 0;
for (pair<ll, float> j : curr_letters) {
curr_diff += __builtin_popcount(j.first) * abs(j.second - (prev_letters[i][j.first] / prev_cnt[i]));
}
if (curr_diff <= best_diff) {
best_diff = curr_diff;
best_lang = i;
}
}
int correct = language(best_lang);
prev_cnt[correct]++;
for (pair<ll, float> i : curr_letters) {
prev_letters[correct][i.first] += i.second;
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9519 ms |
158744 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
8919 ms |
158784 KB |
Output is partially correct - 85.82% |