답안 #869926

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
869926 2023-11-06T10:42:03 Z Matjaz Languages (IOI10_languages) C++14
30 / 100
10000 ms 41360 KB
#include <stdlib.h>
#include <stdio.h>
#include <set>
#include <vector>
#include <algorithm>
#include <unordered_set>
using namespace std;
 
#include "grader.h"
#include "lang.h"
 
#define SZ 100
 
unordered_set<int> S[56];
int L = 56;
 
void excerpt(int *E) {
    
    vector<int> sample;
    long long a = 719;
    long long b = 479001599;
    
    for (int l=1;l<=4;l++){
        for (int i=0;i<100 - l + 1;i++){
            int hash = 0;
            for (int j=0;j<l;j++){
                hash = (hash * a + E[i + j]) % b;
            }
            sample.push_back(hash);
        }
    }
    
    
    int best_score = 0;
    int best_guess = 0;
    
    for (int i=0;i<L;i++){
        
        int score = 0;
        for (int j=0;j<sample.size();j++) score += S[i].count(sample[j]);
        
        if (best_score < score){
            best_score = score;
            best_guess = i;
        }
    }
    
    int target = language(best_guess);
    
    S[target].insert(sample.begin(), sample.end());
}

Compilation message

lang.cpp: In function 'void excerpt(int*)':
lang.cpp:40:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |         for (int j=0;j<sample.size();j++) score += S[i].count(sample[j]);
      |                      ~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 9799 ms 41360 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 10034 ms 40860 KB Time limit exceeded
2 Halted 0 ms 0 KB -