제출 #1327221

#제출 시각아이디문제언어결과실행 시간메모리
1327221skibidigodv9Languages (IOI10_languages)C++20
98 / 100
4213 ms18232 KiB
#include <bits/stdc++.h>
#include "grader.h"
using namespace std;

unordered_map<long long, int> NW[3][56];
long long superConst = 100000000000;
vector<long long> Cst = {superConst, 12*superConst, 100*superConst};
//single[char][lang] = weight?

void excerpt(int* E) {
    long long n = 100, i, j, k, l = 0;
    vector<long long> langScore(56, 0), wPop(56, 0);

    k = -1; while (++k < 3) {
        //k+1 in a row
        i = k-1; while (++i < n) {
            long long stv = 0, S = 0;
            l = k+1; while (l--) stv += (long long)(E[i-l])<<(l<<4LL);
            j = -1; while (++j < 56) {
                if (NW[k][j].find(stv) != NW[k][j].end()) {
                    wPop[j] = NW[k][j][stv];
                    S += wPop[j]*wPop[j];
                } else wPop[j] = 0;
            }
            if (S == 0) {
                langScore[0]++; //never seen that before
            } else {
                long long cc = Cst[k]/S;
                j = -1; while (++j < 56) langScore[j] += cc*wPop[j]*wPop[j];
            }
        }
    }

    long long bestLang = 0;
    i = -1; while (++i < 56) {
        if (langScore[i] > langScore[bestLang]) bestLang = i;
    }
    long long L = language(bestLang);
    k = -1; while (++k < 3) {
        //k+1 in a row
        i = k-1; while (++i < n) {
            long long stv = 0;
            l = k+1; while (l--) stv += (long long)(E[i-l])<<(l<<4LL);
            NW[k][L][stv]++;
        }
    }
    return;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...