Submission #39676

# Submission time Handle Problem Language Result Execution time Memory
39676 2018-01-17T06:04:39 Z smu201111192 Languages (IOI10_languages) C++14
Compilation error
0 ms 0 KB
#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);
        }
    }
}

Compilation message

lang.cpp: In function 'void excerpt(int*)':
lang.cpp:59:13: warning: unused variable 'abc' [-Wunused-variable]
         int abc=3;
             ^~~
lang.cpp:61:5: error: 'sort' was not declared in this scope
     sort(cand.begin(),cand.end());
     ^~~~
lang.cpp:61:5: note: suggested alternative: 'qsort'
     sort(cand.begin(),cand.end());
     ^~~~
     qsort
lang.cpp: At global scope:
lang.cpp:13:38: warning: 'right' defined but not used [-Wunused-variable]
 static int lnum, i,j,k,n,nl, uni[N], right, tot;
                                      ^~~~~
lang.cpp:13:30: warning: 'uni' defined but not used [-Wunused-variable]
 static int lnum, i,j,k,n,nl, uni[N], right, tot;
                              ^~~
lang.cpp:13:26: warning: 'nl' defined but not used [-Wunused-variable]
 static int lnum, i,j,k,n,nl, uni[N], right, tot;
                          ^~
lang.cpp:13:24: warning: 'n' defined but not used [-Wunused-variable]
 static int lnum, i,j,k,n,nl, uni[N], right, tot;
                        ^
lang.cpp:13:22: warning: 'k' defined but not used [-Wunused-variable]
 static int lnum, i,j,k,n,nl, uni[N], right, tot;
                      ^
lang.cpp:13:20: warning: 'j' defined but not used [-Wunused-variable]
 static int lnum, i,j,k,n,nl, uni[N], right, tot;
                    ^
lang.cpp:13:18: warning: 'i' defined but not used [-Wunused-variable]
 static int lnum, i,j,k,n,nl, uni[N], right, tot;
                  ^
lang.cpp:13:12: warning: 'lnum' defined but not used [-Wunused-variable]
 static int lnum, i,j,k,n,nl, uni[N], right, tot;
            ^~~~
lang.cpp:12:23: warning: 'lan' defined but not used [-Wunused-variable]
 static char lang[20], lan[100][20];
                       ^~~
lang.cpp:12:13: warning: 'lang' defined but not used [-Wunused-variable]
 static char lang[20], lan[100][20];
             ^~~~