QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#643608 | #6. 玛里苟斯 | maspy | 100 ✓ | 39ms | 4132kb | C++20 | 18.2kb | 2024-10-15 22:18:05 | 2024-10-15 22:18:07 |
Judging History
answer
#line 1 "/home/maspy/compro/library/my_template.hpp"
#if defined(LOCAL)
#include <my_template_compiled.hpp>
#else
// https://codeforces.com/blog/entry/96344
#pragma GCC optimize("Ofast,unroll-loops")
// いまの CF だとこれ入れると動かない?
// #pragma GCC target("avx2,popcnt")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i128 = __int128;
using u128 = unsigned __int128;
using f128 = __float128;
template <class T>
constexpr T infty = 0;
template <>
constexpr int infty<int> = 1'010'000'000;
template <>
constexpr ll infty<ll> = 2'020'000'000'000'000'000;
template <>
constexpr u32 infty<u32> = infty<int>;
template <>
constexpr u64 infty<u64> = infty<ll>;
template <>
constexpr i128 infty<i128> = i128(infty<ll>) * 2'000'000'000'000'000'000;
template <>
constexpr double infty<double> = infty<ll>;
template <>
constexpr long double infty<long double> = infty<ll>;
using pi = pair<ll, ll>;
using vi = vector<ll>;
template <class T>
using vc = vector<T>;
template <class T>
using vvc = vector<vc<T>>;
template <class T>
using vvvc = vector<vvc<T>>;
template <class T>
using vvvvc = vector<vvvc<T>>;
template <class T>
using vvvvvc = vector<vvvvc<T>>;
template <class T>
using pq = priority_queue<T>;
template <class T>
using pqg = priority_queue<T, vector<T>, greater<T>>;
#define vv(type, name, h, ...) vector<vector<type>> name(h, vector<type>(__VA_ARGS__))
#define vvv(type, name, h, w, ...) vector<vector<vector<type>>> name(h, vector<vector<type>>(w, vector<type>(__VA_ARGS__)))
#define vvvv(type, name, a, b, c, ...) \
vector<vector<vector<vector<type>>>> name(a, vector<vector<vector<type>>>(b, vector<vector<type>>(c, vector<type>(__VA_ARGS__))))
// https://trap.jp/post/1224/
#define FOR1(a) for (ll _ = 0; _ < ll(a); ++_)
#define FOR2(i, a) for (ll i = 0; i < ll(a); ++i)
#define FOR3(i, a, b) for (ll i = a; i < ll(b); ++i)
#define FOR4(i, a, b, c) for (ll i = a; i < ll(b); i += (c))
#define FOR1_R(a) for (ll i = (a)-1; i >= ll(0); --i)
#define FOR2_R(i, a) for (ll i = (a)-1; i >= ll(0); --i)
#define FOR3_R(i, a, b) for (ll i = (b)-1; i >= ll(a); --i)
#define overload4(a, b, c, d, e, ...) e
#define overload3(a, b, c, d, ...) d
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FOR_R(...) overload3(__VA_ARGS__, FOR3_R, FOR2_R, FOR1_R)(__VA_ARGS__)
#define FOR_subset(t, s) for (ll t = (s); t >= 0; t = (t == 0 ? -1 : (t - 1) & (s)))
#define all(x) x.begin(), x.end()
#define len(x) ll(x.size())
#define elif else if
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define stoi stoll
int popcnt(int x) { return __builtin_popcount(x); }
int popcnt(u32 x) { return __builtin_popcount(x); }
int popcnt(ll x) { return __builtin_popcountll(x); }
int popcnt(u64 x) { return __builtin_popcountll(x); }
int popcnt_mod_2(int x) { return __builtin_parity(x); }
int popcnt_mod_2(u32 x) { return __builtin_parity(x); }
int popcnt_mod_2(ll x) { return __builtin_parityll(x); }
int popcnt_mod_2(u64 x) { return __builtin_parityll(x); }
// (0, 1, 2, 3, 4) -> (-1, 0, 1, 1, 2)
int topbit(int x) { return (x == 0 ? -1 : 31 - __builtin_clz(x)); }
int topbit(u32 x) { return (x == 0 ? -1 : 31 - __builtin_clz(x)); }
int topbit(ll x) { return (x == 0 ? -1 : 63 - __builtin_clzll(x)); }
int topbit(u64 x) { return (x == 0 ? -1 : 63 - __builtin_clzll(x)); }
// (0, 1, 2, 3, 4) -> (-1, 0, 1, 0, 2)
int lowbit(int x) { return (x == 0 ? -1 : __builtin_ctz(x)); }
int lowbit(u32 x) { return (x == 0 ? -1 : __builtin_ctz(x)); }
int lowbit(ll x) { return (x == 0 ? -1 : __builtin_ctzll(x)); }
int lowbit(u64 x) { return (x == 0 ? -1 : __builtin_ctzll(x)); }
template <typename T>
T floor(T a, T b) {
return a / b - (a % b && (a ^ b) < 0);
}
template <typename T>
T ceil(T x, T y) {
return floor(x + y - 1, y);
}
template <typename T>
T bmod(T x, T y) {
return x - y * floor(x, y);
}
template <typename T>
pair<T, T> divmod(T x, T y) {
T q = floor(x, y);
return {q, x - q * y};
}
template <typename T, typename U>
T SUM(const vector<U> &A) {
T sm = 0;
for (auto &&a: A) sm += a;
return sm;
}
#define MIN(v) *min_element(all(v))
#define MAX(v) *max_element(all(v))
#define LB(c, x) distance((c).begin(), lower_bound(all(c), (x)))
#define UB(c, x) distance((c).begin(), upper_bound(all(c), (x)))
#define UNIQUE(x) sort(all(x)), x.erase(unique(all(x)), x.end()), x.shrink_to_fit()
template <typename T>
T POP(deque<T> &que) {
T a = que.front();
que.pop_front();
return a;
}
template <typename T>
T POP(pq<T> &que) {
T a = que.top();
que.pop();
return a;
}
template <typename T>
T POP(pqg<T> &que) {
T a = que.top();
que.pop();
return a;
}
template <typename T>
T POP(vc<T> &que) {
T a = que.back();
que.pop_back();
return a;
}
template <typename F>
ll binary_search(F check, ll ok, ll ng, bool check_ok = true) {
if (check_ok) assert(check(ok));
while (abs(ok - ng) > 1) {
auto x = (ng + ok) / 2;
(check(x) ? ok : ng) = x;
}
return ok;
}
template <typename F>
double binary_search_real(F check, double ok, double ng, int iter = 100) {
FOR(iter) {
double x = (ok + ng) / 2;
(check(x) ? ok : ng) = x;
}
return (ok + ng) / 2;
}
template <class T, class S>
inline bool chmax(T &a, const S &b) {
return (a < b ? a = b, 1 : 0);
}
template <class T, class S>
inline bool chmin(T &a, const S &b) {
return (a > b ? a = b, 1 : 0);
}
// ? は -1
vc<int> s_to_vi(const string &S, char first_char) {
vc<int> A(S.size());
FOR(i, S.size()) { A[i] = (S[i] != '?' ? S[i] - first_char : -1); }
return A;
}
template <typename T, typename U>
vector<T> cumsum(vector<U> &A, int off = 1) {
int N = A.size();
vector<T> B(N + 1);
FOR(i, N) { B[i + 1] = B[i] + A[i]; }
if (off == 0) B.erase(B.begin());
return B;
}
// stable sort
template <typename T>
vector<int> argsort(const vector<T> &A) {
vector<int> ids(len(A));
iota(all(ids), 0);
sort(all(ids), [&](int i, int j) { return (A[i] == A[j] ? i < j : A[i] < A[j]); });
return ids;
}
// A[I[0]], A[I[1]], ...
template <typename T>
vc<T> rearrange(const vc<T> &A, const vc<int> &I) {
vc<T> B(len(I));
FOR(i, len(I)) B[i] = A[I[i]];
return B;
}
template <typename T, typename... Vectors>
void concat(vc<T> &first, const Vectors &... others) {
vc<T> &res = first;
(res.insert(res.end(), others.begin(), others.end()), ...);
}
#endif
#line 1 "/home/maspy/compro/library/other/io.hpp"
#define FASTIO
#include <unistd.h>
// https://judge.yosupo.jp/submission/21623
namespace fastio {
static constexpr uint32_t SZ = 1 << 17;
char ibuf[SZ];
char obuf[SZ];
char out[100];
// pointer of ibuf, obuf
uint32_t pil = 0, pir = 0, por = 0;
struct Pre {
char num[10000][4];
constexpr Pre() : num() {
for (int i = 0; i < 10000; i++) {
int n = i;
for (int j = 3; j >= 0; j--) {
num[i][j] = n % 10 | '0';
n /= 10;
}
}
}
} constexpr pre;
inline void load() {
memcpy(ibuf, ibuf + pil, pir - pil);
pir = pir - pil + fread(ibuf + pir - pil, 1, SZ - pir + pil, stdin);
pil = 0;
if (pir < SZ) ibuf[pir++] = '\n';
}
inline void flush() {
fwrite(obuf, 1, por, stdout);
por = 0;
}
void rd(char &c) {
do {
if (pil + 1 > pir) load();
c = ibuf[pil++];
} while (isspace(c));
}
void rd(string &x) {
x.clear();
char c;
do {
if (pil + 1 > pir) load();
c = ibuf[pil++];
} while (isspace(c));
do {
x += c;
if (pil == pir) load();
c = ibuf[pil++];
} while (!isspace(c));
}
template <typename T>
void rd_real(T &x) {
string s;
rd(s);
x = stod(s);
}
template <typename T>
void rd_integer(T &x) {
if (pil + 100 > pir) load();
char c;
do
c = ibuf[pil++];
while (c < '-');
bool minus = 0;
if constexpr (is_signed<T>::value || is_same_v<T, i128>) {
if (c == '-') { minus = 1, c = ibuf[pil++]; }
}
x = 0;
while ('0' <= c) { x = x * 10 + (c & 15), c = ibuf[pil++]; }
if constexpr (is_signed<T>::value || is_same_v<T, i128>) {
if (minus) x = -x;
}
}
void rd(int &x) { rd_integer(x); }
void rd(ll &x) { rd_integer(x); }
void rd(i128 &x) { rd_integer(x); }
void rd(u32 &x) { rd_integer(x); }
void rd(u64 &x) { rd_integer(x); }
void rd(u128 &x) { rd_integer(x); }
void rd(double &x) { rd_real(x); }
void rd(long double &x) { rd_real(x); }
void rd(f128 &x) { rd_real(x); }
template <class T, class U>
void rd(pair<T, U> &p) {
return rd(p.first), rd(p.second);
}
template <size_t N = 0, typename T>
void rd_tuple(T &t) {
if constexpr (N < std::tuple_size<T>::value) {
auto &x = std::get<N>(t);
rd(x);
rd_tuple<N + 1>(t);
}
}
template <class... T>
void rd(tuple<T...> &tpl) {
rd_tuple(tpl);
}
template <size_t N = 0, typename T>
void rd(array<T, N> &x) {
for (auto &d: x) rd(d);
}
template <class T>
void rd(vc<T> &x) {
for (auto &d: x) rd(d);
}
void read() {}
template <class H, class... T>
void read(H &h, T &... t) {
rd(h), read(t...);
}
void wt(const char c) {
if (por == SZ) flush();
obuf[por++] = c;
}
void wt(const string s) {
for (char c: s) wt(c);
}
void wt(const char *s) {
size_t len = strlen(s);
for (size_t i = 0; i < len; i++) wt(s[i]);
}
template <typename T>
void wt_integer(T x) {
if (por > SZ - 100) flush();
if (x < 0) { obuf[por++] = '-', x = -x; }
int outi;
for (outi = 96; x >= 10000; outi -= 4) {
memcpy(out + outi, pre.num[x % 10000], 4);
x /= 10000;
}
if (x >= 1000) {
memcpy(obuf + por, pre.num[x], 4);
por += 4;
} else if (x >= 100) {
memcpy(obuf + por, pre.num[x] + 1, 3);
por += 3;
} else if (x >= 10) {
int q = (x * 103) >> 10;
obuf[por] = q | '0';
obuf[por + 1] = (x - q * 10) | '0';
por += 2;
} else
obuf[por++] = x | '0';
memcpy(obuf + por, out + outi + 4, 96 - outi);
por += 96 - outi;
}
template <typename T>
void wt_real(T x) {
ostringstream oss;
oss << fixed << setprecision(15) << double(x);
string s = oss.str();
wt(s);
}
void wt(int x) { wt_integer(x); }
void wt(ll x) { wt_integer(x); }
void wt(i128 x) { wt_integer(x); }
void wt(u32 x) { wt_integer(x); }
void wt(u64 x) { wt_integer(x); }
void wt(u128 x) { wt_integer(x); }
void wt(double x) { wt_real(x); }
void wt(long double x) { wt_real(x); }
void wt(f128 x) { wt_real(x); }
template <class T, class U>
void wt(const pair<T, U> val) {
wt(val.first);
wt(' ');
wt(val.second);
}
template <size_t N = 0, typename T>
void wt_tuple(const T t) {
if constexpr (N < std::tuple_size<T>::value) {
if constexpr (N > 0) { wt(' '); }
const auto x = std::get<N>(t);
wt(x);
wt_tuple<N + 1>(t);
}
}
template <class... T>
void wt(tuple<T...> tpl) {
wt_tuple(tpl);
}
template <class T, size_t S>
void wt(const array<T, S> val) {
auto n = val.size();
for (size_t i = 0; i < n; i++) {
if (i) wt(' ');
wt(val[i]);
}
}
template <class T>
void wt(const vector<T> val) {
auto n = val.size();
for (size_t i = 0; i < n; i++) {
if (i) wt(' ');
wt(val[i]);
}
}
void print() { wt('\n'); }
template <class Head, class... Tail>
void print(Head &&head, Tail &&... tail) {
wt(head);
if (sizeof...(Tail)) wt(' ');
print(forward<Tail>(tail)...);
}
// gcc expansion. called automaticall after main.
void __attribute__((destructor)) _d() { flush(); }
} // namespace fastio
using fastio::read;
using fastio::print;
using fastio::flush;
#if defined(LOCAL)
#define SHOW(...) SHOW_IMPL(__VA_ARGS__, SHOW6, SHOW5, SHOW4, SHOW3, SHOW2, SHOW1)(__VA_ARGS__)
#define SHOW_IMPL(_1, _2, _3, _4, _5, _6, NAME, ...) NAME
#define SHOW1(x) print(#x, "=", (x)), flush()
#define SHOW2(x, y) print(#x, "=", (x), #y, "=", (y)), flush()
#define SHOW3(x, y, z) print(#x, "=", (x), #y, "=", (y), #z, "=", (z)), flush()
#define SHOW4(x, y, z, w) print(#x, "=", (x), #y, "=", (y), #z, "=", (z), #w, "=", (w)), flush()
#define SHOW5(x, y, z, w, v) print(#x, "=", (x), #y, "=", (y), #z, "=", (z), #w, "=", (w), #v, "=", (v)), flush()
#define SHOW6(x, y, z, w, v, u) print(#x, "=", (x), #y, "=", (y), #z, "=", (z), #w, "=", (w), #v, "=", (v), #u, "=", (u)), flush()
#else
#define SHOW(...)
#endif
#define INT(...) \
int __VA_ARGS__; \
read(__VA_ARGS__)
#define LL(...) \
ll __VA_ARGS__; \
read(__VA_ARGS__)
#define U32(...) \
u32 __VA_ARGS__; \
read(__VA_ARGS__)
#define U64(...) \
u64 __VA_ARGS__; \
read(__VA_ARGS__)
#define STR(...) \
string __VA_ARGS__; \
read(__VA_ARGS__)
#define CHAR(...) \
char __VA_ARGS__; \
read(__VA_ARGS__)
#define DBL(...) \
double __VA_ARGS__; \
read(__VA_ARGS__)
#define VEC(type, name, size) \
vector<type> name(size); \
read(name)
#define VV(type, name, h, w) \
vector<vector<type>> name(h, vector<type>(w)); \
read(name)
void YES(bool t = 1) { print(t ? "YES" : "NO"); }
void NO(bool t = 1) { YES(!t); }
void Yes(bool t = 1) { print(t ? "Yes" : "No"); }
void No(bool t = 1) { Yes(!t); }
void yes(bool t = 1) { print(t ? "yes" : "no"); }
void no(bool t = 1) { yes(!t); }
#line 3 "main.cpp"
#line 2 "/home/maspy/compro/library/linalg/xor/transpose.hpp"
// n x m 行列の transpose。O((n+m)log(n+m)) 時間。
// https://github.com/dsnet/matrix-transpose
template <typename UINT>
vc<UINT> transpose(int n, int m, vc<UINT>& A, bool keep_A = 1) {
assert(max(n, m) <= numeric_limits<UINT>::digits);
assert(len(A) == n);
vc<UINT> tmp;
if (keep_A) tmp = A;
int LOG = 0;
while ((1 << LOG) < max(n, m)) ++LOG;
A.resize(1 << LOG);
int width = 1 << LOG;
UINT mask = 1;
FOR(i, LOG) mask = mask | (mask << (1 << i));
FOR(t, LOG) {
width >>= 1;
mask = mask ^ (mask >> width);
FOR(i, 1 << t) {
FOR(j, width) {
UINT* x = &A[width * (2 * i + 0) + j];
UINT* y = &A[width * (2 * i + 1) + j];
*x = ((*y << width) & mask) ^ *x;
*y = ((*x & mask) >> width) ^ *y;
*x = ((*y << width) & mask) ^ *x;
}
}
}
A.resize(m);
if (!keep_A) return A;
swap(A, tmp);
return tmp;
}
#line 2 "/home/maspy/compro/library/linalg/xor/vector_space.hpp"
template <typename UINT>
struct Vector_Space {
#define SP Vector_Space
vc<UINT> dat;
Vector_Space() {}
Vector_Space(vc<UINT> dat, bool is_reduced = false) : dat(dat) {
if (!is_reduced) reduce();
}
int size() { return dat.size(); }
int dim() { return dat.size(); }
bool add_element(UINT v) {
for (auto&& e: dat) {
if (e == 0 || v == 0) break;
chmin(v, v ^ e);
}
if (v) {
dat.eb(v);
return true;
}
return false;
}
bool contain(UINT v) {
for (auto&& w: dat) {
if (v == 0) break;
chmin(v, v ^ w);
}
return v == 0;
}
UINT get_max(UINT xor_val = 0) {
UINT res = xor_val;
for (auto&& x: dat) chmax(res, res ^ x);
return res;
}
UINT get_min(UINT xor_val) {
UINT res = xor_val;
for (auto&& x: dat) chmin(res, res ^ x);
return res;
}
static SP merge(SP x, SP y) {
if (len(x) < len(y)) swap(x, y);
for (auto v: y.dat) { x.add_element(v); }
return x;
}
static SP intersection(SP& x, SP& y) {
// とりあえず
static_assert(is_same_v<UINT, u32>);
vc<u64> xx;
for (auto& v: x.dat) xx.eb(v | static_cast<u64>(v) << 32);
Vector_Space<u64> z(xx, true);
for (auto& v: y.dat) z.add_element(static_cast<u64>(v) << 32);
vc<u32> xy;
for (auto& v: z.dat) {
if (v <= u32(-1)) xy.eb(v);
}
return SP(xy, true);
}
SP orthogonal_space(int max_dim) {
normalize();
int m = max_dim;
// pivot[k] == k となるように行の順番を変える
vc<u64> tmp(m);
FOR(i, len(dat)) tmp[topbit(dat[i])] = dat[i];
tmp = transpose(m, m, tmp, 0);
SP res;
FOR(j, m) {
if (tmp[j] >> j & 1) continue;
res.add_element(tmp[j] | UINT(1) << j);
}
return res;
}
void normalize(bool dec = true) {
int n = len(dat);
// 三角化
FOR(j, n) FOR(i, j) chmin(dat[i], dat[i] ^ dat[j]);
sort(all(dat));
if (dec) reverse(all(dat));
}
private:
void reduce() {
SP y;
for (auto&& e: dat) y.add_element(e);
(*this) = y;
}
#undef SP
};
#line 5 "main.cpp"
/*
問題
すべての subset にわたる (XOR^K) の平均
答は 2^63 以下?
XORの分布は生成するベクトル空間に制限してよい
topbit は確率1/2で入るので、Kが大きいならば次元も小さい
K=1,2 だけ真面目にとく
正確な小数として出力する必要があるw
*/
void out(u128 num, u64 den) {
if (num % den == 0) return print(num / den);
string ANS;
ANS += to_string(u64(num / den));
num %= den;
ANS += '.';
while (num) {
num *= 10;
ANS += to_string(u64(num / den));
num %= den;
}
print(ANS);
}
u64 dp[1 << 23];
void solve() {
LL(N, K);
Vector_Space<u64> X;
FOR(N) {
U64(x);
X.add_element(x);
}
vc<u64> A = X.dat;
if (len(A) <= 23) {
u128 ANS = 0;
auto dfs = [&](auto& dfs, u64 a, int i) -> void {
if (i == len(A)) {
u128 x = 1;
FOR(K) x *= a;
ANS += x;
return;
}
dfs(dfs, a, i + 1), dfs(dfs, a ^ A[i], i + 1);
};
dfs(dfs, 0, 0);
out(ANS, 1 << len(A));
return;
}
assert(K <= 2);
if (K == 1) {
u128 ANS = 0;
FOR(k, 64) {
bool b = 0;
for (auto& x: A) b = b | (x >> k & 1);
if (b) ANS += u128(1) << k;
}
return out(ANS, 2);
}
assert(K == 2);
u128 ANS = 0;
FOR(a, 60) FOR(b, 60) {
// どっちもあるときに加点
vc<u64> dp(4);
dp[0] = 1;
for (auto& x: A) {
int y = 0;
if (x >> a & 1) y += 1;
if (x >> b & 1) y += 2;
vc<u64> newdp = dp;
FOR(i, 4) newdp[i ^ y] += dp[i];
swap(dp, newdp);
}
ANS += u128(dp[3]) << (a + b);
}
out(ANS, u64(1) << len(A));
}
signed main() { solve(); }
詳細信息
Pretests
Final Tests
Test #1:
score: 5
Accepted
time: 9ms
memory: 3880kb
input:
93348 1 1 2 4 9 25 52 81 133 508 652 1903 3296 5019 14045 18897 39827 81761 164654 433137 873979 1760925 2191486 7119527 14976120 19550122 56863700 91579561 181786097 320782698 677088935 1847381903 2214472334 6489287469 15349585339 22417199361 64252243732 127008028892 253725946829 497102455446 10445...
output:
9223372036854775807.5
result:
ok single line: '9223372036854775807.5'
Test #2:
score: 5
Accepted
time: 4ms
memory: 3848kb
input:
96800 1 14051766699896359 7215410969988351 16776696067864826 7632921873870586 12557076885174912 9161735894052404 15980916402619673 17968380965733216 11261263426099215 1424382964472915 5728555547066265 14908601420989880 14030145822431125 16379643591472362 11558257546383490 5684152043872785 5196436283...
output:
9007199254740991.5
result:
ok single line: '9007199254740991.5'
Test #3:
score: 5
Accepted
time: 2ms
memory: 4132kb
input:
95221 1 541 541 61 544 376 61 61 325 1340 1625 856 869 376 325 1636 544 1145 1281 1145 1340 1636 1820 1820 1625 1820 0 61 1825 376 1145 325 1145 1340 325 376 1281 0 1820 325 1281 1820 541 325 869 1825 1820 1281 376 376 1625 856 856 1281 1825 1145 1340 376 1281 1281 869 541 856 1825 1281 1281 1092 54...
output:
958.5
result:
ok single line: '958.5'
Test #4:
score: 5
Accepted
time: 2ms
memory: 3800kb
input:
98533 1 3708816 4210066 1308040 5434845 7910693 1308040 340294 7907595 5097203 4782005 3775884 4045297 848253 7625599 340559 5751740 3039403 276563 2843160 7688810 1785775 3103042 5903375 3034992 583164 3976394 8231748 7898832 5109263 5912797 5494589 652238 7233072 4530959 340559 2529657 3502072 310...
output:
4194303.5
result:
ok single line: '4194303.5'
Test #5:
score: 5
Accepted
time: 3ms
memory: 3808kb
input:
99218 2 1 2 7 11 31 62 89 133 440 542 1168 3630 5715 9335 22179 46247 89580 194345 438141 1032713 1538482 3074213 5533309 10366154 24031543 55097817 83511187 173451015 536744384 812063048 1419004740 4033891637 4196467447 1019527648 3299473730 1996992967 3674463225 651220214 34624954 137660395 310456...
output:
6148914689089033557.5
result:
ok single line: '6148914689089033557.5'
Test #6:
score: 5
Accepted
time: 3ms
memory: 3816kb
input:
96578 2 2142966981 2057970579 650230902 614791007 2009993626 1503336264 1843254468 344954375 1034874026 1836303812 1330950372 1062930152 1808725968 1345032296 742153662 144209584 778791656 958176703 310646776 648544269 1589164918 1353992516 795183608 1551098207 1044570885 1275989152 746346323 161141...
output:
1537228671735387477.5
result:
ok single line: '1537228671735387477.5'
Test #7:
score: 5
Accepted
time: 6ms
memory: 4088kb
input:
94187 2 1957907055 3931003789 2005347316 2544301452 1497132383 3152717565 1181858491 3483019990 4170106259 4055750004 4003470954 1974284488 1144991575 2668423078 3471595561 1583551589 1406011571 708388628 2126694511 747605046 1718302214 2193548222 2669308194 2258324117 1472721468 834409926 398749751...
output:
6148914689089033557.5
result:
ok single line: '6148914689089033557.5'
Test #8:
score: 5
Accepted
time: 39ms
memory: 3900kb
input:
90891 2 118554447 298165489 188351639 377308761 367689478 178508150 442268442 264391947 57586167 382022377 172829829 36075824 406112676 126474848 330208701 92046913 326570291 291751316 14008758 231762663 354234446 533562288 449834557 532237997 2899563 171139218 93795221 116023039 132785778 243837301...
output:
96076791782135125.5
result:
ok single line: '96076791782135125.5'
Test #9:
score: 5
Accepted
time: 14ms
memory: 3892kb
input:
90619 3 1 3 7 10 28 36 124 186 424 906 1647 2462 6234 9933 27809 53072 68578 142700 362823 654554 1984087 157994 693201 322850 116492 610036 204838 1345906 696265 342996 1078802 1317315 835765 1523925 1145451 520990 1733279 1317634 1398717 983003 1114840 302148 1618973 1693935 686085 434399 247741 1...
output:
2305840810190962688
result:
ok single line: '2305840810190962688'
Test #10:
score: 5
Accepted
time: 3ms
memory: 3832kb
input:
99692 3 54966 49725 36175 19283 46374 36992 41651 19295 61003 31483 17700 62315 6815 36564 47174 40308 1218 27082 24730 17759 65206 17083 12912 49829 50463 58622 9856 251 16677 59372 17149 47128 28281 63288 44046 32455 2759 25380 39233 31057 36170 6518 15121 44269 16701 26455 53637 20422 61692 31173...
output:
70366596710400
result:
ok single line: '70366596710400'
Test #11:
score: 5
Accepted
time: 0ms
memory: 3828kb
input:
98665 3 210 27 27 110 0 188 0 129 188 201 244 38 188 239 210 83 129 27 188 188 244 38 167 27 188 110 154 0 129 210 0 244 27 154 244 154 83 244 72 110 239 244 117 167 110 129 83 201 72 244 129 110 0 61 38 239 72 110 27 188 38 72 129 201 83 210 201 201 117 154 201 83 239 38 0 83 129 129 72 239 188 72 ...
output:
4177536
result:
ok single line: '4177536'
Test #12:
score: 5
Accepted
time: 2ms
memory: 3708kb
input:
93587 3 31263 13029 42528 12794 16841 26681 48758 3271 6993 4778 22541 23342 39968 28137 51098 8355 37051 50543 47728 30027 58097 46182 19500 29713 30216 4489 23204 45019 1170 54271 48866 41614 32405 21049 11722 5664 49886 6703 48026 5325 63960 11809 18302 60322 573 3774 60753 26681 57742 64934 4422...
output:
70366596710400
result:
ok single line: '70366596710400'
Test #13:
score: 5
Accepted
time: 3ms
memory: 3832kb
input:
99711 4 1 3 4 9 21 60 112 233 371 857 2008 3740 4360 8778 24463 63257 51889 62102 13543 14856 5708 21083 36755 51081 21762 38599 9190 63703 29413 41985 40595 4474 14114 5556 40949 56375 41901 16928 43079 31958 38357 52247 24836 59723 60762 62591 45398 46165 33783 11491 15363 35607 16225 58700 6431 5...
output:
3689208078685210760.5
result:
ok single line: '3689208078685210760.5'
Test #14:
score: 5
Accepted
time: 2ms
memory: 3816kb
input:
91509 4 437 94 988 94 898 94 567 994 172 172 96 94 599 395 956 327 956 677 395 295 709 94 599 898 763 295 667 880 395 281 956 709 846 898 763 677 521 295 62 204 395 994 599 172 172 784 172 880 469 295 567 599 295 395 62 0 295 96 994 814 880 898 617 677 880 327 880 677 377 677 281 846 146 521 763 0 3...
output:
219160771256.5
result:
ok single line: '219160771256.5'
Test #15:
score: 5
Accepted
time: 2ms
memory: 3792kb
input:
92430 4 18697 13758 12489 31927 1399 1399 15077 1399 15077 12489 18002 13758 2604 18002 19582 16274 17189 3931 16274 0 16274 16274 16274 31927 31927 19582 30363 15077 16274 2604 0 19582 0 12489 3931 15077 29676 18697 16274 31168 2604 12489 0 30363 13758 19582 19582 18002 15077 29676 0 29676 13758 29...
output:
265753624987159112.5
result:
ok single line: '265753624987159112.5'
Test #16:
score: 5
Accepted
time: 2ms
memory: 3888kb
input:
91817 4 6247 3781 6698 8841 466 8498 13838 3208 11300 4406 6773 1497 13734 3361 6581 15175 7079 3967 4766 5446 13228 589 12219 8557 5834 5461 14260 14484 8435 12850 13211 549 13698 13926 76 10251 13247 15115 3809 8983 15528 7172 11794 11156 12717 8498 10324 7614 14315 11264 1442 4457 1955 6247 2268 ...
output:
14409319974865032.5
result:
ok single line: '14409319974865032.5'
Test #17:
score: 5
Accepted
time: 3ms
memory: 3856kb
input:
99478 5 1 3 5 9 26 35 86 164 420 1019 1088 3607 6424 4029 1253 2314 3020 7503 3077 3742 7766 846 929 7718 2395 5341 780 4323 7760 1906 5293 6795 711 3814 3962 1085 4728 5645 4355 1429 3901 6005 8091 6820 6829 4903 420 6523 722 6630 2979 7779 7 5045 8032 1083 1320 2955 1669 6485 34 7698 6811 434 5656...
output:
6146663120487753728
result:
ok single line: '6146663120487753728'
Test #18:
score: 5
Accepted
time: 2ms
memory: 3884kb
input:
99213 5 485 426 161 79 346 436 191 346 277 426 238 277 346 79 485 507 79 277 191 436 324 436 436 485 191 238 161 324 30 240 507 277 436 79 191 426 240 30 324 81 81 79 0 81 240 324 436 267 485 485 507 81 240 161 485 81 426 277 240 240 79 507 436 30 507 30 161 0 324 426 267 238 485 240 426 240 0 0 238...
output:
6472883376848
result:
ok single line: '6472883376848'
Test #19:
score: 5
Accepted
time: 2ms
memory: 3796kb
input:
99889 5 19 28 34 19 34 45 28 34 49 34 19 15 49 0 45 49 45 19 62 28 62 19 34 28 62 45 0 28 0 19 45 28 28 45 15 19 19 15 34 0 28 15 19 45 49 15 15 45 34 49 0 34 34 45 15 49 0 28 28 0 34 28 15 62 45 19 45 34 62 28 49 34 15 28 15 49 49 0 28 45 34 15 19 49 49 19 15 15 28 19 28 0 62 45 15 49 49 0 28 19 19...
output:
181127184
result:
ok single line: '181127184'
Test #20:
score: 5
Accepted
time: 0ms
memory: 3924kb
input:
99139 5 1894 178 1837 325 240 1987 155 2037 572 1211 631 146 1986 1557 576 1140 664 1632 502 489 1565 664 1230 630 2004 141 141 1222 1141 1836 1535 963 294 75 1265 1140 9 66 332 896 503 133 1503 794 427 471 1953 881 1982 2027 1961 1578 248 124 1013 1437 573 1597 1502 1579 1526 488 2005 1130 1091 173...
output:
5996021955078656
result:
ok single line: '5996021955078656'