#include <stdlib.h>
#include <stdio.h>
#include <bits/stdc++.h>
#include "grader.h"
#include "lang.h"
#define SZ 100
using namespace std;
int prevs[1100000];
map <int, map<int, int>> word_list;
static bool isInit = false;
void excerpt(int *E) {
if (!isInit) {
for (int i = 0; i <= 56; i++) {
word_list[i] = map<int, int>();
}
isInit = true;
}
map<int, int> mp;
map<int, int>::iterator it_mp = mp.begin();
for (int i = 1; i < SZ; i++) {
int bigram = E[i - 1] * 100000 + E[i];
mp[bigram]++;
}
int maxs = 0, guess_ans = 0;
map<int, map<int, int>>::iterator it = word_list.begin();
for (; it != word_list.end(); it++) {
int lang = it->first;
map<int, int> data = it->second;
int res = 0;
for (it_mp = mp.begin(); it_mp != mp.end(); it_mp++) {
int dt = it_mp->first;
int weight = it_mp->second;
if (data[dt] != NULL) {
res += data[dt] + weight;
}
else {
res += weight;
}
}
if (maxs < res) {
guess_ans = lang;
maxs = res;
}
}
int real_ans = language(guess_ans);
for (it_mp = mp.begin(); it_mp != mp.end(); it_mp++) {
map<int, int> tmp = word_list[real_ans];
word_list[real_ans][it_mp->first] += it_mp->second;
}
}
Compilation message
lang.cpp: In function 'void excerpt(int*)':
lang.cpp:42:20: warning: NULL used in arithmetic [-Wpointer-arith]
if (data[dt] != NULL) {
^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
10019 ms |
2772 KB |
Time limit exceeded |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
10029 ms |
2692 KB |
Time limit exceeded |