Submission #64483

# Submission time Handle Problem Language Result Execution time Memory
64483 2018-08-04T16:01:50 Z Abelyan Languages (IOI10_languages) C++17
96 / 100
2356 ms 43072 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]+=0.005*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;
    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;
        }
    }

}

Compilation message

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