답안 #235496

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
235496 2020-05-28T11:27:42 Z dolphingarlic Languages (IOI10_languages) C++14
97 / 100
6288 ms 95148 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 SI_WEIGHT = 1, BI_WEIGHT = 4, TR_WEIGHT = 17, QU_WEIGHT = 47;

ll cnt[LANGS], si[SZ], bi[SZ], tr[SZ], qu[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) {
        qu[i] = 0;
        FOR(j, 0, 4) { qu[i] = (qu[i] << 16) + E[i + j]; }
        tr[i] = qu[i] >> 16;
        bi[i] = tr[i] >> 16;
        si[i] = bi[i] >> 16;

        if (mp[qu[i]].size()) {
            int best = -1, sim = -1;
            for (pair<int, int> k : mp[qu[i]]) {
                if (k.second > sim) {
                    sim = k.second;
                    best = k.first;
                }
            }
            cnt[best] += QU_WEIGHT;
        }
        if (mp[tr[i]].size()) {
            int best = -1, sim = -1;
            for (pair<int, int> k : mp[tr[i]]) {
                if (k.second > sim) {
                    sim = k.second;
                    best = k.first;
                }
            }
            cnt[best] += TR_WEIGHT;
        }
        if (mp[bi[i]].size()) {
            int best = -1, sim = -1;
            for (pair<int, int> k : mp[bi[i]]) {
                if (k.second > sim) {
                    sim = k.second;
                    best = k.first;
                }
            }
            cnt[best] += BI_WEIGHT;
        }
        if (mp[si[i]].size()) {
            int best = -1, sim = -1;
            for (pair<int, int> k : mp[si[i]]) {
                if (k.second > sim) {
                    sim = k.second;
                    best = k.first;
                }
            }
            cnt[best] += SI_WEIGHT;
        }
    }

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

    int ans = language(best);
    FOR(i, 0, SZ - 3) {
        mp[qu[i]][ans]++;
        mp[tr[i]][ans]++;
        mp[bi[i]][ans]++;
        mp[si[i]][ans]++;
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5880 ms 95104 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 6288 ms 95148 KB Output is partially correct - 89.05%