#include <iostream>
#include <iomanip>
#include <fstream>
#include <vector>
#include <array>
#include <algorithm>
#include <utility>
#include <map>
#include <queue>
#include <set>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <unordered_map>
#include "lang.h"
#include "grader.h"
#define ll long long
#define ld long double
#define eps 1e-8
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3f
// change if necessary
#define MAXN 70000
using namespace std;
// replace this back when submit
const int LEN = 100;
const int LANGS = 56;
struct hash_pair {
size_t operator() (const array<int, 3> &p) const {
return p[0] + (1 << 16) * p[1] + (1LL << 32) * p[2];
}
};
ll conv(const array<int, 3> &arr) {
return arr[0] + (1 << 16) * arr[1] + (1LL << 32) * arr[2];
}
using mm = map<ll, int>;
struct val {
int tot;
mm freq;
val() : tot(0) {}
ld qry(const mm &f) {
if (tot == 0) return INFLL;
ld ans = 0;
for (auto p : f) {
ld actual_f = 1.0 * freq[p.first] / tot;
ld given_f = 1.0 * p.second / LEN;
ll val = fabs(actual_f - given_f) * 100;
ans += val * val;
}
return ans;
}
void upd(int arr[LEN]) {
tot += LEN;
for (int i = 0; i < LEN - 2; i++) {
freq[conv({arr[i], arr[i + 1], arr[i + 2]})]++;
}
}
};
val langs[LANGS];
void excerpt(int arr[LEN]) {
ld min_val = INFLL;
int ans = 0;
mm cnt;
for (int i = 0; i < LEN - 2; i++) {
cnt[conv({arr[i], arr[i + 1], arr[i + 2]})]++;
}
for (int i = 0; i < LANGS; i++) {
ld val = langs[i].qry(cnt);
if (val < min_val) {
min_val = val;
ans = i;
}
}
int correct = language(ans);
langs[correct].upd(arr);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
10079 ms |
234200 KB |
Time limit exceeded |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
10099 ms |
237308 KB |
Time limit exceeded |