Submission #292157

# Submission time Handle Problem Language Result Execution time Memory
292157 2020-09-06T13:02:00 Z tatyam Languages (IOI10_languages) C++17
101 / 100
1973 ms 145944 KB
#include "grader.h"
#include "lang.h"
#include <bits/stdc++.h>
using namespace std;

#define C(n) \
auto comp ## n = [](const array<int, n>& a){ uint64_t ans = 0; for(int i : a){ ans <<= 16; ans |= i; } return ans; };\
unordered_map<array<int, n>, array<int, 56>, decltype(comp ## n)> c ## n(1 << 17, comp ## n)
C(1);
C(2);
C(3);
C(4);
array<double, 56> cnt;

/*
random_device RD;
double A = 85.69436, B = 1066.034, C = 143.9561, D = 1719.933;
double highest = 91.75;
/*/
const double A = 85.69436, B = 1066.034, C = 143.9561, D = 1719.933;
// */
void excerpt(int *E) {
   cnt.fill(0);
   for(int i = 0; i <= 100 - 1; i++){
      auto& c = c1[{E[i]}];
      int s = accumulate(c.begin(), c.end(), 0);
      if(!s) continue;
      for(int i = 0; i < 56; i++) cnt[i] += double(c[i]) / s * A;
   }
   for(int i = 0; i <= 100 - 2; i++){
      auto& c = c2[{E[i], E[i + 1]}];
      int s = accumulate(c.begin(), c.end(), 0);
      if(!s) continue;
      for(int i = 0; i < 56; i++) cnt[i] += double(c[i]) / s * B;
   }
   for(int i = 0; i <= 100 - 3; i++){
      auto& c = c3[{E[i], E[i + 1], E[i + 2]}];
      int s = accumulate(c.begin(), c.end(), 0);
      if(!s) continue;
      for(int i = 0; i < 56; i++) cnt[i] += double(c[i]) / s * C;
   }
   for(int i = 0; i <= 100 - 4; i++){
      auto& c = c4[{E[i], E[i + 1], E[i + 2], E[i + 3]}];
      int s = accumulate(c.begin(), c.end(), 0);
      if(!s) continue;
      for(int i = 0; i < 56; i++) cnt[i] += double(c[i]) / s * D;
   }

   int ans = language(max_element(cnt.begin(), cnt.end()) - cnt.begin());

   for(int i = 0; i <= 100 - 1; i++){
      auto& c = c1[{E[i]}];
      c[ans]++;
   }
   for(int i = 0; i <= 100 - 2; i++){
      auto& c = c2[{E[i], E[i + 1]}];
      c[ans]++;
   }
   for(int i = 0; i <= 100 - 3; i++){
      auto& c = c3[{E[i], E[i + 1], E[i + 2]}];
      c[ans]++;
   }
   for(int i = 0; i <= 100 - 4; i++){
      auto& c = c4[{E[i], E[i + 1], E[i + 2], E[i + 3]}];
      c[ans]++;
   }
}
# Verdict Execution time Memory Grader output
1 Correct 1973 ms 145876 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1954 ms 145944 KB Output is correct - 92.27%