Submission #1279031

#TimeUsernameProblemLanguageResultExecution timeMemory
1279031user149Languages (IOI10_languages)C++20
0 / 100
10084 ms8308 KiB
#include <bits/stdc++.h>
#include "grader.h"
#include "lang.h"
using namespace std;

using pdi = pair<double, int>;

unordered_map<int, int> freq[60];
int num[60];

double loss(int l,unordered_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) {
    unordered_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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...