Submission #363396

# Submission time Handle Problem Language Result Execution time Memory
363396 2021-02-05T19:16:14 Z cig32 Languages (IOI10_languages) C++17
0 / 100
10000 ms 253124 KB
#include "bits/stdc++.h"
#include "lang.h"
#include "grader.h"
using namespace std;
int word[65536][56];
int totcnt[65536];
unordered_map<int,int>paircnt[56];
double newtiles[56];
int anscnt[56];
int test_case=0;
int space_character;
double diff=0;
void excerpt(int *a){
    test_case++;
    if(test_case==20){
        int mm=0;
        for(int i=0;i<65536;i++){
            mm=max(mm,totcnt[i]);
        }
        for(int i=0;i<65536;i++){
            if(mm==totcnt[i]){
                space_character=i;
                break;
            }
        }
    }
    double s[56];
    double m=0;
    int newcnt=0;
    for(int j=0;j<56;j++)s[j]=0;
    for(int j=0;j<100;j++){
        for(int k=0;k<56;k++){
            if(a[j]==space_character)continue;
            if(totcnt[a[j]])s[k]+=word[a[j]][k]*1.0/totcnt[a[j]];
            else newcnt++;
        }
    }
    for(int j=0;j<100;j++){
        int x=rand()%100;
        int y=rand()%100;
        if(a[x]==space_character || a[y]==space_character)continue;
        for(int k=0;k<56;k++){
            s[k]+=0.05*paircnt[k][a[x]*65536+a[y]];
        }
    }
    newcnt/=56;
    for(int j=0;j<56;j++){
        s[j]+=0.05*(100-abs(newtiles[j]-newcnt));
        m=max(m,s[j]);
    }
    for(int j=0;j<100;j++){
        totcnt[a[j]]++;
    }
    int ans;
    for(int j=0;j<56;j++){
        if(s[j]==m){
            ans=language(j);
            if(ans!=j){
                diff+=s[j]-s[ans];
            }
            break;
        }
    }
    newtiles[ans]=(newtiles[ans]*anscnt[ans]+newcnt)*1.0;
    anscnt[ans]++;
    newtiles[ans]/=anscnt[ans];
    for(int j=0;j<100;j++){
        word[a[j]][ans]++;
    }
    for(int j=0;j<100;j++){
        for(int k=0;k<100;k++){
            if(j!=k && a[j]!=space_character && a[k]!=space_character){
                paircnt[ans][a[j]*65536+a[k]]++;
            }
        }
    }
}

Compilation message

lang.cpp: In function 'void excerpt(int*)':
lang.cpp:54:9: warning: 'ans' may be used uninitialized in this function [-Wmaybe-uninitialized]
   54 |     int ans;
      |         ^~~
# Verdict Execution time Memory Grader output
1 Execution timed out 10117 ms 253124 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Execution timed out 10117 ms 253124 KB Time limit exceeded