Submission #64490

# Submission time Handle Problem Language Result Execution time Memory
64490 2018-08-04T16:08:21 Z Abelyan Languages (IOI10_languages) C++17
96 / 100
4090 ms 81484 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,three;
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]+=(ld)23*tv[j]/ans;
        }
    }
    for (int i=0;i<S-2;i++){
        ld ans=0;
        k=three[e[i]*L*L+e[i+1]*L+e[i+2]];
        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]+=(ld)50*tv[j]/ans;
        }
    }
    ld mx=-50;
    int mxi;
    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;
        }
        if (i<S-1){
            k=three[e[i]*L*L+e[i+1]*L+e[i+2]];
            if (k.size()==0){
                for (int j=0;j<LN;j++)k.push_back(0);
            }
            k[lang]++;
            three[e[i]*L*L+e[i+1]*L+e[i+2]]=k;
        }
    }

}

Compilation message

lang.cpp: In function 'void excerpt(int*)':
lang.cpp:71:28: warning: 'mxi' may be used uninitialized in this function [-Wmaybe-uninitialized]
     int lang = language(mxi);
                            ^
# Verdict Execution time Memory Grader output
1 Correct 3680 ms 81484 KB Output is correct
# Verdict Execution time Memory Grader output
1 Partially correct 4090 ms 81416 KB Output is partially correct - 87.96%