Submission #235459

# Submission time Handle Problem Language Result Execution time Memory
235459 2020-05-28T10:18:42 Z dolphingarlic Languages (IOI10_languages) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("O3")
#pragma GCC target("sse4,avx2,fma,avx")
#define FOR(i, x, y) for (int i = x; i < y; i++)
typedef long long ll;
using namespace std;

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

const int SZ = 100, LANGS = 56;
const ll BIGRAM_WEIGHT = 1, TRIGRAM_WEIGHT = 10, QUADRAM_WEIGHT = 100;

ll cnt[LANGS], bigram[SZ], trigram[SZ], quadram[SZ];
unordered_map<ll, unordered_map<int, int>> mp;

void excerpt(int *E) {
    FOR(i, 0, LANGS) cnt[i] = 0;
    FOR(i, 0, SZ - 3) {
        quadram[i] = 0;
        FOR(j, 0, 4) {
            quadram[i] = (quadram[i] << 16) + E[i + j];
        }
        trigram[i] = quadram[i] >> 16;
        bigram[i] = trigram[i] >> 16;

        if (mp[quadram[i]].size()) {
            int best = 0, sim = 0;
            for (pair<int, int> k : mp[quadram[i]]) {
                if (k.second > sim) {
                    sim = k.second;
                    best = k.first;
                }
            }
            cnt[best] += QUADRAM_WEIGHT;
        }
        if (mp[trigram[i]].size()) {
            int best = 0, sim = 0;
            for (pair<int, int> k : mp[trigram[i]]) {
                if (k.second > sim) {
                    sim = k.second;
                    best = k.first;
                }
            }
            cnt[best] += TRIGRAM_WEIGHT;
        }
        if (mp[bigram[i]].size()) {
            int best = 0, sim = 0;
            for (pair<int, int> k : mp[bigram[i]]) {
                if (k.second > sim) {
                    sim = k.second;
                    best = k.first;
                }
            }
            cnt[best] += BIGRAM_WEIGHT;
        }
    }

    int best = 0, sim = 0;
    FOR(i, 0, LANGS) {
        if (cnt[i] > sim) {
            sim = cnt[i];
            best = i;
        }
    }

    int ans = language(best);
    FOR(i, 0, SZ - 3) {
        mp[quadram[i]][ans]++;
        mp[trigram[i]][ans]++;
        mp[bigram[i]][ans]++;
        mp[letter[i]][ans]++;
    }
}

Compilation message

lang.cpp: In function 'void excerpt(int*)':
lang.cpp:73:12: error: 'letter' was not declared in this scope
         mp[letter[i]][ans]++;
            ^~~~~~
lang.cpp:73:12: note: suggested alternative: 'gettext'
         mp[letter[i]][ans]++;
            ^~~~~~
            gettext