답안 #64475

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
64475 2018-08-04T15:57:16 Z Abelyan Languages (IOI10_languages) C++17
95 / 100
2386 ms 43180 KB
#include "grader.h"
//#include "lang.h"
#include <bits/stdc++.h>
using namespace std;

typedef long double ld;
const int L=65536,S=100,LN=56;

ld cnt[LN],qan[LN][L],tv[S],mv[LN];
map<int,vector<ld> > two;
int ct=0;
void excerpt(int *e) {
    ct++;
    for (int i=0;i<S;i++){
        ld ans=0;
        for (int j=0;j<LN;j++){
            if (cnt[j]==0){
                tv[j]=0;
            }
            else{
                tv[j]=qan[j][e[i]]/cnt[j];
            }
            ans+=tv[j];
        }
        for (int j=0;j<LN;j++){
            if (ans!=0)
                mv[j]+=tv[j]/ans;
        }
    }
    vector<ld> k;
    for (int i=0;i<S-1;i++){
        ld ans=0;
        k=two[e[i]*L+e[i+1]];
        if (k.size())
        for (int j=0;j<LN;j++){
            //assert(cnt[j]>=0);
            tv[j]=k[j]/cnt[j];
            ans+=tv[j];
        }
        for (int j=0;j<LN;j++){
            if (ans!=0)
                mv[j]+=tv[j]/ans;
        }
    }
    ld mx=-50;
    int mxi=0;
    for (int i=0;i<LN;i++){
        //cout<<mv[i]<<endl;
        //if (mv[i]<0) cout<<i<<endl;
        if (mv[i]>mx){
            mx=mv[i];
            mxi=i;
        }
        mv[i]=0;
    }
    //assert(mxi!=57);
    int lang = language(mxi);
    cnt[lang]++;
    for (int i=0;i<S;i++){
        qan[lang][e[i]]++;
        if (i!=S-1){
            k=two[e[i]*L+e[i+1]];
            if (k.size()==0){
                for (int j=0;j<LN;j++)k.push_back(0);
            }
            k[lang]++;
            two[e[i]*L+e[i+1]]=k;
        }
    }

}
# 결과 실행 시간 메모리 Grader output
1 Correct 2187 ms 43180 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 2386 ms 43080 KB Output is partially correct - 87.33%