#include <map>
#include <algorithm>
#include <vector>
#include "lang.h"
#include "grader.h"
using namespace std;
struct WD{
long long t1, t2;
void init(){
t1 = t2 = 0;
}
void addwd(int p, int pos){
if(pos == 0) t1 = p;
else t2 |= (1ll << (16 * (4 - pos))) * p;
}
};
bool operator<(WD a, WD b){
return a.t1 != b.t1 ? (a.t1 > b.t1) : (a.t2 > b.t2);
}
map<WD,int> mp;
const int l = 5;
void excerpt(int *E){
int cnt[105] = {};
vector<WD> v;
for (int i=0; i<96; i++) {
WD px;
px.init();
for (int j=0; j<l; j++) {
px.addwd(E[i+j],j);
}
map<WD,int> ::iterator it = mp.lower_bound(px);
if(it != mp.end()) cnt[(*it).second] += 100;
it = mp.upper_bound(px);
if(it != mp.end()) cnt[(*it).second] += 85;
if(it != mp.begin()) cnt[(*--it).second] += 100;
v.push_back(px);
}
int mv = (int)(max_element(cnt,cnt+56) - cnt);
int t = language(mv);
for (int i=0; i<v.size(); i++) {
mp[v[i]] = t;
}
}
Compilation message
lang.cpp: In function 'void excerpt(int*)':
lang.cpp:44:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i=0; i<v.size(); i++) {
~^~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1606 ms |
32288 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
1588 ms |
32416 KB |
Output is partially correct - 90.78% |