답안 #300581

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
300581 2020-09-17T09:55:14 Z fishy15 Languages (IOI10_languages) C++17
0 / 100
2938 ms 20984 KB
#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 "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 val {
    int tot;
    int freq[MAXN];
    val() {
        memset(freq, 0, sizeof freq);
    }
    double qry(const map<int, int> &f) {
        if (tot == 0) return INFLL;
        double ans = 0;
        for (auto p : f) {
            double actual_f = 1.0 * freq[p.first] / tot;
            double given_f = 1.0 * p.second / LEN;
            ans += log(fabs(actual_f - given_f) + eps);
        }
        return ans;
    }
    void upd(int arr[LEN]) {
        tot += LEN;
        for (int i = 0; i < LEN; i++) {
            freq[arr[i]]++;
        }
    }
};

val langs[LANGS];

void excerpt(int arr[LEN]) {
    double min_val = INFLL;
    int ans = 0;
    map<int, int> cnt;
    for (int i = 0; i < LEN; i++) {
        cnt[i]++;
    }
    for (int i = 0; i < LANGS; i++) {
        double val = langs[i].qry(cnt);
        cout << val << '\n';
        if (val < min_val) {
            min_val = val;
            ans = i;
        }
    }

    int correct = language(ans);
    langs[correct].upd(arr);
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2938 ms 20760 KB Hacked.
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2929 ms 20984 KB Hacked.