#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 long double sq(long double X) { return X * X; }
unordered_map<ll, long double> prev_quadrams[langs];
int prev_cnt[langs];
void excerpt(int *E) {
unordered_map<ll, long double> curr_quadrams;
FOR(i, 3, sz) {
curr_quadrams[(E[i - 3] << 48) + (E[i - 2] << 32) + (E[i - 1] << 16) + E[i]]++;
}
int best_lang = 0;
long double best_diff = 1e18;
FOR(i, 0, langs) if (prev_cnt[i]) {
long double curr_diff = 0;
for (pair<ll, long double> j : curr_quadrams) {
curr_diff += sq(j.second - (prev_quadrams[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, long double> i : curr_quadrams) {
prev_quadrams[correct][i.first] += i.second;
}
}
Compilation message
lang.cpp: In function 'void excerpt(int*)':
lang.cpp:20:34: warning: left shift count >= width of type [-Wshift-count-overflow]
curr_quadrams[(E[i - 3] << 48) + (E[i - 2] << 32) + (E[i - 1] << 16) + E[i]]++;
^~
lang.cpp:20:53: warning: left shift count >= width of type [-Wshift-count-overflow]
curr_quadrams[(E[i - 3] << 48) + (E[i - 2] << 32) + (E[i - 1] << 16) + E[i]]++;
^~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
10088 ms |
136136 KB |
Time limit exceeded |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
10028 ms |
140636 KB |
Time limit exceeded |