Submission #55639

# Submission time Handle Problem Language Result Execution time Memory
55639 2018-07-08T10:18:58 Z choyi0521 Languages (IOI10_languages) C++14
100 / 100
4780 ms 144292 KB
#include <stdlib.h>
#include <stdio.h>

#include "grader.h"
#include "lang.h"

#define SZ 100

int prev[1100000]; 
int ha[60][3][428957];
int htot[3][428957];
int cp(int* s, int l) {
    long long res = 0, mod = 428957;
    for (int i = 0; i < l; i++) {
        res = (res * 70000 + s[i]) % mod;
    }
    return (int)res;
}
int w[3] = { 1, 30, 90 };
void excerpt(int *E) {
    long long maxi = -1, ans = -1;
    for (int lan = 0; lan < 56; lan++) {
        long long res = 0;
        for (int i = 0; i < 3; i++) {
            long long s = 0;
            for (int j = 0; j < 100 - i; j++) {
                int h = cp(E + j, i + 1);
                if(htot[i][h]) s += 10000*ha[lan][i][h] / htot[i][h];
            }
            res += s*w[i];
        }
        if (res > maxi) {
            maxi = res;
            ans = lan;
        }
    }

    int re = language(ans);
    for (int i = 0; i < 3; i++) {
        long long s = 0;
        for (int j = 0; j < 100 - i; j++) {
            int p = cp(E + j, i + 1);
            ha[re][i][p]++;
            htot[i][p]++;
        }
    }
}

Compilation message

lang.cpp: In function 'void excerpt(int*)':
lang.cpp:40:19: warning: unused variable 's' [-Wunused-variable]
         long long s = 0;
                   ^
# Verdict Execution time Memory Grader output
1 Correct 4780 ms 144292 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4635 ms 144252 KB Output is correct - 91.06%