Submission #69054

#TimeUsernameProblemLanguageResultExecution timeMemory
69054mhs4670Languages (IOI10_languages)C11
94 / 100
1032 ms22316 KiB
#if 01 #include <stdlib.h> #include <stdio.h> #include "grader.h" #include "lang.h" #define SZ 100 #define M (100003) #define LANG (56) #define P (65537) typedef long long ll; const int roll = 3; ll save[SZ + 1]; //int cnt[LANG][P]; int hcnt[LANG][M]; int vote[LANG]; ll hash(int *E){ ll hash_value = 0; ll p_pow = 1; for (int i = 0; i < roll; i++){ hash_value = (hash_value + E[i] * p_pow) % M; p_pow = (p_pow*P) % M; } return hash_value; } void excerpt(int *E) { for (int i = 0; i < SZ - roll + 1; i++){ save[i] = hash(E + i); } for (int i = 0; i < LANG; i++){ vote[i] = 0; for (int j = 0; j < SZ; j++){ //if (cnt[i][E[j]])vote[i]++; if (i < SZ - roll + 1) if (hcnt[i][save[j]])vote[i]++; } } int guess = 0, max = 0; for (int i = 0; i < LANG; i++){ if (max < vote[i])guess = i, max = vote[i]; } int ans = language(guess); for (int i = 0; i < SZ; i++){ //cnt[ans][i]++; if (i<SZ - roll + 1) hcnt[ans][save[i]]++; } } #endif
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...