# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1011526 |
2024-06-30T14:57:15 Z |
awu |
Languages (IOI10_languages) |
C++14 |
|
2608 ms |
147924 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;
map<int, unordered_map<int, int>> chars;
map<array<int, 2>, unordered_map<int, int>> ngrams2;
map<array<int, 3>, unordered_map<int, int>> ngrams3;
map<array<int, 4>, unordered_map<int, int>> ngrams4;
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<int, 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<int, 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<int, 4> ngram;
for(int j = 0; j < 4; j++) {
ngram[j] = s[i + j];
}
for(auto p : ngrams4[ngram]) {
scores[p.first] += 16;
}
}
// 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<int, 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<int, 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<int, 4> ngram;
for(int j = 0; j < 4; j++) {
ngram[j] = s[i + j];
}
ngrams4[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:18:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
18 | for(int i = 0; i < s.size(); i++) {
| ~~^~~~~~~~~~
lang.cpp:23:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
23 | for(int i = 0; i < s.size() - 1; i++) {
| ~~^~~~~~~~~~~~~~
lang.cpp:32:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
32 | for(int i = 0; i < s.size() - 2; i++) {
| ~~^~~~~~~~~~~~~~
lang.cpp:41:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
41 | for(int i = 0; i < s.size() - 3; i++) {
| ~~^~~~~~~~~~~~~~
lang.cpp: In function 'void process(int, std::vector<int>)':
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(); i++) {
| ~~^~~~~~~~~~
lang.cpp:57:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
57 | for(int i = 0; i < s.size() - 1; i++) {
| ~~^~~~~~~~~~~~~~
lang.cpp:64:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
64 | for(int i = 0; i < s.size() - 2; i++) {
| ~~^~~~~~~~~~~~~~
lang.cpp:71:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
71 | for(int i = 0; i < s.size() - 3; i++) {
| ~~^~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2607 ms |
147832 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
2608 ms |
147924 KB |
Output is partially correct - 90.59% |