답안 #402499

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
402499 2021-05-11T19:23:30 Z IloveN Languages (IOI10_languages) C++14
98 / 100
5875 ms 112420 KB
#include<bits/stdc++.h>
#include "grader.h"

using namespace std;
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define all(vr) vr.begin(),vr.end()
#define vi vector<int>
#define vll vector<ll>
namespace myrand
{
    mt19937 mt(chrono::system_clock::now().time_since_epoch() / chrono::microseconds(1));
    ll Int(ll l,ll r) {return uniform_int_distribution<ll> (l,r)(mt);}
}

using namespace myrand;
const int N = 1e5 + 10;
const int Hmod = (1 << 31) - 1;
int base = 1e6 + 9, cnt = 0;

unordered_set<int> word[60];

int add(ll x, int y)
{
    x = x * base + y + 1;
    x = (x & Hmod) + (x >> 31);
    x = (x & Hmod) + (x >> 31);
    return x - 1;
}

void init()
{
    for (int i = 0; i <= 55; ++i) word[i].max_load_factor(0.25);
}

void excerpt(int E[])
{
    ll id = 0, mx = -1;
    for (int i = 0; i <= 55; ++i)
    {
        ll score = 0;
        int h = 0;
        for (int j = 0; j < 100; ++j)
        {
            int r = j;
            h = E[j];
            if (word[i].count(h) == 0) continue;
            while (r < 99 && word[i].count(h))
                h = add(h, E[++r]);
            if (word[i].count(h)) r++;
            score += (r - j) * (r - j);
            j = r - 1;
        }
        if (score > mx) id = i, mx = score;
    }
    id = language(id);
    if (cnt == 0) init();
    cnt++;
    //if (cnt > 8e3) return;
    for (int i = 0; i < 100; ++i)
    {
        int h = 0;
        for (int j = i; j < min(100, i + 5); ++j)
        {
            h = add(h, E[j]);
            word[id].insert(h);
        }
    }
}

/*int main()
{
    //freopen("ss.inp", "r", stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);
    return 0;
}*/

Compilation message

lang.cpp:24:28: warning: integer overflow in expression of type 'int' results in '2147483647' [-Woverflow]
   24 | const int Hmod = (1 << 31) - 1;
      |                  ~~~~~~~~~~^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 5758 ms 112380 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 5875 ms 112420 KB Output is partially correct - 89.52%