제출 #591697

#제출 시각아이디문제언어결과실행 시간메모리
591697ogibogi2004Languages (IOI10_languages)C++14
0 / 100
10083 ms29524 KiB
#include <bits/stdc++.h> #include "grader.h" #include "lang.h" const int MAX_SYMBOLS = 65545; const int MAX_LANGS=56; using namespace std; double freq[MAX_LANGS][MAX_SYMBOLS]; int seen[MAX_LANGS]; void excerpt(int *E) { double f1[MAX_SYMBOLS]; for(int i=0;i<MAX_SYMBOLS;i++)f1[i]=0; for(int i=0;i<100;i++) { f1[E[i]-1]+=1; } for(int i=0;i<MAX_SYMBOLS;i++) { f1[i]/=100.0; } int guess=0; double mindiff=2e9; for(int i=0;i<MAX_LANGS;i++) { if(seen[i]==0)continue; double err=0; for(int j=0;j<MAX_SYMBOLS;j++) { err+=(freq[i][j]-f1[j])*(freq[i][j]-f1[j]); } if(err<mindiff) { guess=i; mindiff=err; } } int l=language(guess); int s=seen[l]; double c1=1.0*s/(s+1.0); double c2=1.0/(s+1.0); for(int i=0;i<MAX_SYMBOLS;i++) { freq[l][i]=freq[l][i]*c1+f1[i]*c2; } seen[l]++; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...