제출 #1336470

#제출 시각아이디문제언어결과실행 시간메모리
1336470monaxiaLanguages (IOI10_languages)C++20
70 / 100
1362 ms10260 KiB
#include <bits/stdc++.h>
#include <ext/random>
#include <ext/pb_ds/assoc_container.hpp>
#include "grader.h"
// #pragma GCC optimize("O3,unroll-loops")
// #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
 
#define pb push_back
#define ppb pop_back
#define fr first
#define sc second
#define all(v) v.begin(), v.end()
#define vektor vector
 
using namespace std;
using namespace __gnu_pbds;
 
using ll = long long;
using ull = unsigned ll;
using ld = long double;
 
constexpr ull Mod = 100;
constexpr ull Mod2 = 1 + 7 * 17 * (1 << 23);
constexpr ull sqr = 320;
constexpr ld eps = 1e-12;
 
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll random(ll l, ll r) {if(l <= r) return uniform_int_distribution <ll> (l, r)(rng); return -1;}

unordered_map <int, int> a[56], cnt, tot;
ld p[100];
int cntt = 0;
int cur = 0, ans = 0;

// int language(int l){
//     if(l == cur) ans ++;
//     return cur;
// }

void excerpt(int e[100]){
    cntt ++;

    if(cntt == 1){
        p[0] = 1;
        for(int i = 1; i <= 99; i ++) p[i] = p[i - 1] * 0.9;
    }

    int ans;
    pair <ld, int> mx = {0, -1};
    // compare and guess

    for(int i = 0; i <= 55; i ++){
        ld c = 0;
        for(int j = 0; j < 99; j ++){
            if(a[i][e[j]] == 0) continue;

            c += (ld)a[i][e[j]] / (ld)tot[e[j]] * (ld)p[cnt[e[j]] / 2];
        }

        mx = max(mx, {c, i});
    }

    ans = mx.sc;

    ans = language(ans);
    //learning

    for(int i = 0; i < 99; i ++){
        a[ans][e[i]] ++;
        tot[e[i]] ++;
        if(a[ans][e[i]] == 1) cnt[e[i]] ++;
    }
}

void solve(){
    vector <int> e[56];

    for(int i = 0; i <= 55; i ++){
        for(int j = 1; j <= 36; j ++) e[i].pb(j);
        for(int j = 1; j <= 50; j ++) e[i].pb(random(37, 100));
    }

    int E[100];

    for(int i = 1; i <= 10000; i ++){
        cur = random(0, 55);

        for(int i = 0; i < 100; i ++) E[i] = e[cur][random(0, e[cur].size() - 1)];

        excerpt(E);
    }

    cout << ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...