Submission #51704

#TimeUsernameProblemLanguageResultExecution timeMemory
51704tjd229Languages (IOI10_languages)C++11
98 / 100
9163 ms24880 KiB
#include <stdlib.h> #include <stdio.h> #include <stdarg.h> #include <unordered_map> #include "grader.h" #include "lang.h" #define ll long long #define SZ 100 //length #define MAXL 56 using namespace std; const int uni = 1 << 16; static int lnum = -1; int cnt[MAXL]; int cnt1[MAXL][uni + 1]; unordered_map<ll, int> cnt2[MAXL], cnt3[MAXL]; unordered_map<ll, int> cnt4[MAXL]; ll hash_func(int n, ...){ va_list li; va_start(li, n); ll res = 0; for (int i = 0; i < n; i++){ res <<= 16; res += va_arg(li, int); } va_end(li); return res; } void excerpt(int *E) { int i, j; double mx = 0; int l = 0; for (i = 0; i <= lnum; i++){ double val = 0; for (j = 0; j < SZ; j++){ ll h = hash_func(1, E[j]); val += cnt1[i][h]; //if (cnt1[i].find(h) != cnt1[i].end()) val +=cnt1[i][h] *1; } for (j = 3; j < SZ; j++){ ll h = hash_func(4, E[j - 3], E[j - 2], E[j - 1], E[j]); if (cnt4[i].find(h) != cnt4[i].end()) val += cnt4[i][h] * 90; //else hist4.push_back(h); } if (mx < val){ mx = val; l = i; } } int ans = language(l); //printf("%d,%f,%d\n", l, mx, ans); if (ans > lnum) lnum = ans; for (i = 0; i < SZ; i++){ ll h = hash_func(1, E[i]); cnt1[ans][h] = 1; //if (cnt1[ans].find(h) == cnt1[ans].end()) cnt1[ans][h] = 1; //else cnt1[ans][h]++; } for (i = 3; i < SZ; i++){ ll h = hash_func(4, E[i - 3], E[i - 2], E[i - 1], E[i]); if (cnt4[ans].find(h) == cnt4[ans].end()) cnt4[ans][h] = 1; //else cnt3[ans][h]++; } cnt[ans]++; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...