#include <bits/stdc++.h>
#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;
const ll chr = 65535;
inline float sq(float X) { return X * X; }
unordered_map<ll, float> prev_trigrams[langs];
int prev_cnt[langs];
void excerpt(int *E) {
unordered_map<ll, float> curr_trigrams;
FOR(i, 2, sz) {
curr_trigrams[chr * (chr * E[i - 2] + E[i - 1]) + 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_trigrams) {
curr_diff += sq(j.second - (prev_trigrams[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_trigrams) {
prev_trigrams[correct][i.first] += i.second;
}
vector<ll> to_erase;
for (pair<ll, float> i : prev_trigrams[correct]) {
if (i.second / prev_cnt[correct] < 1e-3) to_erase.push_back(i.first);
}
for (int i : to_erase) {
prev_trigrams[correct].erase(i);
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
10086 ms |
149904 KB |
Time limit exceeded |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
10089 ms |
145400 KB |
Time limit exceeded |