Submission #1327155

#TimeUsernameProblemLanguageResultExecution timeMemory
1327155nguynLanguages (IOI10_languages)C++20
57 / 100
1208 ms123168 KiB
#include <bits/stdc++.h>
#include "grader.h"

using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define debug(...)
#endif // LOCAL

#define ll long long
#define F first
#define S second
#define pb push_back
#define pii pair<int, int>
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()

const int N = 2e5 + 5;
const int base = 65537;
const int mod = 199999;
const ll inf = 1e18;

int cnt[4][56][mod]; 
int p[4] = {1, 3, 6, 9};

ll score[56]; 

void excerpt(int E[]) {
    memset(score, 0, sizeof(score)); 
    for (int len = 1; len <= 4; len++) {
        for (int i = 0; i + len - 1 < 100; i++) {
            ll hsh = 0; 
            for (int j = i; j < i + len; j++) {
                hsh = (hsh * base + E[j]) % mod; 
            }
            for (int i = 0; i < 56; i++) score[i] += p[len - 1] * cnt[len - 1][i][hsh]; 
        }
    }
    int best = 0;
    for (int i = 1; i < 56; i++) {
        if (score[i] > score[best]) best = i; 
    }
    int L = language(best); 
    for (int len = 1; len <= 4; len++) {
        for (int i = 0; i + len - 1 < 100; i++) {
            ll hsh = 0; 
            for (int j = i; j < i + len; j++) {
                hsh = (hsh * base + E[j]) % mod; 
            }
            cnt[len - 1][L][hsh]++; 
        }
    }
}   
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...