Submission #155338

# Submission time Handle Problem Language Result Execution time Memory
155338 2019-09-27T14:37:07 Z jhnah917 Languages (IOI10_languages) C++14
101 / 100
3919 ms 55356 KB
#include "grader.h"
#include "lang.h"
#include <bits/stdc++.h>
using namespace std;
 
const int n = 100, m = 56;
const int mod = 80021;
 
int cnt[57][80808];
int cnt2[57][80808];
int cnt3[57][80808];
int cnt4[57][80808];
int lan[57];
 
int f(int a, int b){
	long long ret = (long long)a << 16;
	ret |= b;
	ret %= mod;
	return ret;
}
 
int f(int a, int b, int c){
	long long ret = (long long)f(a, b) << 16;
	ret |= c;
	ret %= mod;
	return ret;
}
 
int f(int a, int b, int c, int d){
	long long ret = (long long)f(a, b, c) << 16;
	ret |= d;
	ret %= mod;
	return ret;
}

double f(int x){
	return (double)x / (x + 1);
}

void excerpt(int *arr){
	double mx = 0;
	int idx = 0;
	for(int i=0; i<m; i++){
		double now = 0;
		for(int j=0; j<n; j++){
			now += f(cnt[i][arr[i]]);
			if(j >= n-1) continue;
			now += f(cnt2[i][f(arr[j], arr[j+1])]) * 100;
			if(j >= n-2) continue;
			now += f(cnt3[i][f(arr[j], arr[j+1], arr[j+2])]) * 150;
			if(j >= n-3) continue;
			now += f(cnt4[i][f(arr[j], arr[j+1], arr[j+2], arr[j+3])]) * 100;
		}
		now /= log(lan[i] + 1);
		if(now > mx){
			mx = now; idx = i;
		}
	}
	
	int ans = language(idx);
	lan[ans]++;
	for(int i=0; i<n; i++){
		cnt[ans][arr[i]]++;
		if(i >= n-1) continue;
		cnt2[ans][f(arr[i], arr[i+1])]++;
		if(i >= n-2) continue;
		cnt3[ans][f(arr[i], arr[i+1], arr[i+2])]++;
		if(i >= n-3) continue;
		cnt4[ans][f(arr[i], arr[i+1], arr[i+2], arr[i+3])]++;
	}
}
# Verdict Execution time Memory Grader output
1 Correct 3866 ms 55300 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3919 ms 55356 KB Output is correct - 92.40%