답안 #363389

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
363389 2021-02-05T19:02:21 Z cig32 Languages (IOI10_languages) C++17
72 / 100
267 ms 5996 KB
#include "bits/stdc++.h"
#include "lang.h"
#include "grader.h"
using namespace std;
int word[65536][56];
int totcnt[65536];
double newtiles[56];
int anscnt[56];
int test_case=0;
int space_character;
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++;
        }
    }
    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);
            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]++;
    }
}

Compilation message

lang.cpp: In function 'void excerpt(int*)':
lang.cpp:55:23: warning: 'ans' may be used uninitialized in this function [-Wmaybe-uninitialized]
   55 |         word[a[j]][ans]++;
      |         ~~~~~~~~~~~~~~^
# 결과 실행 시간 메모리 Grader output
1 Correct 265 ms 5996 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 267 ms 5996 KB Output is partially correct - 67.14%