Submission #235408

# Submission time Handle Problem Language Result Execution time Memory
235408 2020-05-28T08:45:42 Z dolphingarlic Languages (IOI10_languages) C++14
0 / 100
10000 ms 262148 KB
#include <bits/stdc++.h>
#define FOR(i, x, y) for (int i = x; i < y; i++)
typedef long long ll;
typedef long double ld;
using namespace std;

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

const int sz = 100, langs = 56;
const ll chr = 65535;

inline ld sq(ld X) { return X * X; }

map<ll, ld> prev_trigrams[langs];
int prev_cnt[langs];

void excerpt(int *E) {
   map<ll, ld> curr_trigrams;
   FOR(i, 2, sz) {
      curr_trigrams[chr * (chr * E[i - 2] + E[i - 1]) + E[i]]++;
   }
   
   int best_lang = 0;
   ld best_diff = 1e18;
   FOR(i, 0, langs) if (prev_cnt[i]) {
      ld curr_diff = 0;
      for (pair<ll, ld> j : curr_trigrams) {
         curr_diff += sq(j.second - (prev_trigrams[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, ld> i : curr_trigrams) {
      prev_trigrams[correct][i.first] += i.second;
   }
}
# Verdict Execution time Memory Grader output
1 Execution timed out 10083 ms 241852 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Runtime error 9136 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)