Submission #390778

# Submission time Handle Problem Language Result Execution time Memory
390778 2021-04-16T21:33:56 Z Sorting Languages (IOI10_languages) C++17
91 / 100
6984 ms 98612 KB
#include <bits/stdc++.h>
#include "grader.h"
#include "lang.h"

using namespace std;

typedef double ld;
typedef unsigned int uint;
const int N = 100;
const int LANG = 64;
const int MAX_CHAR = 65536;

int *e;
int cnt[LANG];
unordered_map<uint, int> pair_cnt[LANG];
int char_cnt[LANG][MAX_CHAR];

void excerpt(int *_e){
    e = _e;

    map<int, int> mp;
    for(int i = 0; i < N; ++i)
        mp[e[i]]++;
    map<int, int> mp2;
    for(int i = 0; i < N - 1; ++i)
        mp2[(uint)e[i] * MAX_CHAR +  e[i + 1]]++;

    ld best_sim = DBL_MAX;
    int best_guess = 0;
    for(int guess = 0; guess < 56; ++guess){
        if(!cnt[guess]) continue;

        ld curr_sim = 0;
        for(auto [p, cnt_p]: mp2)
            curr_sim += 12 * abs((ld)pair_cnt[guess][p] / (ld)cnt[guess] - (ld)cnt_p);
        for(auto [x, cnt_x]: mp)
            curr_sim += abs((ld)char_cnt[guess][x] / (ld)cnt[guess] - (ld)cnt_x);
        if(curr_sim < best_sim){
            best_sim = curr_sim;
            best_guess = guess;
        }
    }

    int ans = language(best_guess);
    ++cnt[ans];
     for(int i = 0; i < N - 1; ++i)
         pair_cnt[ans][(uint)e[i] * MAX_CHAR + e[i + 1]]++;
    for(int i = 0; i < N; ++i)
        char_cnt[ans][e[i]]++;
}
# Verdict Execution time Memory Grader output
1 Correct 6933 ms 98492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Partially correct 6984 ms 98612 KB Output is partially correct - 83.10%