# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
39676 | smu201111192 | Languages (IOI10_languages) | C++14 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "grader.h"
#include "lang.h"
#include <cassert>
#include <stdio.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <vector>
#define N 100
using namespace std;
static char lang[20], lan[100][20];
static int lnum, i,j,k,n,nl, uni[N], right, tot;
const int MAXN = 56;
#define SZ 100
int prv1[MAXN][(1<<16)+1];
int prv2[MAXN][(1<<18)+1];
int prv3[MAXN][(1<<18)+1];
int prv4[MAXN][(1<<18)+1];
const long long mod2 = 79378;
long long hash1(int a){
assert(a>=0);
return a;
}
long long hash2(int a,int b){
long long ret = (hash1(a) << 16)| b;
assert(ret>=0);
return ret % mod2;
}
long long hash3(int a,int b,int c){
long long ret = (hash2(a,b)<<16) | c;
assert(ret>=0);
return ret % mod2;
}
long long hash4(int a,int b,int c,int d){
long long ret = (hash3(a,b,c)<<16) | d;
assert(ret>=0);
return ret % mod2;
}
void excerpt(int *E) {
vector<pair<int,int> > cand;
for(int j=0;j<MAXN;j++){
int t = 0;
for(int i=0;i<100;i++){
vector<int> vx;
for(int cnt = 0; cnt < 3; cnt ++){
if(i+cnt > 100)break;
vx.push_back(E[i+cnt]);
if(vx.size() == 1) t += prv1[j][hash1(vx[0])];
if(vx.size() == 2) t += prv2[j][hash2(vx[0],vx[1])];
if(vx.size() == 3) t += prv3[j][hash3(vx[0],vx[1],vx[2])];
//if(vx.size() == 4) t += prv4[j][hash4(vx[0],vx[1],vx[2],vx[3])];
}
}
cand.push_back(make_pair(t,j));
}
if(tot > 3000){
int abc=3;
}
sort(cand.begin(),cand.end());
int q = cand.back().second;
int ans = language(q);
for(int i=0;i<100;i++){
vector<int> vx;
for(int cnt = 0; cnt < 3; cnt ++){
if(i+cnt > 100)break;
vx.push_back(E[i+cnt]);
if(vx.size() == 1) (prv1[ans][hash1(vx[0])] = 1);
if(vx.size() == 2) (prv2[ans][hash2(vx[0],vx[1])] = 1);
if(vx.size() == 3) (prv3[ans][hash3(vx[0],vx[1],vx[2])] = 1);
//if(vx.size() == 4) (prv4[ans][hash4(vx[0],vx[1],vx[2],vx[3])] = 1);
}
}
}