답안 #1011538

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1011538 2024-06-30T15:08:11 Z awu Languages (IOI10_languages) C++14
0 / 100
3038 ms 262148 KB
// This is a complete and utter mess
#include <bits/extc++.h>
using namespace std;
#define unordered_map __gnu_pbds::gp_hash_table

#include "grader.h"
#include "lang.h"

int cnt = 0;

#define int unsigned short
map<int, unordered_map<int8_t, int>> chars;
map<array<unsigned short, 2>, unordered_map<int8_t, int>> ngrams2;
map<array<unsigned short, 3>, unordered_map<int8_t, int>> ngrams3;
map<array<unsigned short, 4>, unordered_map<int8_t, int>> ngrams4;
map<array<unsigned short, 5>, unordered_map<int8_t, int>> ngrams5;
map<array<unsigned short, 6>, unordered_map<int8_t, int>> ngrams6;
#undef int
int guess(vector<int> s) {
  if(cnt == 0) return rand() % 56;
  vector<double> scores(56);
  for(int i = 0; i < s.size(); i++) {
    for(auto p : chars[s[i]]) {
      scores[p.first] += 30;
    }
  }
  for(int i = 0; i < s.size() - 1; i++) {
    array<unsigned short, 2> ngram;
    for(int j = 0; j < 2; j++) {
      ngram[j] = s[i + j];
    }
    for(auto p : ngrams2[ngram]) {
      scores[p.first] += 13;
    }
  }
  for(int i = 0; i < s.size() - 2; i++) {
    array<unsigned short, 3> ngram;
    for(int j = 0; j < 3; j++) {
      ngram[j] = s[i + j];
    }
    for(auto p : ngrams3[ngram]) {
      scores[p.first] += 13;
    }
  }
  for(int i = 0; i < s.size() - 3; i++) {
    array<unsigned short, 4> ngram;
    for(int j = 0; j < 4; j++) {
      ngram[j] = s[i + j];
    }
    for(auto p : ngrams4[ngram]) {
      scores[p.first] += 16;
    }
  }
  for(int i = 0; i < s.size() - 4; i++) {
    array<unsigned short, 5> ngram;
    for(int j = 0; j < 5; j++) {
      ngram[j] = s[i + j];
    }
    for(auto p : ngrams5[ngram]) {
      scores[p.first] += 20;
    }
  }
  for(int i = 0; i < s.size() - 5; i++) {
    array<unsigned short, 6> ngram;
    for(int j = 0; j < 6; j++) {
      ngram[j] = s[i + j];
    }
    for(auto p : ngrams6[ngram]) {
      scores[p.first] += 21;
    }
  }
  // cout << "Max score: " << *max_element(scores.begin(), scores.end()) << endl;
  return max_element(scores.begin(), scores.end()) - scores.begin();
}
void process(int lang, vector<int> s) {
  for(int i = 0; i < s.size(); i++) {
    chars[s[i]][lang]++;
  }
  for(int i = 0; i < s.size() - 1; i++) {
    array<unsigned short, 2> ngram;
    for(int j = 0; j < 2; j++) {
      ngram[j] = s[i + j];
    }
    ngrams2[ngram][lang]++;
  }
  for(int i = 0; i < s.size() - 2; i++) {
    array<unsigned short, 3> ngram;
    for(int j = 0; j < 3; j++) {
      ngram[j] = s[i + j];
    }
    ngrams3[ngram][lang]++;
  }
  for(int i = 0; i < s.size() - 3; i++) {
    array<unsigned short, 4> ngram;
    for(int j = 0; j < 4; j++) {
      ngram[j] = s[i + j];
    }
    ngrams4[ngram][lang]++;
  }
  for(int i = 0; i < s.size() - 4; i++) {
    array<unsigned short, 5> ngram;
    for(int j = 0; j < 5; j++) {
      ngram[j] = s[i + j];
    }
    ngrams5[ngram][lang]++;
  }
  for(int i = 0; i < s.size() - 5; i++) {
    array<unsigned short, 6> ngram;
    for(int j = 0; j < 6; j++) {
      ngram[j] = s[i + j];
    }
    ngrams6[ngram][lang]++;
  }
  cnt++;
}
void excerpt(int *E) {
  vector<int> e(E, E + 100);
  process(language(guess(e)), e);
}

Compilation message

lang.cpp: In function 'int guess(std::vector<int>)':
lang.cpp:22:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |   for(int i = 0; i < s.size(); i++) {
      |                  ~~^~~~~~~~~~
lang.cpp:27:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |   for(int i = 0; i < s.size() - 1; i++) {
      |                  ~~^~~~~~~~~~~~~~
lang.cpp:36:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |   for(int i = 0; i < s.size() - 2; i++) {
      |                  ~~^~~~~~~~~~~~~~
lang.cpp:45:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |   for(int i = 0; i < s.size() - 3; i++) {
      |                  ~~^~~~~~~~~~~~~~
lang.cpp:54:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   54 |   for(int i = 0; i < s.size() - 4; i++) {
      |                  ~~^~~~~~~~~~~~~~
lang.cpp:63:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   63 |   for(int i = 0; i < s.size() - 5; i++) {
      |                  ~~^~~~~~~~~~~~~~
lang.cpp: In function 'void process(int, std::vector<int>)':
lang.cpp:76:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   76 |   for(int i = 0; i < s.size(); i++) {
      |                  ~~^~~~~~~~~~
lang.cpp:79:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   79 |   for(int i = 0; i < s.size() - 1; i++) {
      |                  ~~^~~~~~~~~~~~~~
lang.cpp:86:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   86 |   for(int i = 0; i < s.size() - 2; i++) {
      |                  ~~^~~~~~~~~~~~~~
lang.cpp:93:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   93 |   for(int i = 0; i < s.size() - 3; i++) {
      |                  ~~^~~~~~~~~~~~~~
lang.cpp:100:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  100 |   for(int i = 0; i < s.size() - 4; i++) {
      |                  ~~^~~~~~~~~~~~~~
lang.cpp:107:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  107 |   for(int i = 0; i < s.size() - 5; i++) {
      |                  ~~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 3030 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 3038 ms 262148 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -