답안 #51708

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
51708 2018-06-20T07:42:38 Z tjd229 Languages (IOI10_languages) C++11
95 / 100
6717 ms 33412 KB
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include "grader.h"
#include "lang.h"
#define ll long long
#define SZ 100
#define MAXL 56
const int mod = 70001;
static int lnum = -1;
int cnt1[MAXL][mod], cnt2[MAXL][mod], cnt3[MAXL][mod];
int cnt4[MAXL][mod];
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 %= mod;
		res += va_arg(li, int);
	}
	va_end(li);
	return res;

}
void excerpt(int *E) {
	int i, j;
	ll mx=0;
	int l = 0;
	for (i = 0; i <= lnum; i++){
		ll val = 0;
		for (j = 0; j < SZ; j++) val += cnt1[i][E[j]];
		for (j = 1; j < SZ; j++) val += cnt2[i][hash_func(2,E[j - 1], E[j])] * 10;
		for (j = 2; j < SZ; j++) val += cnt3[i][hash_func(3, E[j - 2], E[j - 1], E[j])] * 30;
		//for (j = 3; j < SZ; j++) val += cnt4[i][hash_func(4, E[j - 3], E[j - 2], E[j - 1], E[j])]*90;
		if (mx < val){
			mx = val;
			l = i;
		}
	}
	int ans = language(l);
	if (ans > lnum) lnum = ans;
	for (i = 0; i < SZ; i++) cnt1[ans][E[i]] = 1;
	for (i = 1; i < SZ; i++) cnt2[ans][hash_func(2, E[i - 1], E[i])] = 1;
	for (i = 2; i < SZ; i++) cnt3[ans][hash_func(3, E[i - 2], E[i - 1], E[i])] = 1;
	//for (i = 3; i < SZ; i++) cnt4[ans][hash_func(4, E[i - 3], E[i - 2], E[i - 1], E[i])]=1;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 6717 ms 33360 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 5621 ms 33412 KB Output is partially correct - 87.17%