답안 #39678

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
39678 2018-01-17T06:05:54 Z smu201111192 Languages (IOI10_languages) C++14
82 / 100
8262 ms 20504 KB
#include "grader.h"
#include "lang.h"
#include <algorithm>
#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 < 2; 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 < 2; 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:60:13: warning: unused variable 'abc' [-Wunused-variable]
         int abc=3;
             ^~~
lang.cpp: At global scope:
lang.cpp:14:38: warning: 'right' defined but not used [-Wunused-variable]
 static int lnum, i,j,k,n,nl, uni[N], right, tot;
                                      ^~~~~
lang.cpp:14:30: warning: 'uni' defined but not used [-Wunused-variable]
 static int lnum, i,j,k,n,nl, uni[N], right, tot;
                              ^~~
lang.cpp:14:26: warning: 'nl' defined but not used [-Wunused-variable]
 static int lnum, i,j,k,n,nl, uni[N], right, tot;
                          ^~
lang.cpp:14:24: warning: 'n' defined but not used [-Wunused-variable]
 static int lnum, i,j,k,n,nl, uni[N], right, tot;
                        ^
lang.cpp:14:22: warning: 'k' defined but not used [-Wunused-variable]
 static int lnum, i,j,k,n,nl, uni[N], right, tot;
                      ^
lang.cpp:14:20: warning: 'j' defined but not used [-Wunused-variable]
 static int lnum, i,j,k,n,nl, uni[N], right, tot;
                    ^
lang.cpp:14:18: warning: 'i' defined but not used [-Wunused-variable]
 static int lnum, i,j,k,n,nl, uni[N], right, tot;
                  ^
lang.cpp:14:12: warning: 'lnum' defined but not used [-Wunused-variable]
 static int lnum, i,j,k,n,nl, uni[N], right, tot;
            ^~~~
lang.cpp:13:23: warning: 'lan' defined but not used [-Wunused-variable]
 static char lang[20], lan[100][20];
                       ^~~
lang.cpp:13:13: warning: 'lang' defined but not used [-Wunused-variable]
 static char lang[20], lan[100][20];
             ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 8262 ms 20432 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 8070 ms 20504 KB Output is partially correct - 75.78%