#include <bits/stdc++.h>
#include "grader.h"
#include "lang.h"
using namespace std;
using pdi = pair<double, int>;
map<int, int> freq[60];
int num[60];
double loss(int l, map<int, int> v) {
double ans = 0;
for (auto [a, b] : v) {
ans += pow(((num[l] == 0 ? 0 : (double)freq[l][a]/num[l])) - (b/100.0), 2);
}
// for (auto [a, b] : freq[l]) {
// if (v.find(a) == v.end()) ans += pow((num[l] == 0 ? 0 : (double)b/num[l]), 2);
// }
return ans;
}
void excerpt(int *E) {
map<int, int> v;
for (int i = 0; i <= 99; i++) {
v[E[i]]++;
}
pdi best = {1e9, -1};
for (int l = 0; l <= 55; l++) {
best = min(best, (pdi){loss(l, v), l});
}
int ans = language(best.second);
num[ans] += 100;
for (auto [a, b] : v) {
freq[ans][a] += b;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |