답안 #67583

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
67583 2018-08-15T03:53:02 Z usefulhyun Languages (IOI10_languages) C++17
82 / 100
5193 ms 51340 KB
#include <stdlib.h>
#include <stdio.h>
#include <map>
#include <unordered_map>
using namespace std;

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

#define SZ 100

unordered_map<int, int> occurrence[56];
bool initialized = false;
void init() {

	for (int lang = 0; lang < 56; lang++) {
		occurrence[lang].reserve(100000);
	}
}

int words[200];
int word_size = 0;
void clear() {
	word_size = 0;
}
void insert_word(int key) {
	for (int i = 0; i < word_size; i++) {
		if ( words[i] == key)
			return;
	}
	words[word_size++] = key;
}


void excerpt(int *E) {
	if (!initialized) {
		init();
		initialized = true;
	}



	int guess = 0;
	int max_similarity = 0;
	for (int lang = 0; lang < 56; lang++) {
		int similarity = 0;
		clear();

		for (int i = 0; i < 100; i++) {
			int key = E[i];
			insert_word(key);
		}

		for (int i = 0; i < 99; i++) {
			int key = E[i] * 65536 + E[i + 1];
			insert_word(key);
		}

		for (int i = 0; i < word_size; i++){
			int key = words[i];
			if (occurrence[lang].find(key) != occurrence[lang].end())
				similarity++;
		}
		

		if (max_similarity < similarity) {
			max_similarity = similarity;
			guess = lang;
		}
	}


	int ans = language(guess);

	for (int i = 0; i < 100; i++) {
		int key = E[i];
		occurrence[ans][key] = 1;
	}

	for (int i = 0; i < 99; i++) {
		int key = E[i] * 65536 + E[i + 1];
		occurrence[ans][key] = 1;
	}

//	printf("%d %d\n", guess, ans);

}
# 결과 실행 시간 메모리 Grader output
1 Correct 5108 ms 51340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 5193 ms 51276 KB Output is partially correct - 75.42%