Submission #51702

# Submission time Handle Problem Language Result Execution time Memory
51702 2018-06-20T06:33:31 Z tjd229 Languages (IOI10_languages) C++11
0 / 100
10000 ms 26272 KB
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>

#include "grader.h"
#include "lang.h"
#include <unordered_map>
#define ll long long
#define SZ 100 //length
#define MAXL 56
using namespace std;
const int uni = 1 << 16;
static int lnum = -1;

int cnt[MAXL];
int cnt1[MAXL][uni + 1];
unordered_map<ll, int> cnt2[MAXL], cnt3[MAXL];
unordered_map<ll, int> cnt4[MAXL];

ll hash_func(int n, ...){
	va_list li;
	va_start(li, n);
	ll res = 0;
	for (int i = 0; i < n; i++){
		res <<= 16;
		res += va_arg(li, int);
	}
	va_end(li);
	return res;
}
void excerpt(int *E) {
	int i, j;
	double mx = 0;
	int l = 0;

	for (i = 0; i <= lnum; i++){
		double val = 0;
		for (j = 0; j < SZ; j++){
			ll h = hash_func(1, E[j]);
			val += cnt1[i][h];
			//if (cnt1[i].find(h) != cnt1[i].end()) val +=cnt1[i][h] *1;
		}
		for (j = 1; j < SZ; j++){
			ll h = hash_func(2, E[j - 1], E[j]);
			if (cnt2[i].find(h) != cnt2[i].end()) val += cnt2[i][h]*10;
		}
		for (j = 2; j < SZ; j++){
			ll h = hash_func(3, E[j - 2], E[j - 1], E[j]);
			if (cnt3[i].find(h) != cnt3[i].end()) val += cnt3[i][h] * 30;
		}
		for (j = 3; j < SZ; j++){
			ll h = hash_func(4, E[j - 3], E[j - 2], E[j - 1], E[j]);
			if (cnt4[i].find(h) != cnt4[i].end()) val += cnt4[i][h] * 90;
		}
		if (mx < val){
			mx = val;
			l = i;
		}
	}
	int ans = language(l);
	//printf("%d,%f,%d\n", l, mx, ans);
	if (ans > lnum) lnum = ans;
	for (i = 0; i < SZ; i++){
		ll h = hash_func(1, E[i]);	
		cnt1[ans][h] = 1;
		//if (cnt1[ans].find(h) == cnt1[ans].end()) cnt1[ans][h] = 1;
		//else cnt1[ans][h]++;
	}
	for (i = 1; i < SZ; i++){
		ll h = hash_func(2, E[i - 1], E[i]);
		if (cnt2[ans].find(h) == cnt2[ans].end()) cnt2[ans][h] = 1;
		//else cnt2[ans][h]++;
	}
	for (i = 2; i < SZ; i++){
		ll h = hash_func(3, E[i - 2], E[i - 1], E[i]);
		if (cnt3[ans].find(h) == cnt3[ans].end()) cnt3[ans][h] = 1;
		//else cnt3[ans][h]++;
	}
	for (i = 3; i < SZ; i++){
		ll h = hash_func(4, E[i - 3], E[i - 2], E[i - 1], E[i]);
		if (cnt4[ans].find(h) == cnt4[ans].end()) cnt4[ans][h] = 1;
		//else cnt3[ans][h]++;
	}
	cnt[ans]++;
}
# Verdict Execution time Memory Grader output
1 Execution timed out 10016 ms 25780 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Execution timed out 10096 ms 26272 KB Time limit exceeded