답안 #235437

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
235437 2020-05-28T09:24:49 Z dolphingarlic Languages (IOI10_languages) C++14
0 / 100
10000 ms 142864 KB
#include <bits/stdc++.h>
#define FOR(i, x, y) for (int i = x; i < y; i++)
typedef unsigned long long ll;
using namespace std;

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

const int SZ = 100, LANGS = 56;
const float LETTER_WEIGHT = 1, BIGRAM_WEIGHT = 2, TRIGRAM_WEIGHT = 3;

unordered_map<ll, float> prev_letters[LANGS];
int prev_cnt[LANGS];

void excerpt(int *E) {
   unordered_map<ll, float> curr_letters;
   FOR(i, 2, SZ) {
      curr_letters[E[i]]++;
      curr_letters[(E[i - 1] << 15) + E[i]]++;
      curr_letters[(E[i - 2] << 31) + (E[i - 1] << 15) + E[i]]++;
   }
   
   int best_lang = 0;
   float best_diff = 1e18;
   FOR(i, 0, LANGS) if (prev_cnt[i]) {
      float curr_diff = 0;
      for (pair<ll, float> j : curr_letters) {
         curr_diff += __builtin_popcount(j.first) * abs(j.second - (prev_letters[i][j.first] / prev_cnt[i]));
      }
      if (curr_diff < best_diff) {
         best_diff = curr_diff;
         best_lang = i;
      }
   }

   int correct = language(best_lang);
   prev_cnt[correct]++;
   for (pair<ll, float> i : curr_letters) {
      prev_letters[correct][i.first] += i.second;
   }
}
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 10024 ms 142620 KB Time limit exceeded
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 10022 ms 142864 KB Time limit exceeded