Submission #897628

# Submission time Handle Problem Language Result Execution time Memory
897628 2024-01-03T14:02:15 Z Macker Languages (IOI10_languages) C++14
0 / 100
10000 ms 36164 KB
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef long double ld;
#define all(v) v.begin(), v.end()

#pragma GCC optimize("Ofast")
#pragma GCC target("avx2")

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

#define SZ 100
#define MXLEN 5

set<ll> v[56][MXLEN];

class HashedArray{
   ll B = 42069;
   ll mod = 1e9+7;
   vector<ll> hsh;
   vector<ll> pow;
public:
   HashedArray(int* s){
      hsh.resize(101, 0);
      pow.resize(101, 1);
      for (int i = 1; i < 100; i++) {
         pow[i] = pow[i - 1] * B % mod;
      }
      
      for (int i = 0; i < 100; i++) {
         hsh[i + 1] = (hsh[i] * B % mod + s[i]) % mod;
      }
   }

   ll gethsh(int s, int e){
      ll raw = hsh[e] - hsh[s] * pow[e - s];
      return (raw % mod + mod) % mod;
   }
};


void excerpt(int *E) {
   vector<int> score(56);
   vector<ll> cur[MXLEN];
   HashedArray ha(E);
   for (int i = 1; i < MXLEN; i++) {
      for (int j = 0; j < 100 - i; j++) {
         cur[i].push_back(ha.gethsh(j, i + j + 1));
      }
   }
   
   for (int i = 0; i < 56; i++) {
      for (int j = 1; j < MXLEN; j++) {
         for (auto &x : cur[j]) {
            if(v[i][j].find(x) != v[i][j].end()){
               score[i] += j * j * j;
            }
         }
      }
   }
   int mx = 0;
   int mxi = 0;
   for (int i = 0; i < 56; i++) {
      if(score[i] > mx) {
         mx = score[i];
         mxi = i;
      }
   }
   
   int lan = language(mxi);

   for (int i = 0; i < MXLEN; i++) {
      for (auto &x : cur[i]) {
         v[lan][i].insert(x);
      }
   }
   
}
# Verdict Execution time Memory Grader output
1 Execution timed out 10017 ms 36084 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 10097 ms 36164 KB Time limit exceeded
2 Halted 0 ms 0 KB -