답안 #67580

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
67580 2018-08-15T03:48:03 Z usefulhyun Languages (IOI10_languages) C++17
82 / 100
8540 ms 51324 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);
	}
}

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;
		map<int, bool> words;

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

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

		for (auto itr = words.begin(); itr != words.end(); itr++) {
			int key = itr->first;
			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 8540 ms 51192 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 8446 ms 51324 KB Output is partially correct - 75.42%