Submission #57240

# Submission time Handle Problem Language Result Execution time Memory
57240 2018-07-14T10:42:02 Z Crown Languages (IOI10_languages) C++14
0 / 100
10000 ms 84176 KB
#include "grader.h"
#include "lang.h"
#include <bits/stdc++.h>
using namespace std;
#define X first
#define Y second
#define pb push_back
typedef pair<int, int> ii;
typedef long long ll;

#define SZ 100
#define lng 55
#define ch 65535

const ll all = 1LL*ch*ch;

map<ll, double> mp[60];
int cnt[60];
map<ll, int> freq;

void excerpt(int *E)
{
	freq.clear();
	for(int i = 0; i+1< 100; i++)
	{
		ll help = E[i]*ch+E[i+1];
		freq[help]++;
	}
	int best = -1;
	double bestdiff = 1e18;
	for(int lang = 0; lang<= 55; lang++)
	{
		double diff = 0;
		for(auto kk : freq)
		{
			ll chunk = kk.X;
			double f = 1.00*kk.Y/100;
			double here;
			if(cnt[lang] == 0) here = 1.00/all;
			else here = mp[lang][chunk];
			diff += (here-f)*(here-f);
		}
		if(diff< bestdiff)
		{
			bestdiff = diff;
			best = lang;
		}
	}
	int ans = language(best);
	for(auto &kk : mp[ans])
	{
		kk.Y *= cnt[ans];
	}
	cnt[ans]++;
	for(auto kk : freq)
	{
		mp[ans][kk.X] += kk.Y;
	}
	for(auto &kk : mp[ans])
	{
		kk.Y /= cnt[ans];
	}
}
# Verdict Execution time Memory Grader output
1 Execution timed out 10057 ms 82880 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Execution timed out 10031 ms 84176 KB Time limit exceeded