Submission #155314

# Submission time Handle Problem Language Result Execution time Memory
155314 2019-09-27T14:14:47 Z jhnah917 Languages (IOI10_languages) C++14
99 / 100
3721 ms 67760 KB
#include "grader.h"
#include "lang.h"
#include <bits/stdc++.h>
using namespace std;
 
const int n = 100, m = 56;
const int mod = 1e5+19, base = 917;
 
int cnt[66][101010];
int cnt2[66][101010];
int cnt3[66][101010];
int cnt4[66][101010];
 
int f(int a, int b){
	int ret = a;
	ret = (ret * base + b) % mod;
	return ret;
}
 
int f(int a, int b, int c){
	int ret = a;
	ret = (ret * base + b) % mod;
	ret = (ret * base + c) % mod;
	return ret;
}
 
int f(int a, int b, int c, int d){
	int ret = a;
	ret = (ret * base + b) % mod;
	ret = (ret * base + c) % mod;
	ret = (ret * base + d) % mod;
	return ret;
}
 
void excerpt(int *arr){
	int mx = 0, idx = 0;
	for(int i=0; i<m; i++){
		int now = 0;
		for(int j=0; j<n; j++){
			if(cnt[i][arr[j]]) now++;
			if(j == n-1) continue;
			if(cnt2[i][f(arr[j], arr[j+1])]) now++;
			if(j == n-2) continue;
			if(cnt3[i][f(arr[j], arr[j+1], arr[j+2])]) now++;
			if(j == n-3) continue;
			if(cnt4[i][f(arr[j], arr[j+1], arr[j+2], arr[j+3])]) now++;
		}
		if(now > mx){
			mx = now; idx = i;
		}
	}
	
	int ans = language(idx);
	for(int i=0; i<n; i++){
		cnt[ans][arr[i]] = 1;
		if(i == n-1) continue;
		cnt2[ans][f(arr[i], arr[i+1])] = 1;
		if(i == n-2) continue;
		cnt3[ans][f(arr[i], arr[i+1], arr[i+2])] = 1;
		if(i == n-3) continue;
		cnt4[ans][f(arr[i], arr[i+1], arr[i+2], arr[i+3])] = 1;
	}
}
# Verdict Execution time Memory Grader output
1 Correct 3721 ms 67584 KB Output is correct
# Verdict Execution time Memory Grader output
1 Partially correct 3368 ms 67760 KB Output is partially correct - 90.18%