#include <stdlib.h>
#include <stdio.h>
#include "grader.h"
#include "lang.h"
#include <bits/stdc++.h>
using namespace std;
const long long prime = 70207;
const long long mod = 1000000007;
long long probel, pows[200];
int COUNTER, symbols[100000];
map < long long, set < int > > langs;
void init(){
pows[0] = 1;
for( int i = 1; i < 111; i ++ ){
pows[i] = pows[i-1] * prime % mod;
}
}
long long shifr(vector < int > vc){
long long res = 0;
for( size_t i = 0; i < vc.size(); i ++ ){
res += pows[i] * vc[i];
res %= mod;
}
return res;
}
void excerpt(int*E){
COUNTER ++;
if( COUNTER == 1 )init();
for( int i = 0; i < 100; i ++ ){
symbols[E[i]]++;
if(symbols[E[i]] > symbols[probel])
probel = E[i];
}
vector < pair < long long, int > > wrds;
vector < int > wrd;
for( int i = 0; i < 100; i ++ ){
if( E[i] == probel ){
if( wrd.empty() == false ){
wrds.push_back({shifr(wrd), wrd.size()});
wrd.clear();
}
}
else{
wrd.push_back(E[i]);
}
}if( !wrd.empty())wrds.push_back({shifr(wrd), wrd.size()});
double cnt[100] = {};
for( auto [wrd,size]: wrds){
double app = 20.0*size/langs[wrd].size();
for( auto lang: langs[wrd] )
cnt[lang] += app;
}
vector < int > candidats;
int mx = 0;
for( int i = 0; i < 56; i ++ ){
if( cnt[i] > cnt[mx] ){
mx = i;
candidats.clear();
}
if( cnt[i] == cnt[mx] ){
candidats.push_back( i );
}
}
srand(time(0));
int res = language(candidats[rand()%candidats.size()]);
for( auto [wrd,size]: wrds ){
langs[wrd].insert(res);
}
//cout << "passed " << COUNTER << ' ' << wrd.size() << ' ' << probel << endl;
}
Compilation message
lang.cpp: In function 'void excerpt(int*)':
lang.cpp:72:21: warning: unused variable 'size' [-Wunused-variable]
for( auto [wrd,size]: wrds ){
^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
430 ms |
12412 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
744 ms |
12204 KB |
Output is partially correct - 82.24% |