제출 #1327051

#제출 시각아이디문제언어결과실행 시간메모리
1327051minh30082008Languages (IOI10_languages)C++20
99 / 100
1904 ms150012 KiB
#include "grader.h"
#include<bits/stdc++.h>
#define fi first
#define se second
#define FOR(i, k, n) for(int i = k; i <= n; i++)
#define FOR1(i, k, n) for(int i = k; i >= n; i--)
#define pb push_back
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vi vector<int>
#define pii pair<int, int>
#define vii vector<pii>
#define ll long long
#define vll vector<ll>
#define pll pair<ll, ll>
#define re return 0
#define mii map<int, int>
#define input "wtf.inp"
#define output "wtf.out"
#define rf 	freopen(input, "r", stdin); freopen(output, "w", stdout)
using namespace std;
const int maxn = 2e5 + 5;
const int mod = 1e9 + 19972207;
const int base = 65537;
const int base1 = 31;
const int SZ = 320;
const ll INF = 1e18;
const long double EPS = 1e-9;
void add(int &a, int b) 
{
	a += b; 
	if(a >= mod) a -= mod; 
	if(a < 0) a += mod; 
}
mt19937 rd(chrono::steady_clock::now().time_since_epoch().count());
int randint(int l, int r)
{
	return uniform_int_distribution<int>(l, r) (rd);
}
double rand(double l, double r)
{
	return uniform_real_distribution<double>(l, r) (rd);
}
const int MOD = 249989;
int cnt[60][4][MOD];
ll val[60];
int cost[5] = {0, 1, 3, 6, 9};
void excerpt(int *a)
{
	FOR(i, 0, 55)
		val[i] = 0;
	FOR(i, 0, 96)
	{
		FOR(k, 1, 4)
		{
			ll res = 0;
			FOR(j, i, i + k - 1)
				res = (res * base + a[j]) % MOD;
			FOR(t, 0, 55)
				val[t] += min(k / 2, cnt[t][k - 1][res]) * cost[k];
		}
	}
	int ask = 0;
	FOR(i, 0, 55)
		if(val[i] > val[ask])
			ask = i;
	int kq = language(ask);
	FOR(i, 0, 96)
	{
		FOR(k, 1, 4)
		{
			ll res = 0;
			FOR(j, i, i + k - 1)
				res = (res * base + a[j]) % MOD;
			cnt[kq][k - 1][res]++;
		}
	}
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...