Submission #8495

# Submission time Handle Problem Language Result Execution time Memory
8495 2014-09-14T23:40:11 Z gs13023 Languages (IOI10_languages) C++
85 / 100
3823 ms 84732 KB
#include<cstdio>
#include<string.h>
#include"grader.h"
#include"lang.h"
#define MOD 65536
int lang_freq[60][70000];
long long lang_flow1[60][70000];
long long lang_flow2[60][70000];
long long lang_flow3[60][70000];
long long lang_flow4[60][70000];
long long f1(int a,int b)
{
    return ((a<<3)^b)%MOD;
}
long long f2(int a,int b,int c)
{
    return ((a<<6)^(b<<3)^c)%MOD;
}
long long f3(int a,int b,int c,int d)
{
    return ((a<<9)^(b<<6)^(c<<3)^d)%MOD;
}
long long f4(int a,int b,int c,int d,int e)
{
    return ((a<<12)^(b<<9)^(c<<6)^(d<<3)^e)%MOD;
}
void excerpt(int *E)
{
    int ans=0;
  	long long ansp=0;
    long long pos[60]={0};
    for(int i=0;i<56;i++)
    {
        for(int j=0;j<100;j++)
        {
            pos[i]+=lang_freq[i][E[j]];
            if(j>0)pos[i]+=lang_flow1[i][f1(E[j-1],E[j])]*1000;
            if(j>1)pos[i]+=lang_flow2[i][f2(E[j-2],E[j-1],E[j])]*100001;
          	if(j>2)pos[i]+=lang_flow3[i][f3(E[j-3],E[j-2],E[j-1],E[j])]*10000001;
          	if(j>3)pos[i]+=lang_flow4[i][f4(E[j-4],E[j-3],E[j-2],E[j-1],E[j])]*10000000001;
        }
        if(ansp<pos[i])ansp=pos[i],ans=i;
    }
    int lang=language(ans);
    for(int i=0;i<100;i++)
    {
        lang_freq[lang][E[i]]++;
        if(i>0)
        {
            lang_flow1[lang][f1(E[i-1],E[i])]++;
        }
        if(i>1)
        {
            lang_flow2[lang][f2(E[i-2],E[i-1],E[i])]++;
        }
      	if(i>2)
        {
          	lang_flow3[lang][f3(E[i-3],E[i-2],E[i-1],E[i])]++;
        }
       	if(i>3)
        {
          	lang_flow4[lang][f4(E[i-4],E[i-3],E[i-2],E[i-1],E[i])]++;
        }

    }
}
# Verdict Execution time Memory Grader output
1 Correct 3823 ms 84704 KB Output is correct
# Verdict Execution time Memory Grader output
1 Partially correct 3751 ms 84732 KB Output is partially correct - 78.08%