Submission #635295

#TimeUsernameProblemLanguageResultExecution timeMemory
635295pedroslreyLanguages (IOI10_languages)C++17
67 / 100
330 ms11916 KiB
#include <bits/stdc++.h>

#include "grader.h"
#include "lang.h"

using namespace std;
using ld = long double;

const int MAXN = 65545;
const int LANG = 66;
const int WAIT = 200;

int alfa[MAXN][LANG];
int tmp[MAXN];
int cnt[LANG];

int iteration;

void excerpt(int *E) {
	cerr << "\r" << iteration;
	++iteration;

	int guess = 1;
	if (iteration > WAIT) {
		set<int> appear;
		for (int *it = E; it < E + 100; ++it) {
			++tmp[*it];
			appear.insert(*it);
		}

		ld best = 1e18;
		for (int i = 0; i < 56; ++i) {
			if (!cnt[i]) continue;
			ld val = 0;
			for (int k: appear) {
				ld x = ((ld)alfa[k][i])/cnt[i] - tmp[k];
				val += x*x;
			}

			if (val < best) {
				best = val;
				guess = i;
			}
		}

		for (int *it = E; it < E + 100; ++it)
			--tmp[*it];
	}

	int lan = language(guess);
	for (int *it = E; it < E + 100; ++it)
		++alfa[*it][lan];
	++cnt[lan];
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...