Submission #146331

# Submission time Handle Problem Language Result Execution time Memory
146331 2019-08-23T13:55:47 Z popovicirobert Languages (IOI10_languages) C++14
44 / 100
4492 ms 249192 KB
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long

using namespace std;

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

#define SZ 100

const int B = (int) 1e9 + 7;

unordered_map <ull, bool> mp[60];
bool vis[60];

inline ll myrand() {
    return (1LL * rand() << 15) + rand();
}

void excerpt(int *E) {
    int i, j;

    int id = -1;
    for(int len = 5; len >= 1 && id == -1; len--) {
        ull cur = 0, pw = 1;
        for(i = 1; i < len; i++) {
            pw *= B;
        }
        for(i = 0; i + len <= 100 && id == -1; i++) {
            cur = cur * B + E[i];
            if(i >= len - 1) {
                for(int j = 0; j < 56; j++) {
                    if(mp[j][cur]) {
                        id = j;
                        break;
                    }
                }
                cur -= pw * E[i - len + 1];
            }
        }
    }


    if(id == -1) {
        vector <int> ids;
        for(i = 0; i < 56; i++) {
            if(vis[i] == 0) ids.push_back(i);
        }
        int sz = ids.size();
        id = ids[myrand() % sz];
    }

    id = language(id);
    for(i = 0; i < 100; i++) {
        ull cur = 0;
        for(j = i; j < i + 5 && j < 100; j++) {
            cur = cur * B + E[j];
            mp[id][cur] = 1;
        }
    }
    vis[id] = 1;
}
# Verdict Execution time Memory Grader output
1 Correct 4467 ms 249192 KB Output is correct
# Verdict Execution time Memory Grader output
1 Partially correct 4492 ms 249168 KB Output is partially correct - 42.28%