#include <stdlib.h>
#include <stdio.h>
#include <iostream>
#include "grader.h"
#include "lang.h"
#include <map>
using namespace std;
#define SZ 100
int prev[1100000];
map<int, int> uniq_letter_to_lang;
map<int, int> uniq_digraph_to_lang;
int get_digraph(int* E){
return E[0] * 65536 + E[1];
}
void excerpt(int *E) {
map<int, int> languages_to_unique_letters_shared;
map<int, int> languages_to_unique_digraphs_shared;
for(int i = 0; i < SZ; i++){
auto ite = uniq_letter_to_lang.find(E[i]);
if(ite == uniq_letter_to_lang.end() or ite->second == -1){
continue;
}
languages_to_unique_letters_shared[ite->second]++;
}
for(int i = 0; i < SZ - 1; i++){
auto ite = uniq_digraph_to_lang.find(get_digraph(&E[i]));
if(ite == uniq_digraph_to_lang.end() or ite->second == -1){
continue;
}
languages_to_unique_digraphs_shared[ite->second]++;
}
int best_lang = 0;
double best_score = -1.;
for(int i = 0; i < 56; i++){
int uniq_letter_score = languages_to_unique_letters_shared[i];
int uniq_digraph_score = languages_to_unique_digraphs_shared[i];
double curr_score = uniq_letter_score * 1. + uniq_digraph_score * 0.7;
if(best_score < curr_score){
best_lang = i;
best_score = curr_score;
}
}
int resp = language(best_lang);
for(int i = 0; i < SZ; i++){
auto ite = uniq_letter_to_lang.find(E[i]);
if(ite == uniq_letter_to_lang.end()){
uniq_letter_to_lang[E[i]] = resp;
continue;
} else if(ite->second != resp){
ite->second = -1;
}
}
for(int i = 0; i < SZ - 1; i++){
auto ite = uniq_digraph_to_lang.find(get_digraph(&E[i]));
if(ite == uniq_digraph_to_lang.end()){
uniq_digraph_to_lang[get_digraph(&E[i])] = resp;
continue;
} else if(ite->second != resp){
ite->second = -1;
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |