Submission #760511

# Submission time Handle Problem Language Result Execution time Memory
760511 2023-06-17T16:48:19 Z SanguineChameleon Languages (IOI10_languages) C++17
100 / 100
9961 ms 39228 KB
#include <stdlib.h>
#include <stdio.h>

#include "grader.h"
#include "lang.h"

#define SZ 100

#include <bits/stdc++.h>
using namespace std;

unordered_set<long long> lang_words[56][4];
long long score[56];
int weight[4];

void excerpt(int *E) {
	weight[0] = 1;
	weight[1] = 10;
	weight[2] = 1;
	weight[3] = 20;
	for (int i = 0; i < 56; i++) {
		score[i] = 0;
	}
	for (int len = 1; len <= 4; len++) {
		unordered_set<long long> exp_words;
		for (int i = 0; i < 101 - len; i++) {
			unsigned long long h = 0;
			for (int j = 0; j < len; j++) {
				h = h << 16 | E[i + j];
			}
			exp_words.insert(h);
		}
		for (auto h: exp_words) {
			for (int j = 0; j < 56; j++) {
				score[j] += lang_words[j][len - 1].count(h) * weight[len - 1];
			}
		}
	}
	pair<long long, int> best = make_pair(-1, -1);
	for (int i = 0; i < 56; i++) {
		best = max(best, make_pair(score[i], i));
	}
	int ans = language(best.second);
	for (int len = 1; len <= 4; len++) {
		for (int i = 0; i < 101 - len; i++) {
			unsigned long long h = 0;
			for (int j = 0; j < len; j++) {
				h = h << 16 | E[i + j];
			}
			lang_words[ans][len - 1].insert(h);
		}
	}
}
# Verdict Execution time Memory Grader output
1 Correct 9854 ms 39204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9961 ms 39228 KB Output is correct - 91.02%