답안 #2960

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
2960 2013-08-19T01:11:03 Z gs13068 Languages (IOI10_languages) C++
61 / 100
1612 ms 10004 KB
#include"grader.h"
#include"lang.h"

int langn[56];
int lang[56][65536];
int a[65536];
int b[100];
int c[100];

void excerpt(int *str)
{
  double max=987654321,maxlang;
  double now;
  int i,j,n,sum;
  for(i=0;i<65536;i++)a[i]=0;
  for(i=0;i<100;i++)a[str[i]]++;
  j=0;
  for(i=0;i<65536;i++)if(a[i])
  {
    b[j]=i;
    c[j]=a[i];
    j++;
  }
  for(i=0;i<56;i++)
  {
    sum=langn[i]+1;
    now=0;
    for(j=0;j<100;j++)now+=(1.*lang[i][b[j]]/sum-c[j]/100.)*(1.*lang[i][b[j]]/sum-c[j]/100.);
    if(now<max)
    {
      max=now;
      maxlang=i;
    }
  }
  n=language(maxlang);
  langn[n]+=100;
  for(i=0;i<100;i++)lang[n][b[i]]+=c[i];
}

Compilation message

lang.cpp: In function 'void excerpt(int*)':
lang.cpp:35:13: warning: 'maxlang' may be used uninitialized in this function [-Wmaybe-uninitialized]
   n=language(maxlang);
     ~~~~~~~~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1405 ms 10004 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 1612 ms 9740 KB Output is partially correct - 56.96%