QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#339234 | #8279. Segment Tree | kotatsugame | AC ✓ | 1769ms | 39904kb | C++20 | 27.8kb | 2024-02-26 21:37:44 | 2024-03-01 17:28:45 |
Judging History
answer
#include<iostream>
#include<vector>
#include<cassert>
#include <algorithm>
#include <cassert>
#include <vector>
namespace atcoder {
struct dsu {
public:
dsu() : _n(0) {}
explicit dsu(int n) : _n(n), parent_or_size(n, -1) {}
int merge(int a, int b) {
assert(0 <= a && a < _n);
assert(0 <= b && b < _n);
int x = leader(a), y = leader(b);
if (x == y) return x;
if (-parent_or_size[x] < -parent_or_size[y]) std::swap(x, y);
parent_or_size[x] += parent_or_size[y];
parent_or_size[y] = x;
return x;
}
bool same(int a, int b) {
assert(0 <= a && a < _n);
assert(0 <= b && b < _n);
return leader(a) == leader(b);
}
int leader(int a) {
assert(0 <= a && a < _n);
if (parent_or_size[a] < 0) return a;
return parent_or_size[a] = leader(parent_or_size[a]);
}
int size(int a) {
assert(0 <= a && a < _n);
return -parent_or_size[leader(a)];
}
std::vector<std::vector<int>> groups() {
std::vector<int> leader_buf(_n), group_size(_n);
for (int i = 0; i < _n; i++) {
leader_buf[i] = leader(i);
group_size[leader_buf[i]]++;
}
std::vector<std::vector<int>> result(_n);
for (int i = 0; i < _n; i++) {
result[i].reserve(group_size[i]);
}
for (int i = 0; i < _n; i++) {
result[leader_buf[i]].push_back(i);
}
result.erase(
std::remove_if(result.begin(), result.end(),
[&](const std::vector<int>& v) { return v.empty(); }),
result.end());
return result;
}
private:
int _n;
std::vector<int> parent_or_size;
};
} // namespace atcoder
#include <cassert>
#include <numeric>
#include <type_traits>
#ifdef _MSC_VER
#include <intrin.h>
#endif
#include <utility>
#ifdef _MSC_VER
#include <intrin.h>
#endif
namespace atcoder {
namespace internal {
constexpr long long safe_mod(long long x, long long m) {
x %= m;
if (x < 0) x += m;
return x;
}
struct barrett {
unsigned int _m;
unsigned long long im;
explicit barrett(unsigned int m) : _m(m), im((unsigned long long)(-1) / m + 1) {}
unsigned int umod() const { return _m; }
unsigned int mul(unsigned int a, unsigned int b) const {
unsigned long long z = a;
z *= b;
#ifdef _MSC_VER
unsigned long long x;
_umul128(z, im, &x);
#else
unsigned long long x =
(unsigned long long)(((unsigned __int128)(z)*im) >> 64);
#endif
unsigned int v = (unsigned int)(z - x * _m);
if (_m <= v) v += _m;
return v;
}
};
constexpr long long pow_mod_constexpr(long long x, long long n, int m) {
if (m == 1) return 0;
unsigned int _m = (unsigned int)(m);
unsigned long long r = 1;
unsigned long long y = safe_mod(x, m);
while (n) {
if (n & 1) r = (r * y) % _m;
y = (y * y) % _m;
n >>= 1;
}
return r;
}
constexpr bool is_prime_constexpr(int n) {
if (n <= 1) return false;
if (n == 2 || n == 7 || n == 61) return true;
if (n % 2 == 0) return false;
long long d = n - 1;
while (d % 2 == 0) d /= 2;
constexpr long long bases[3] = {2, 7, 61};
for (long long a : bases) {
long long t = d;
long long y = pow_mod_constexpr(a, t, n);
while (t != n - 1 && y != 1 && y != n - 1) {
y = y * y % n;
t <<= 1;
}
if (y != n - 1 && t % 2 == 0) {
return false;
}
}
return true;
}
template <int n> constexpr bool is_prime = is_prime_constexpr(n);
constexpr std::pair<long long, long long> inv_gcd(long long a, long long b) {
a = safe_mod(a, b);
if (a == 0) return {b, 0};
long long s = b, t = a;
long long m0 = 0, m1 = 1;
while (t) {
long long u = s / t;
s -= t * u;
m0 -= m1 * u; // |m1 * u| <= |m1| * s <= b
auto tmp = s;
s = t;
t = tmp;
tmp = m0;
m0 = m1;
m1 = tmp;
}
if (m0 < 0) m0 += b / s;
return {s, m0};
}
constexpr int primitive_root_constexpr(int m) {
if (m == 2) return 1;
if (m == 167772161) return 3;
if (m == 469762049) return 3;
if (m == 754974721) return 11;
if (m == 998244353) return 3;
int divs[20] = {};
divs[0] = 2;
int cnt = 1;
int x = (m - 1) / 2;
while (x % 2 == 0) x /= 2;
for (int i = 3; (long long)(i)*i <= x; i += 2) {
if (x % i == 0) {
divs[cnt++] = i;
while (x % i == 0) {
x /= i;
}
}
}
if (x > 1) {
divs[cnt++] = x;
}
for (int g = 2;; g++) {
bool ok = true;
for (int i = 0; i < cnt; i++) {
if (pow_mod_constexpr(g, (m - 1) / divs[i], m) == 1) {
ok = false;
break;
}
}
if (ok) return g;
}
}
template <int m> constexpr int primitive_root = primitive_root_constexpr(m);
unsigned long long floor_sum_unsigned(unsigned long long n,
unsigned long long m,
unsigned long long a,
unsigned long long b) {
unsigned long long ans = 0;
while (true) {
if (a >= m) {
ans += n * (n - 1) / 2 * (a / m);
a %= m;
}
if (b >= m) {
ans += n * (b / m);
b %= m;
}
unsigned long long y_max = a * n + b;
if (y_max < m) break;
n = (unsigned long long)(y_max / m);
b = (unsigned long long)(y_max % m);
std::swap(m, a);
}
return ans;
}
} // namespace internal
} // namespace atcoder
#include <cassert>
#include <numeric>
#include <type_traits>
namespace atcoder {
namespace internal {
#ifndef _MSC_VER
template <class T>
using is_signed_int128 =
typename std::conditional<std::is_same<T, __int128_t>::value ||
std::is_same<T, __int128>::value,
std::true_type,
std::false_type>::type;
template <class T>
using is_unsigned_int128 =
typename std::conditional<std::is_same<T, __uint128_t>::value ||
std::is_same<T, unsigned __int128>::value,
std::true_type,
std::false_type>::type;
template <class T>
using make_unsigned_int128 =
typename std::conditional<std::is_same<T, __int128_t>::value,
__uint128_t,
unsigned __int128>;
template <class T>
using is_integral = typename std::conditional<std::is_integral<T>::value ||
is_signed_int128<T>::value ||
is_unsigned_int128<T>::value,
std::true_type,
std::false_type>::type;
template <class T>
using is_signed_int = typename std::conditional<(is_integral<T>::value &&
std::is_signed<T>::value) ||
is_signed_int128<T>::value,
std::true_type,
std::false_type>::type;
template <class T>
using is_unsigned_int =
typename std::conditional<(is_integral<T>::value &&
std::is_unsigned<T>::value) ||
is_unsigned_int128<T>::value,
std::true_type,
std::false_type>::type;
template <class T>
using to_unsigned = typename std::conditional<
is_signed_int128<T>::value,
make_unsigned_int128<T>,
typename std::conditional<std::is_signed<T>::value,
std::make_unsigned<T>,
std::common_type<T>>::type>::type;
#else
template <class T> using is_integral = typename std::is_integral<T>;
template <class T>
using is_signed_int =
typename std::conditional<is_integral<T>::value && std::is_signed<T>::value,
std::true_type,
std::false_type>::type;
template <class T>
using is_unsigned_int =
typename std::conditional<is_integral<T>::value &&
std::is_unsigned<T>::value,
std::true_type,
std::false_type>::type;
template <class T>
using to_unsigned = typename std::conditional<is_signed_int<T>::value,
std::make_unsigned<T>,
std::common_type<T>>::type;
#endif
template <class T>
using is_signed_int_t = std::enable_if_t<is_signed_int<T>::value>;
template <class T>
using is_unsigned_int_t = std::enable_if_t<is_unsigned_int<T>::value>;
template <class T> using to_unsigned_t = typename to_unsigned<T>::type;
} // namespace internal
} // namespace atcoder
namespace atcoder {
namespace internal {
struct modint_base {};
struct static_modint_base : modint_base {};
template <class T> using is_modint = std::is_base_of<modint_base, T>;
template <class T> using is_modint_t = std::enable_if_t<is_modint<T>::value>;
} // namespace internal
template <int m, std::enable_if_t<(1 <= m)>* = nullptr>
struct static_modint : internal::static_modint_base {
using mint = static_modint;
public:
static constexpr int mod() { return m; }
static mint raw(int v) {
mint x;
x._v = v;
return x;
}
static_modint() : _v(0) {}
template <class T, internal::is_signed_int_t<T>* = nullptr>
static_modint(T v) {
long long x = (long long)(v % (long long)(umod()));
if (x < 0) x += umod();
_v = (unsigned int)(x);
}
template <class T, internal::is_unsigned_int_t<T>* = nullptr>
static_modint(T v) {
_v = (unsigned int)(v % umod());
}
unsigned int val() const { return _v; }
mint& operator++() {
_v++;
if (_v == umod()) _v = 0;
return *this;
}
mint& operator--() {
if (_v == 0) _v = umod();
_v--;
return *this;
}
mint operator++(int) {
mint result = *this;
++*this;
return result;
}
mint operator--(int) {
mint result = *this;
--*this;
return result;
}
mint& operator+=(const mint& rhs) {
_v += rhs._v;
if (_v >= umod()) _v -= umod();
return *this;
}
mint& operator-=(const mint& rhs) {
_v -= rhs._v;
if (_v >= umod()) _v += umod();
return *this;
}
mint& operator*=(const mint& rhs) {
unsigned long long z = _v;
z *= rhs._v;
_v = (unsigned int)(z % umod());
return *this;
}
mint& operator/=(const mint& rhs) { return *this = *this * rhs.inv(); }
mint operator+() const { return *this; }
mint operator-() const { return mint() - *this; }
mint pow(long long n) const {
assert(0 <= n);
mint x = *this, r = 1;
while (n) {
if (n & 1) r *= x;
x *= x;
n >>= 1;
}
return r;
}
mint inv() const {
if (prime) {
assert(_v);
return pow(umod() - 2);
} else {
auto eg = internal::inv_gcd(_v, m);
assert(eg.first == 1);
return eg.second;
}
}
friend mint operator+(const mint& lhs, const mint& rhs) {
return mint(lhs) += rhs;
}
friend mint operator-(const mint& lhs, const mint& rhs) {
return mint(lhs) -= rhs;
}
friend mint operator*(const mint& lhs, const mint& rhs) {
return mint(lhs) *= rhs;
}
friend mint operator/(const mint& lhs, const mint& rhs) {
return mint(lhs) /= rhs;
}
friend bool operator==(const mint& lhs, const mint& rhs) {
return lhs._v == rhs._v;
}
friend bool operator!=(const mint& lhs, const mint& rhs) {
return lhs._v != rhs._v;
}
private:
unsigned int _v;
static constexpr unsigned int umod() { return m; }
static constexpr bool prime = internal::is_prime<m>;
};
template <int id> struct dynamic_modint : internal::modint_base {
using mint = dynamic_modint;
public:
static int mod() { return (int)(bt.umod()); }
static void set_mod(int m) {
assert(1 <= m);
bt = internal::barrett(m);
}
static mint raw(int v) {
mint x;
x._v = v;
return x;
}
dynamic_modint() : _v(0) {}
template <class T, internal::is_signed_int_t<T>* = nullptr>
dynamic_modint(T v) {
long long x = (long long)(v % (long long)(mod()));
if (x < 0) x += mod();
_v = (unsigned int)(x);
}
template <class T, internal::is_unsigned_int_t<T>* = nullptr>
dynamic_modint(T v) {
_v = (unsigned int)(v % mod());
}
unsigned int val() const { return _v; }
mint& operator++() {
_v++;
if (_v == umod()) _v = 0;
return *this;
}
mint& operator--() {
if (_v == 0) _v = umod();
_v--;
return *this;
}
mint operator++(int) {
mint result = *this;
++*this;
return result;
}
mint operator--(int) {
mint result = *this;
--*this;
return result;
}
mint& operator+=(const mint& rhs) {
_v += rhs._v;
if (_v >= umod()) _v -= umod();
return *this;
}
mint& operator-=(const mint& rhs) {
_v += mod() - rhs._v;
if (_v >= umod()) _v -= umod();
return *this;
}
mint& operator*=(const mint& rhs) {
_v = bt.mul(_v, rhs._v);
return *this;
}
mint& operator/=(const mint& rhs) { return *this = *this * rhs.inv(); }
mint operator+() const { return *this; }
mint operator-() const { return mint() - *this; }
mint pow(long long n) const {
assert(0 <= n);
mint x = *this, r = 1;
while (n) {
if (n & 1) r *= x;
x *= x;
n >>= 1;
}
return r;
}
mint inv() const {
auto eg = internal::inv_gcd(_v, mod());
assert(eg.first == 1);
return eg.second;
}
friend mint operator+(const mint& lhs, const mint& rhs) {
return mint(lhs) += rhs;
}
friend mint operator-(const mint& lhs, const mint& rhs) {
return mint(lhs) -= rhs;
}
friend mint operator*(const mint& lhs, const mint& rhs) {
return mint(lhs) *= rhs;
}
friend mint operator/(const mint& lhs, const mint& rhs) {
return mint(lhs) /= rhs;
}
friend bool operator==(const mint& lhs, const mint& rhs) {
return lhs._v == rhs._v;
}
friend bool operator!=(const mint& lhs, const mint& rhs) {
return lhs._v != rhs._v;
}
private:
unsigned int _v;
static internal::barrett bt;
static unsigned int umod() { return bt.umod(); }
};
template <int id> internal::barrett dynamic_modint<id>::bt(998244353);
using modint998244353 = static_modint<998244353>;
using modint1000000007 = static_modint<1000000007>;
using modint = dynamic_modint<-1>;
namespace internal {
template <class T>
using is_static_modint = std::is_base_of<internal::static_modint_base, T>;
template <class T>
using is_static_modint_t = std::enable_if_t<is_static_modint<T>::value>;
template <class> struct is_dynamic_modint : public std::false_type {};
template <int id>
struct is_dynamic_modint<dynamic_modint<id>> : public std::true_type {};
template <class T>
using is_dynamic_modint_t = std::enable_if_t<is_dynamic_modint<T>::value>;
} // namespace internal
} // namespace atcoder
#include <algorithm>
#include <cassert>
#include <vector>
#ifdef _MSC_VER
#include <intrin.h>
#endif
namespace atcoder {
namespace internal {
int ceil_pow2(int n) {
int x = 0;
while ((1U << x) < (unsigned int)(n)) x++;
return x;
}
constexpr int bsf_constexpr(unsigned int n) {
int x = 0;
while (!(n & (1 << x))) x++;
return x;
}
int bsf(unsigned int n) {
#ifdef _MSC_VER
unsigned long index;
_BitScanForward(&index, n);
return index;
#else
return __builtin_ctz(n);
#endif
}
} // namespace internal
} // namespace atcoder
namespace atcoder {
template <class S, S (*op)(S, S), S (*e)()> struct segtree {
public:
segtree() : segtree(0) {}
explicit segtree(int n) : segtree(std::vector<S>(n, e())) {}
explicit segtree(const std::vector<S>& v) : _n(int(v.size())) {
log = internal::ceil_pow2(_n);
size = 1 << log;
d = std::vector<S>(2 * size, e());
for (int i = 0; i < _n; i++) d[size + i] = v[i];
for (int i = size - 1; i >= 1; i--) {
update(i);
}
}
void set(int p, S x) {
assert(0 <= p && p < _n);
p += size;
d[p] = x;
for (int i = 1; i <= log; i++) update(p >> i);
}
S get(int p) const {
assert(0 <= p && p < _n);
return d[p + size];
}
S prod(int l, int r) const {
assert(0 <= l && l <= r && r <= _n);
S sml = e(), smr = e();
l += size;
r += size;
while (l < r) {
if (l & 1) sml = op(sml, d[l++]);
if (r & 1) smr = op(d[--r], smr);
l >>= 1;
r >>= 1;
}
return op(sml, smr);
}
S all_prod() const { return d[1]; }
template <bool (*f)(S)> int max_right(int l) const {
return max_right(l, [](S x) { return f(x); });
}
template <class F> int max_right(int l, F f) const {
assert(0 <= l && l <= _n);
assert(f(e()));
if (l == _n) return _n;
l += size;
S sm = e();
do {
while (l % 2 == 0) l >>= 1;
if (!f(op(sm, d[l]))) {
while (l < size) {
l = (2 * l);
if (f(op(sm, d[l]))) {
sm = op(sm, d[l]);
l++;
}
}
return l - size;
}
sm = op(sm, d[l]);
l++;
} while ((l & -l) != l);
return _n;
}
template <bool (*f)(S)> int min_left(int r) const {
return min_left(r, [](S x) { return f(x); });
}
template <class F> int min_left(int r, F f) const {
assert(0 <= r && r <= _n);
assert(f(e()));
if (r == 0) return 0;
r += size;
S sm = e();
do {
r--;
while (r > 1 && (r % 2)) r >>= 1;
if (!f(op(d[r], sm))) {
while (r < size) {
r = (2 * r + 1);
if (f(op(d[r], sm))) {
sm = op(d[r], sm);
r--;
}
}
return r + 1 - size;
}
sm = op(d[r], sm);
} while ((r & -r) != r);
return 0;
}
private:
int _n, size, log;
std::vector<S> d;
void update(int k) { d[k] = op(d[2 * k], d[2 * k + 1]); }
};
} // namespace atcoder
#include <algorithm>
#include <cassert>
#include <iostream>
#include <vector>
namespace atcoder {
template <class S,
S (*op)(S, S),
S (*e)(),
class F,
S (*mapping)(F, S),
F (*composition)(F, F),
F (*id)()>
struct lazy_segtree {
public:
lazy_segtree() : lazy_segtree(0) {}
explicit lazy_segtree(int n) : lazy_segtree(std::vector<S>(n, e())) {}
explicit lazy_segtree(const std::vector<S>& v) : _n(int(v.size())) {
log = internal::ceil_pow2(_n);
size = 1 << log;
d = std::vector<S>(2 * size, e());
lz = std::vector<F>(size, id());
for (int i = 0; i < _n; i++) d[size + i] = v[i];
for (int i = size - 1; i >= 1; i--) {
update(i);
}
}
void set(int p, S x) {
assert(0 <= p && p < _n);
p += size;
for (int i = log; i >= 1; i--) push(p >> i);
d[p] = x;
for (int i = 1; i <= log; i++) update(p >> i);
}
S get(int p) {
assert(0 <= p && p < _n);
p += size;
for (int i = log; i >= 1; i--) push(p >> i);
return d[p];
}
S prod(int l, int r) {
assert(0 <= l && l <= r && r <= _n);
if (l == r) return e();
l += size;
r += size;
for (int i = log; i >= 1; i--) {
if (((l >> i) << i) != l) push(l >> i);
if (((r >> i) << i) != r) push((r - 1) >> i);
}
S sml = e(), smr = e();
while (l < r) {
if (l & 1) sml = op(sml, d[l++]);
if (r & 1) smr = op(d[--r], smr);
l >>= 1;
r >>= 1;
}
return op(sml, smr);
}
S all_prod() { return d[1]; }
void apply(int p, F f) {
assert(0 <= p && p < _n);
p += size;
for (int i = log; i >= 1; i--) push(p >> i);
d[p] = mapping(f, d[p]);
for (int i = 1; i <= log; i++) update(p >> i);
}
void apply(int l, int r, F f) {
assert(0 <= l && l <= r && r <= _n);
if (l == r) return;
l += size;
r += size;
for (int i = log; i >= 1; i--) {
if (((l >> i) << i) != l) push(l >> i);
if (((r >> i) << i) != r) push((r - 1) >> i);
}
{
int l2 = l, r2 = r;
while (l < r) {
if (l & 1) all_apply(l++, f);
if (r & 1) all_apply(--r, f);
l >>= 1;
r >>= 1;
}
l = l2;
r = r2;
}
for (int i = 1; i <= log; i++) {
if (((l >> i) << i) != l) update(l >> i);
if (((r >> i) << i) != r) update((r - 1) >> i);
}
}
template <bool (*g)(S)> int max_right(int l) {
return max_right(l, [](S x) { return g(x); });
}
template <class G> int max_right(int l, G g) {
assert(0 <= l && l <= _n);
assert(g(e()));
if (l == _n) return _n;
l += size;
for (int i = log; i >= 1; i--) push(l >> i);
S sm = e();
do {
while (l % 2 == 0) l >>= 1;
if (!g(op(sm, d[l]))) {
while (l < size) {
push(l);
l = (2 * l);
if (g(op(sm, d[l]))) {
sm = op(sm, d[l]);
l++;
}
}
return l - size;
}
sm = op(sm, d[l]);
l++;
} while ((l & -l) != l);
return _n;
}
template <bool (*g)(S)> int min_left(int r) {
return min_left(r, [](S x) { return g(x); });
}
template <class G> int min_left(int r, G g) {
assert(0 <= r && r <= _n);
assert(g(e()));
if (r == 0) return 0;
r += size;
for (int i = log; i >= 1; i--) push((r - 1) >> i);
S sm = e();
do {
r--;
while (r > 1 && (r % 2)) r >>= 1;
if (!g(op(d[r], sm))) {
while (r < size) {
push(r);
r = (2 * r + 1);
if (g(op(d[r], sm))) {
sm = op(d[r], sm);
r--;
}
}
return r + 1 - size;
}
sm = op(d[r], sm);
} while ((r & -r) != r);
return 0;
}
private:
int _n, size, log;
std::vector<S> d;
std::vector<F> lz;
void update(int k) { d[k] = op(d[2 * k], d[2 * k + 1]); }
void all_apply(int k, F f) {
d[k] = mapping(f, d[k]);
if (k < size) lz[k] = composition(f, lz[k]);
}
void push(int k) {
all_apply(2 * k, lz[k]);
all_apply(2 * k + 1, lz[k]);
lz[k] = id();
}
};
} // namespace atcoder
using namespace std;
pair<int,int>op_pair(pair<int,int>a,pair<int,int>b)
{
a.first=min(a.first,b.first);
a.second=max(a.second,b.second);
return a;
}
pair<int,int>e_pair(){return make_pair((int)1e9,-1);}
using mint=atcoder::modint998244353;
struct dat{
mint A,B;
};
dat op(dat a,dat b)
{
a.A+=b.A;
a.B+=b.B;
return a;
}
dat e(){return(dat){mint(0),mint(0)};}
using F=pair<mint,bool>;
dat mp(F f,dat x)
{
x.A*=f.first;
x.B*=f.first;
if(f.second)x.B=0;
return x;
}
F cmp(F f,F g)
{
f.first*=g.first;
f.second=f.second||g.second;
return f;
}
F id(){return make_pair(mint(1),false);}
int N,M;
int X[2<<17],L[2<<17],R[2<<17];
mint val[2<<17];
void dfsLR(int l,int r,int&id)
{
if(l+1==r)return;
L[id]=l,R[id]=r;
int m=X[id];
id++;
dfsLR(l,m,id);
dfsLR(m,r,id);
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
cin>>N>>M;
for(int i=0;i<N-1;i++)cin>>X[i];
{
int id=0;
dfsLR(0,N,id);
assert(id==N-1);
//for(int i=0;i<N-1;i++)cout<<L[i]<<" "<<R[i]<<endl;
}
atcoder::dsu uf(N+1);
for(int i=0;i<M;i++)
{
int l,r;cin>>l>>r;
uf.merge(l,r);
}
for(int i=0;i<N;i++)val[i]=1;
vector<dat>init(N,(dat){mint(1),mint(1)});
atcoder::lazy_segtree<dat,op,e,F,mp,cmp,id>seg(init);
vector<pair<int,int> >init_pair(N+1,e_pair());
vector<vector<pair<int,int> > >Erase(N-1);
{
vector<pair<int,int> >init_Xinv(N+1,e_pair());
for(int i=0;i<N-1;i++)init_Xinv[X[i]].first=i;
atcoder::segtree<pair<int,int>,op_pair,e_pair>Xinv(init_Xinv);
for(vector<int>g:uf.groups())if(g.size()>=2)
{
int mx=0,mn=N;
for(int u:g)mx=max(mx,u),mn=min(mn,u);
for(int u:g)init_pair[u]=make_pair(mn,mx);
int t=Xinv.prod(mn+1,mx).first;
if(t>=N-1)seg.set(mn,(dat){mint(1),mint(0)});
else Erase[t].push_back(make_pair(mn,mx));
}
}
atcoder::segtree<pair<int,int>,op_pair,e_pair>seg_pair(init_pair);
for(int t=N-1;t--;)
{
int l=L[t],r=R[t],m=X[t];
assert(l<m&&m<r);
mint x=val[l],y=val[m];
if(m-l<=r-m)
{
sort(Erase[t].begin(),Erase[t].end());
for(int i=m-1;i>=l;i--)
{
mint f=y;
int j=seg_pair.max_right(i+1,[&](pair<int,int>p){return p.first>i&&p.second<=r;});
if(m<j)f+=seg.prod(m,min(j,r)).B;
{
dat t=seg.get(i);
t.A*=f;t.B*=f;
seg.set(i,t);
}
while(!Erase[t].empty()&&Erase[t].back().first>=i)
{
auto[l,r]=Erase[t].back();
seg.apply(l,r,make_pair(mint(1),true));
Erase[t].pop_back();
}
}
seg.apply(m,r,make_pair(x,false));
}
else
{
sort(Erase[t].begin(),Erase[t].end(),[](pair<int,int>l,pair<int,int>r){
return l.second>r.second;
});
for(int j=m;j<r;j++)
{
mint f=x;
int i=seg_pair.min_left(j+1,[&](pair<int,int>p){return p.first>=l&&p.second<j+1;})-1;
if(i<m)f+=seg.prod(max(i,l),m).B;
{
dat t=seg.get(j);
t.A*=f;t.B*=f;
seg.set(j,t);
}
while(!Erase[t].empty()&&Erase[t].back().second<=j+1)
{
auto[l,r]=Erase[t].back();
seg.apply(l,r,make_pair(mint(1),true));
Erase[t].pop_back();
}
}
seg.apply(l,m,make_pair(y,false));
}
val[l]=x*y*2+seg.prod(l,r).A;
}
mint ans=val[0]+seg.all_prod().B;
cout<<ans.val()<<endl;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 4856kb
input:
2 1 1 0 2
output:
5
result:
ok 1 number(s): "5"
Test #2:
score: 0
Accepted
time: 1ms
memory: 4892kb
input:
2 1 1 1 2
output:
5
result:
ok 1 number(s): "5"
Test #3:
score: 0
Accepted
time: 1ms
memory: 4616kb
input:
5 2 2 1 4 3 1 3 2 5
output:
193
result:
ok 1 number(s): "193"
Test #4:
score: 0
Accepted
time: 1ms
memory: 4672kb
input:
10 10 5 2 1 3 4 7 6 8 9 0 1 0 2 0 3 0 4 0 5 0 6 0 7 0 8 0 9 0 10
output:
70848
result:
ok 1 number(s): "70848"
Test #5:
score: 0
Accepted
time: 1ms
memory: 4672kb
input:
2 2 1 0 1 0 2
output:
4
result:
ok 1 number(s): "4"
Test #6:
score: 0
Accepted
time: 1ms
memory: 4664kb
input:
3 3 1 2 0 1 0 2 0 3
output:
14
result:
ok 1 number(s): "14"
Test #7:
score: 0
Accepted
time: 1ms
memory: 4668kb
input:
4 4 1 2 3 0 1 0 2 0 3 0 4
output:
48
result:
ok 1 number(s): "48"
Test #8:
score: 0
Accepted
time: 0ms
memory: 4624kb
input:
5 5 3 1 2 4 0 1 0 2 0 3 0 4 0 5
output:
164
result:
ok 1 number(s): "164"
Test #9:
score: 0
Accepted
time: 1ms
memory: 4652kb
input:
6 6 4 2 1 3 5 0 1 0 2 0 3 0 4 0 5 0 6
output:
544
result:
ok 1 number(s): "544"
Test #10:
score: 0
Accepted
time: 1ms
memory: 4904kb
input:
7 7 3 2 1 5 4 6 0 1 0 2 0 3 0 4 0 5 0 6 0 7
output:
1856
result:
ok 1 number(s): "1856"
Test #11:
score: 0
Accepted
time: 1ms
memory: 4664kb
input:
8 8 3 1 2 4 7 5 6 0 1 0 2 0 3 0 4 0 5 0 6 0 7 0 8
output:
6528
result:
ok 1 number(s): "6528"
Test #12:
score: 0
Accepted
time: 1ms
memory: 4704kb
input:
9 9 3 1 2 4 7 6 5 8 0 1 0 2 0 3 0 4 0 5 0 6 0 7 0 8 0 9
output:
21520
result:
ok 1 number(s): "21520"
Test #13:
score: 0
Accepted
time: 0ms
memory: 4672kb
input:
10 10 8 2 1 3 4 6 5 7 9 0 1 0 2 0 3 0 4 0 5 0 6 0 7 0 8 0 9 0 10
output:
71296
result:
ok 1 number(s): "71296"
Test #14:
score: 0
Accepted
time: 1ms
memory: 4616kb
input:
2 3 1 0 1 0 2 1 2
output:
4
result:
ok 1 number(s): "4"
Test #15:
score: 0
Accepted
time: 1ms
memory: 4904kb
input:
3 6 1 2 0 1 0 2 0 3 1 2 1 3 2 3
output:
14
result:
ok 1 number(s): "14"
Test #16:
score: 0
Accepted
time: 0ms
memory: 4840kb
input:
4 10 1 2 3 0 1 0 2 0 3 0 4 1 2 1 3 1 4 2 3 2 4 3 4
output:
48
result:
ok 1 number(s): "48"
Test #17:
score: 0
Accepted
time: 1ms
memory: 4840kb
input:
5 15 1 4 3 2 0 1 0 2 0 3 0 4 0 5 1 2 1 3 1 4 1 5 2 3 2 4 2 5 3 4 3 5 4 5
output:
164
result:
ok 1 number(s): "164"
Test #18:
score: 0
Accepted
time: 1ms
memory: 4856kb
input:
6 21 5 3 1 2 4 0 1 0 2 0 3 0 4 0 5 0 6 1 2 1 3 1 4 1 5 1 6 2 3 2 4 2 5 2 6 3 4 3 5 3 6 4 5 4 6 5 6
output:
544
result:
ok 1 number(s): "544"
Test #19:
score: 0
Accepted
time: 1ms
memory: 4856kb
input:
7 28 4 1 2 3 6 5 0 1 0 2 0 3 0 4 0 5 0 6 0 7 1 2 1 3 1 4 1 5 1 6 1 7 2 3 2 4 2 5 2 6 2 7 3 4 3 5 3 6 3 7 4 5 4 6 4 7 5 6 5 7 6 7
output:
1912
result:
ok 1 number(s): "1912"
Test #20:
score: 0
Accepted
time: 0ms
memory: 4612kb
input:
8 36 5 2 1 3 4 7 6 0 1 0 2 0 3 0 4 0 5 0 6 0 7 0 8 1 2 1 3 1 4 1 5 1 6 1 7 1 8 2 3 2 4 2 5 2 6 2 7 2 8 3 4 3 5 3 6 3 7 3 8 4 5 4 6 4 7 4 8 5 6 5 7 5 8 6 7 6 8 7 8
output:
6304
result:
ok 1 number(s): "6304"
Test #21:
score: 0
Accepted
time: 0ms
memory: 4856kb
input:
9 45 6 2 1 4 3 5 7 8 0 1 0 2 0 3 0 4 0 5 0 6 0 7 0 8 0 9 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 2 3 2 4 2 5 2 6 2 7 2 8 2 9 3 4 3 5 3 6 3 7 3 8 3 9 4 5 4 6 4 7 4 8 4 9 5 6 5 7 5 8 5 9 6 7 6 8 6 9 7 8 7 9 8 9
output:
20736
result:
ok 1 number(s): "20736"
Test #22:
score: 0
Accepted
time: 1ms
memory: 4908kb
input:
10 55 6 3 2 1 4 5 8 7 9 0 1 0 2 0 3 0 4 0 5 0 6 0 7 0 8 0 9 0 10 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 10 2 3 2 4 2 5 2 6 2 7 2 8 2 9 2 10 3 4 3 5 3 6 3 7 3 8 3 9 3 10 4 5 4 6 4 7 4 8 4 9 4 10 5 6 5 7 5 8 5 9 5 10 6 7 6 8 6 9 6 10 7 8 7 9 7 10 8 9 8 10 9 10
output:
70784
result:
ok 1 number(s): "70784"
Test #23:
score: 0
Accepted
time: 0ms
memory: 4560kb
input:
2 1 1 0 2
output:
5
result:
ok 1 number(s): "5"
Test #24:
score: 0
Accepted
time: 1ms
memory: 4660kb
input:
3 1 2 1 2 3
output:
21
result:
ok 1 number(s): "21"
Test #25:
score: 0
Accepted
time: 1ms
memory: 4836kb
input:
4 1 2 1 3 0 1
output:
85
result:
ok 1 number(s): "85"
Test #26:
score: 0
Accepted
time: 1ms
memory: 4616kb
input:
5 1 4 1 3 2 0 5
output:
341
result:
ok 1 number(s): "341"
Test #27:
score: 0
Accepted
time: 0ms
memory: 4888kb
input:
6 1 5 1 2 3 4 0 2
output:
1260
result:
ok 1 number(s): "1260"
Test #28:
score: 0
Accepted
time: 0ms
memory: 4676kb
input:
7 1 2 1 6 4 3 5 3 4
output:
5545
result:
ok 1 number(s): "5545"
Test #29:
score: 0
Accepted
time: 1ms
memory: 4856kb
input:
8 1 5 4 2 1 3 6 7 4 7
output:
14745
result:
ok 1 number(s): "14745"
Test #30:
score: 0
Accepted
time: 0ms
memory: 4908kb
input:
9 1 3 2 1 8 7 6 4 5 3 6
output:
101031
result:
ok 1 number(s): "101031"
Test #31:
score: 0
Accepted
time: 1ms
memory: 4616kb
input:
10 1 7 4 2 1 3 5 6 9 8 9 10
output:
373889
result:
ok 1 number(s): "373889"
Test #32:
score: 0
Accepted
time: 1ms
memory: 4612kb
input:
10 2 1 9 8 5 4 3 2 7 6 1 8 2 5
output:
261049
result:
ok 1 number(s): "261049"
Test #33:
score: 0
Accepted
time: 0ms
memory: 4684kb
input:
10 3 5 1 4 3 2 7 6 9 8 1 8 3 9 6 8
output:
122329
result:
ok 1 number(s): "122329"
Test #34:
score: 0
Accepted
time: 1ms
memory: 4664kb
input:
10 4 4 1 2 3 8 6 5 7 9 0 8 0 10 1 2 4 7
output:
175630
result:
ok 1 number(s): "175630"
Test #35:
score: 0
Accepted
time: 0ms
memory: 4704kb
input:
10 5 3 1 2 8 6 5 4 7 9 3 8 5 6 6 7 7 8 8 9
output:
176820
result:
ok 1 number(s): "176820"
Test #36:
score: 0
Accepted
time: 1ms
memory: 4648kb
input:
10 6 7 6 4 1 3 2 5 9 8 0 2 2 3 2 4 3 5 5 10 6 10
output:
123102
result:
ok 1 number(s): "123102"
Test #37:
score: 0
Accepted
time: 0ms
memory: 4904kb
input:
10 7 6 1 3 2 5 4 8 7 9 2 5 2 7 2 10 3 10 4 7 5 10 8 10
output:
107712
result:
ok 1 number(s): "107712"
Test #38:
score: 0
Accepted
time: 1ms
memory: 4608kb
input:
10 8 1 3 2 7 4 6 5 9 8 0 2 1 7 1 10 2 9 3 7 4 6 4 8 5 7
output:
70272
result:
ok 1 number(s): "70272"
Test #39:
score: 0
Accepted
time: 0ms
memory: 4560kb
input:
10 9 4 1 2 3 5 8 7 6 9 0 7 0 10 1 7 1 9 1 10 3 6 4 5 4 7 6 10
output:
82208
result:
ok 1 number(s): "82208"
Test #40:
score: 0
Accepted
time: 1ms
memory: 4616kb
input:
10 10 6 4 2 1 3 5 8 7 9 0 4 1 3 1 9 2 5 2 9 2 10 3 8 4 5 4 8 4 9
output:
89920
result:
ok 1 number(s): "89920"
Test #41:
score: 0
Accepted
time: 1ms
memory: 4904kb
input:
10 15 6 2 1 3 5 4 8 7 9 0 3 0 10 1 5 2 4 2 10 3 6 3 9 4 6 5 7 5 8 6 7 6 9 6 10 8 10 9 10
output:
71168
result:
ok 1 number(s): "71168"
Test #42:
score: 0
Accepted
time: 1ms
memory: 4668kb
input:
10 20 3 1 2 8 6 5 4 7 9 0 4 0 5 0 10 1 2 1 5 1 6 1 9 2 4 2 10 3 5 3 6 3 7 3 9 4 8 4 10 5 9 5 10 6 7 8 9 8 10
output:
70336
result:
ok 1 number(s): "70336"
Test #43:
score: 0
Accepted
time: 0ms
memory: 4608kb
input:
10 30 6 1 2 4 3 5 9 7 8 0 1 0 2 0 4 0 5 0 6 0 7 0 9 0 10 1 2 1 3 1 6 1 7 1 8 1 10 2 6 2 8 2 10 3 4 3 5 3 6 3 10 4 6 4 10 5 6 5 7 5 8 5 10 6 8 7 9 8 10
output:
73856
result:
ok 1 number(s): "73856"
Test #44:
score: 0
Accepted
time: 1ms
memory: 4608kb
input:
10 40 8 3 1 2 7 6 4 5 9 0 1 0 2 0 3 0 4 0 7 1 2 1 3 1 5 1 6 1 7 1 9 1 10 2 3 2 5 2 6 2 7 2 8 2 9 2 10 3 4 3 5 3 6 3 7 3 10 4 6 4 8 4 9 4 10 5 7 5 8 5 9 5 10 6 7 6 8 6 9 7 8 7 9 7 10 8 10 9 10
output:
73024
result:
ok 1 number(s): "73024"
Test #45:
score: 0
Accepted
time: 0ms
memory: 4628kb
input:
100 1 31 25 5 3 1 2 4 17 6 9 8 7 12 10 11 16 14 13 15 18 23 21 20 19 22 24 30 29 28 27 26 38 33 32 35 34 36 37 65 59 39 45 44 42 40 41 43 52 47 46 50 49 48 51 58 57 55 54 53 56 63 61 60 62 64 99 97 90 68 66 67 86 69 76 70 73 72 71 74 75 81 78 77 80 79 84 83 82 85 87 89 88 95 94 91 92 93 96 98 38 95
output:
552106926
result:
ok 1 number(s): "552106926"
Test #46:
score: 0
Accepted
time: 1ms
memory: 4580kb
input:
100 5 68 14 10 6 5 3 1 2 4 9 8 7 13 12 11 63 41 36 30 27 15 16 17 19 18 22 21 20 23 24 25 26 29 28 34 32 31 33 35 38 37 40 39 60 48 46 42 43 45 44 47 52 49 51 50 54 53 57 55 56 58 59 62 61 66 64 65 67 97 75 74 70 69 72 71 73 76 95 80 78 77 79 90 84 83 81 82 86 85 88 87 89 93 92 91 94 96 98 99 5 62 1...
output:
413773825
result:
ok 1 number(s): "413773825"
Test #47:
score: 0
Accepted
time: 0ms
memory: 4688kb
input:
100 10 86 24 4 2 1 3 9 6 5 7 8 22 15 10 12 11 14 13 18 16 17 19 21 20 23 77 33 29 27 25 26 28 32 30 31 70 60 52 43 40 35 34 39 36 37 38 42 41 47 46 44 45 51 50 49 48 57 53 56 55 54 59 58 65 62 61 63 64 69 66 67 68 73 72 71 76 74 75 84 83 78 82 80 79 81 85 91 88 87 89 90 98 97 92 94 93 96 95 99 5 30 ...
output:
62575440
result:
ok 1 number(s): "62575440"
Test #48:
score: 0
Accepted
time: 1ms
memory: 4676kb
input:
100 100 87 47 5 2 1 3 4 27 22 16 13 12 10 9 8 6 7 11 14 15 21 17 19 18 20 24 23 25 26 28 37 32 29 30 31 35 33 34 36 41 39 38 40 45 43 42 44 46 56 50 48 49 51 53 52 55 54 60 57 59 58 77 64 62 61 63 65 66 75 70 68 67 69 73 72 71 74 76 83 79 78 81 80 82 86 84 85 96 93 89 88 90 92 91 94 95 99 97 98 1 11...
output:
409347680
result:
ok 1 number(s): "409347680"
Test #49:
score: 0
Accepted
time: 1ms
memory: 4628kb
input:
100 200 33 5 3 1 2 4 28 13 12 7 6 11 9 8 10 18 14 17 16 15 23 20 19 22 21 26 24 25 27 31 29 30 32 59 57 36 35 34 38 37 46 41 39 40 43 42 45 44 47 49 48 54 52 51 50 53 56 55 58 88 87 85 79 69 61 60 66 63 62 64 65 68 67 75 70 73 71 72 74 77 76 78 80 84 83 81 82 86 91 90 89 94 92 93 98 95 97 96 99 0 2 ...
output:
390437573
result:
ok 1 number(s): "390437573"
Test #50:
score: 0
Accepted
time: 0ms
memory: 4620kb
input:
100 300 79 29 24 12 8 3 2 1 4 5 6 7 11 10 9 19 13 17 14 16 15 18 21 20 22 23 26 25 28 27 44 41 33 32 30 31 38 37 34 35 36 39 40 43 42 70 46 45 65 47 63 58 51 48 49 50 54 53 52 56 55 57 62 61 60 59 64 66 67 69 68 75 74 71 73 72 77 76 78 95 90 80 86 85 83 81 82 84 87 89 88 92 91 93 94 97 96 98 99 0 44...
output:
819705181
result:
ok 1 number(s): "819705181"
Test #51:
score: 0
Accepted
time: 2ms
memory: 4652kb
input:
100 1000 93 57 56 11 2 1 7 5 4 3 6 8 9 10 30 12 26 25 20 18 14 13 16 15 17 19 21 24 22 23 27 29 28 35 34 31 32 33 36 45 44 37 38 43 42 39 40 41 53 49 48 47 46 51 50 52 55 54 91 78 63 60 59 58 62 61 75 71 68 64 67 66 65 70 69 74 73 72 77 76 83 81 79 80 82 86 84 85 89 87 88 90 92 99 94 98 96 95 97 0 3...
output:
750766504
result:
ok 1 number(s): "750766504"
Test #52:
score: 0
Accepted
time: 1ms
memory: 4868kb
input:
100 5050 59 44 36 35 15 7 6 2 1 3 4 5 9 8 14 12 10 11 13 26 16 20 18 17 19 23 22 21 24 25 32 27 29 28 30 31 33 34 41 39 37 38 40 43 42 45 49 46 48 47 55 50 52 51 53 54 57 56 58 65 60 61 62 64 63 67 66 84 83 72 69 68 70 71 81 75 74 73 78 76 77 80 79 82 93 85 88 86 87 89 92 90 91 96 94 95 98 97 99 0 1...
output:
331243901
result:
ok 1 number(s): "331243901"
Test #53:
score: 0
Accepted
time: 1ms
memory: 4676kb
input:
100 100 71 14 3 1 2 9 6 4 5 8 7 13 12 11 10 60 51 27 20 17 16 15 18 19 21 23 22 25 24 26 43 40 35 28 33 29 31 30 32 34 39 36 38 37 41 42 50 44 48 47 45 46 49 55 52 54 53 59 58 56 57 69 65 61 64 62 63 66 68 67 70 74 73 72 87 78 77 75 76 80 79 86 81 85 83 82 84 99 92 90 88 89 91 98 94 93 96 95 97 0 1 ...
output:
614246259
result:
ok 1 number(s): "614246259"
Test #54:
score: 0
Accepted
time: 0ms
memory: 4624kb
input:
100 100 3 2 1 96 93 5 4 90 6 11 8 7 9 10 16 15 14 12 13 21 17 18 19 20 88 26 23 22 25 24 84 27 79 29 28 33 31 30 32 37 34 36 35 38 42 40 39 41 46 45 43 44 78 76 50 47 48 49 74 73 70 66 54 51 53 52 63 55 60 58 57 56 59 61 62 65 64 67 68 69 71 72 75 77 82 81 80 83 87 86 85 89 91 92 94 95 97 98 99 0 23...
output:
663163875
result:
ok 1 number(s): "663163875"
Test #55:
score: 0
Accepted
time: 1ms
memory: 4692kb
input:
100 500 96 93 4 1 3 2 90 5 7 6 10 9 8 89 14 13 12 11 17 16 15 22 21 20 18 19 24 23 88 86 85 27 26 25 30 28 29 32 31 84 36 34 33 35 37 82 38 41 40 39 44 42 43 47 45 46 52 49 48 51 50 78 76 53 56 54 55 73 69 66 60 58 57 59 65 64 61 62 63 68 67 72 70 71 75 74 77 81 80 79 83 87 91 92 94 95 97 98 99 0 3 ...
output:
62035584
result:
ok 1 number(s): "62035584"
Test #56:
score: 0
Accepted
time: 0ms
memory: 4752kb
input:
500 10 457 239 205 66 2 1 33 19 6 3 5 4 8 7 10 9 12 11 17 16 15 14 13 18 25 22 21 20 23 24 28 27 26 29 32 31 30 64 54 44 39 36 34 35 37 38 43 41 40 42 49 46 45 48 47 53 51 50 52 55 58 57 56 61 60 59 62 63 65 157 135 104 83 81 78 74 70 69 68 67 73 71 72 76 75 77 79 80 82 96 93 88 84 86 85 87 90 89 91...
output:
388044595
result:
ok 1 number(s): "388044595"
Test #57:
score: 0
Accepted
time: 2ms
memory: 4740kb
input:
500 100 239 5 4 2 1 3 148 146 97 65 24 7 6 18 9 8 12 11 10 15 13 14 17 16 23 21 20 19 22 63 55 29 26 25 27 28 35 32 30 31 33 34 50 38 37 36 43 39 41 40 42 46 44 45 47 48 49 52 51 53 54 61 59 58 56 57 60 62 64 91 69 67 66 68 81 79 73 72 70 71 75 74 78 77 76 80 82 88 83 87 84 85 86 89 90 96 95 92 94 9...
output:
292284846
result:
ok 1 number(s): "292284846"
Test #58:
score: 0
Accepted
time: 0ms
memory: 4740kb
input:
500 500 62 11 1 4 2 3 10 6 5 9 8 7 44 18 12 17 16 14 13 15 21 19 20 37 35 31 30 23 22 29 28 26 24 25 27 33 32 34 36 42 40 38 39 41 43 48 46 45 47 55 54 52 51 49 50 53 61 57 56 59 58 60 152 141 130 78 72 64 63 69 65 68 67 66 71 70 75 73 74 77 76 128 85 84 80 79 83 81 82 97 91 89 86 87 88 90 93 92 96 ...
output:
118898834
result:
ok 1 number(s): "118898834"
Test #59:
score: 0
Accepted
time: 2ms
memory: 4676kb
input:
500 2000 234 206 70 5 1 4 2 3 56 42 29 15 14 12 11 7 6 9 8 10 13 26 17 16 20 18 19 22 21 24 23 25 27 28 31 30 38 37 36 33 32 35 34 40 39 41 43 50 49 48 44 45 47 46 52 51 54 53 55 62 59 58 57 60 61 69 64 63 67 66 65 68 101 82 81 75 73 71 72 74 80 78 76 77 79 87 85 83 84 86 88 95 94 90 89 91 93 92 99 ...
output:
567391097
result:
ok 1 number(s): "567391097"
Test #60:
score: 0
Accepted
time: 11ms
memory: 4956kb
input:
500 125250 36 26 9 2 1 3 7 6 5 4 8 25 22 16 15 10 12 11 13 14 21 18 17 20 19 24 23 29 27 28 35 32 31 30 34 33 80 38 37 67 42 41 40 39 48 44 43 45 46 47 62 54 50 49 52 51 53 60 59 57 55 56 58 61 65 63 64 66 74 68 71 70 69 72 73 78 76 75 77 79 100 92 89 87 82 81 85 84 83 86 88 91 90 95 93 94 96 97 98 ...
output:
882819037
result:
ok 1 number(s): "882819037"
Test #61:
score: 0
Accepted
time: 0ms
memory: 4728kb
input:
500 500 215 39 16 4 3 1 2 6 5 15 10 9 7 8 12 11 14 13 21 20 19 18 17 23 22 25 24 35 26 27 30 28 29 32 31 34 33 38 36 37 98 42 40 41 75 65 58 45 43 44 55 49 48 47 46 53 50 52 51 54 57 56 64 62 60 59 61 63 71 66 70 69 67 68 74 73 72 96 76 91 84 81 79 78 77 80 83 82 89 86 85 87 88 90 94 93 92 95 97 132...
output:
384573809
result:
ok 1 number(s): "384573809"
Test #62:
score: 0
Accepted
time: 0ms
memory: 4740kb
input:
500 500 497 1 6 5 2 3 4 7 495 492 10 8 9 12 11 491 16 15 14 13 19 18 17 20 25 21 23 22 24 487 484 479 27 26 29 28 31 30 477 475 35 34 32 33 473 37 36 40 39 38 45 44 41 42 43 47 46 469 51 49 48 50 468 55 54 52 53 59 56 57 58 466 463 462 458 454 60 63 62 61 65 64 450 449 445 67 66 68 440 72 69 70 71 4...
output:
175047909
result:
ok 1 number(s): "175047909"
Test #63:
score: 0
Accepted
time: 2ms
memory: 4748kb
input:
500 3000 497 493 5 3 2 1 4 490 485 10 6 9 8 7 15 11 12 14 13 484 16 482 20 19 18 17 479 477 475 471 469 21 466 24 22 23 465 26 25 462 30 29 28 27 458 34 32 31 33 456 35 453 449 444 40 37 36 38 39 443 45 42 41 43 44 438 434 432 48 47 46 49 50 430 426 424 55 52 51 54 53 419 57 56 58 417 414 412 62 60 ...
output:
208249623
result:
ok 1 number(s): "208249623"
Test #64:
score: 0
Accepted
time: 2ms
memory: 4740kb
input:
500 500 4 1 2 3 499 496 492 6 5 488 485 8 7 483 481 10 9 15 13 12 11 14 20 18 17 16 19 478 477 21 475 25 23 22 24 26 30 29 27 28 34 32 31 33 38 35 37 36 470 42 41 40 39 469 46 45 43 44 464 459 457 456 453 51 50 49 47 48 449 56 53 52 55 54 57 59 58 60 61 448 443 441 64 63 62 440 68 67 65 66 73 71 70 ...
output:
57890760
result:
ok 1 number(s): "57890760"
Test #65:
score: 0
Accepted
time: 22ms
memory: 5328kb
input:
5000 20 2811 687 23 10 8 2 1 5 4 3 7 6 9 12 11 14 13 21 16 15 20 18 17 19 22 459 394 248 96 37 32 26 25 24 30 29 27 28 31 35 33 34 36 47 43 41 40 39 38 42 45 44 46 79 63 49 48 52 50 51 56 55 53 54 62 59 58 57 61 60 75 73 67 64 66 65 70 69 68 71 72 74 77 76 78 94 84 80 82 81 83 87 85 86 89 88 90 93 9...
output:
927919648
result:
ok 1 number(s): "927919648"
Test #66:
score: 0
Accepted
time: 17ms
memory: 5324kb
input:
5000 1000 3687 2811 1266 13 6 4 1 2 3 5 11 7 9 8 10 12 850 622 93 53 52 30 19 15 14 18 17 16 27 24 23 22 21 20 26 25 29 28 40 39 32 31 38 37 36 35 34 33 42 41 51 49 45 43 44 48 46 47 50 57 54 56 55 79 75 64 62 60 59 58 61 63 71 68 66 65 67 70 69 72 74 73 78 76 77 80 84 83 82 81 92 86 85 89 87 88 91 ...
output:
965999797
result:
ok 1 number(s): "965999797"
Test #67:
score: 0
Accepted
time: 15ms
memory: 5200kb
input:
5000 5000 4909 1283 241 76 50 36 7 3 1 2 6 4 5 19 15 9 8 13 10 12 11 14 18 16 17 30 20 28 27 21 23 22 24 25 26 29 32 31 34 33 35 42 41 38 37 39 40 49 46 43 44 45 47 48 67 52 51 54 53 57 56 55 61 59 58 60 62 63 64 66 65 71 68 69 70 75 72 74 73 187 87 83 79 78 77 81 80 82 86 85 84 92 90 88 89 91 125 1...
output:
462834466
result:
ok 1 number(s): "462834466"
Test #68:
score: 0
Accepted
time: 30ms
memory: 5144kb
input:
5000 200000 3441 3112 1065 678 466 324 8 1 7 5 4 2 3 6 169 36 35 9 17 13 12 10 11 16 14 15 30 25 23 18 20 19 21 22 24 26 27 29 28 32 31 33 34 65 61 50 49 45 37 42 41 40 38 39 43 44 46 48 47 52 51 54 53 60 58 57 56 55 59 63 62 64 108 97 72 70 69 66 68 67 71 75 73 74 92 80 78 76 77 79 90 83 82 81 86 8...
output:
944502858
result:
ok 1 number(s): "944502858"
Test #69:
score: 0
Accepted
time: 14ms
memory: 5136kb
input:
5000 5000 66 60 17 3 1 2 7 5 4 6 11 9 8 10 16 14 12 13 15 31 27 21 19 18 20 25 24 22 23 26 28 29 30 47 41 36 34 32 33 35 39 38 37 40 45 42 43 44 46 58 51 49 48 50 55 53 52 54 57 56 59 61 64 63 62 65 4137 4059 874 591 308 292 118 79 77 71 69 68 67 70 76 74 73 72 75 78 81 80 103 98 86 85 82 83 84 88 8...
output:
992123431
result:
ok 1 number(s): "992123431"
Test #70:
score: 0
Accepted
time: 7ms
memory: 5304kb
input:
5000 1000 4996 4991 5 3 1 2 4 4988 6 10 9 7 8 14 12 11 13 18 15 16 17 23 22 20 19 21 4984 25 24 4980 29 27 26 28 4979 32 30 31 4974 33 4973 34 37 35 36 4968 4967 4964 41 38 39 40 4961 43 42 45 44 47 46 4959 4955 49 48 4954 50 4950 52 51 57 54 53 55 56 60 58 59 63 62 61 64 4945 4944 65 4939 69 66 68 ...
output:
942332279
result:
ok 1 number(s): "942332279"
Test #71:
score: 0
Accepted
time: 9ms
memory: 5440kb
input:
5000 5000 4997 4995 4994 4991 4 1 2 3 4989 4984 4982 4981 4979 8 7 5 6 11 9 10 16 12 13 14 15 4975 4970 19 17 18 4966 4964 20 22 21 4959 4954 23 24 4949 26 25 30 28 27 29 4948 31 34 32 33 38 37 36 35 42 39 40 41 44 43 48 47 45 46 4947 53 50 49 52 51 58 54 55 56 57 4946 4942 61 59 60 4941 4936 4932 6...
output:
458864653
result:
ok 1 number(s): "458864653"
Test #72:
score: 0
Accepted
time: 20ms
memory: 5392kb
input:
5000 200000 4997 4 1 2 3 6 5 4995 4991 10 8 7 9 4989 4986 12 11 4981 4976 4974 13 4972 14 4971 17 15 16 4970 19 18 4968 20 4965 4962 22 21 4959 25 24 23 4954 27 26 31 30 28 29 4949 33 32 4945 4944 34 38 35 37 36 40 39 4939 4936 43 42 41 4933 45 44 49 48 47 46 50 4930 54 52 51 53 55 4927 4925 59 58 5...
output:
248680221
result:
ok 1 number(s): "248680221"
Test #73:
score: 0
Accepted
time: 4ms
memory: 5368kb
input:
5000 5000 4998 4 1 2 3 8 6 5 7 4994 4993 4992 4989 4985 4983 4982 9 13 11 10 12 14 18 15 16 17 23 22 19 21 20 25 24 4978 4976 4974 4973 26 30 29 28 27 31 32 4972 4969 4968 33 4967 4962 38 35 34 36 37 43 39 40 41 42 44 4959 48 47 45 46 53 51 50 49 52 4956 4951 55 54 4950 59 58 57 56 4948 4943 62 60 6...
output:
284890525
result:
ok 1 number(s): "284890525"
Test #74:
score: 0
Accepted
time: 1ms
memory: 4836kb
input:
2 1 1 0 2
output:
5
result:
ok 1 number(s): "5"
Test #75:
score: 0
Accepted
time: 1ms
memory: 4908kb
input:
3 1 2 1 2 3
output:
21
result:
ok 1 number(s): "21"
Test #76:
score: 0
Accepted
time: 766ms
memory: 21828kb
input:
100000 1 94687 15935 4789 3507 2824 2099 1138 92 75 24 23 19 3 2 1 4 16 12 5 7 6 10 9 8 11 14 13 15 18 17 22 21 20 59 33 27 25 26 28 29 31 30 32 48 39 37 35 34 36 38 46 40 44 43 41 42 45 47 58 57 56 51 49 50 53 52 55 54 69 60 64 61 63 62 67 65 66 68 71 70 73 72 74 82 80 76 78 77 79 81 90 89 88 87 83...
output:
54900200
result:
ok 1 number(s): "54900200"
Test #77:
score: 0
Accepted
time: 1743ms
memory: 39544kb
input:
199999 1 39981 30792 15067 5153 4932 1167 698 157 7 2 1 4 3 6 5 141 37 23 17 8 14 12 10 9 11 13 15 16 20 18 19 22 21 24 35 26 25 29 27 28 33 32 30 31 34 36 109 74 71 51 39 38 48 42 41 40 44 43 45 46 47 49 50 59 57 53 52 55 54 56 58 69 61 60 63 62 64 67 65 66 68 70 72 73 93 92 79 75 78 77 76 85 83 81...
output:
426286730
result:
ok 1 number(s): "426286730"
Test #78:
score: 0
Accepted
time: 1731ms
memory: 39464kb
input:
200000 1 4305 116 59 32 3 2 1 9 6 4 5 8 7 17 14 11 10 13 12 15 16 25 21 20 19 18 24 22 23 26 31 29 27 28 30 57 45 41 39 36 35 34 33 38 37 40 44 42 43 49 46 47 48 56 53 50 51 52 54 55 58 104 86 82 72 63 61 60 62 68 67 66 65 64 70 69 71 79 78 75 73 74 77 76 81 80 84 83 85 88 87 90 89 95 94 93 91 92 10...
output:
107301064
result:
ok 1 number(s): "107301064"
Test #79:
score: 0
Accepted
time: 623ms
memory: 39904kb
input:
199999 1 2 1 4 3 199995 199994 199990 5 199988 6 199983 199980 199975 11 8 7 10 9 199970 199968 13 12 199967 17 14 16 15 22 20 18 19 21 199963 199961 27 24 23 26 25 199957 29 28 30 199955 199954 199952 199949 31 199946 199942 199941 199937 199936 33 32 37 36 35 34 199931 42 38 40 39 41 199927 199924...
output:
924406167
result:
ok 1 number(s): "924406167"
Test #80:
score: 0
Accepted
time: 634ms
memory: 39808kb
input:
200000 1 4 1 3 2 199995 7 6 5 199993 199991 199988 199985 9 8 199981 199977 10 15 14 13 11 12 199973 199972 199970 199969 199967 199965 20 16 17 18 19 199962 23 22 21 25 24 199957 29 26 28 27 32 30 31 35 33 34 199953 199950 199946 199941 199938 40 39 37 36 38 199936 199933 199931 44 42 41 43 45 46 1...
output:
527773965
result:
ok 1 number(s): "527773965"
Test #81:
score: 0
Accepted
time: 1ms
memory: 4904kb
input:
3 2 2 1 0 1 1 3
output:
15
result:
ok 1 number(s): "15"
Test #82:
score: 0
Accepted
time: 1ms
memory: 4668kb
input:
3 3 1 2 1 2 1 3 2 3
output:
18
result:
ok 1 number(s): "18"
Test #83:
score: 0
Accepted
time: 0ms
memory: 4672kb
input:
3 4 1 2 0 1 0 3 1 3 2 3
output:
14
result:
ok 1 number(s): "14"
Test #84:
score: 0
Accepted
time: 1ms
memory: 4672kb
input:
3 5 1 2 0 2 0 3 1 2 1 3 2 3
output:
14
result:
ok 1 number(s): "14"
Test #85:
score: 0
Accepted
time: 0ms
memory: 4672kb
input:
4 5 3 1 2 0 1 0 4 1 3 2 3 3 4
output:
48
result:
ok 1 number(s): "48"
Test #86:
score: 0
Accepted
time: 1769ms
memory: 39520kb
input:
200000 2 124275 43227 4823 1132 356 148 114 13 1 9 8 5 2 3 4 6 7 10 11 12 44 20 17 15 14 16 19 18 28 25 21 23 22 24 26 27 41 40 29 34 30 33 31 32 35 37 36 38 39 43 42 106 61 48 45 47 46 51 50 49 53 52 60 58 54 55 56 57 59 100 91 66 64 62 63 65 84 71 69 68 67 70 81 77 75 72 73 74 76 80 78 79 82 83 89...
output:
182581647
result:
ok 1 number(s): "182581647"
Test #87:
score: 0
Accepted
time: 1750ms
memory: 39516kb
input:
200000 3 55475 15157 4293 2033 1645 1050 649 526 402 266 109 26 8 6 1 5 2 4 3 7 22 12 9 10 11 14 13 20 19 16 15 18 17 21 25 23 24 81 36 27 33 31 28 29 30 32 34 35 45 37 41 40 38 39 44 42 43 68 50 49 47 46 48 59 54 52 51 53 58 56 55 57 65 61 60 64 63 62 67 66 75 71 69 70 73 72 74 76 78 77 79 80 100 8...
output:
43886574
result:
ok 1 number(s): "43886574"
Test #88:
score: 0
Accepted
time: 1712ms
memory: 39620kb
input:
200000 4 175445 72142 54296 37617 24691 23785 12914 4994 4152 4 2 1 3 2035 409 177 136 39 21 13 8 6 5 7 11 9 10 12 16 15 14 18 17 20 19 36 23 22 27 24 25 26 30 28 29 33 32 31 34 35 37 38 131 83 80 44 40 42 41 43 53 45 51 48 46 47 49 50 52 54 77 76 66 56 55 60 57 58 59 61 62 63 64 65 71 69 67 68 70 7...
output:
498767188
result:
ok 1 number(s): "498767188"
Test #89:
score: 0
Accepted
time: 1737ms
memory: 39504kb
input:
200000 5 106645 97838 57664 23376 20725 10759 1247 516 172 101 65 1 57 45 21 7 4 2 3 6 5 16 15 11 8 10 9 14 13 12 19 17 18 20 39 34 33 29 24 22 23 28 27 26 25 32 31 30 35 36 37 38 40 41 44 42 43 52 50 46 49 48 47 51 54 53 55 56 62 58 59 61 60 63 64 100 94 75 70 67 66 68 69 72 71 73 74 86 82 77 76 81...
output:
613008198
result:
ok 1 number(s): "613008198"
Test #90:
score: 0
Accepted
time: 628ms
memory: 39752kb
input:
200000 2 2 1 7 6 5 3 4 199998 12 9 8 10 11 199993 13 199990 199985 199980 17 15 14 16 19 18 20 24 22 21 23 27 26 25 28 199978 33 29 31 30 32 36 35 34 199973 39 38 37 199969 43 40 41 42 44 199968 47 45 46 52 51 50 48 49 55 53 54 58 57 56 59 60 65 64 62 61 63 67 66 199965 199963 72 68 70 69 71 76 74 7...
output:
449030945
result:
ok 1 number(s): "449030945"
Test #91:
score: 0
Accepted
time: 618ms
memory: 39724kb
input:
200000 3 2 1 199995 199993 3 199989 7 4 6 5 9 8 12 11 10 15 13 14 199985 199983 199980 19 17 16 18 199978 22 21 20 199976 199973 26 23 25 24 28 27 33 29 32 30 31 199971 199968 199963 36 34 35 199962 199959 41 37 39 38 40 42 199957 199955 199950 199949 44 43 199945 47 45 46 51 50 48 49 199941 52 1999...
output:
300585770
result:
ok 1 number(s): "300585770"
Test #92:
score: 0
Accepted
time: 632ms
memory: 39744kb
input:
200000 4 1 199996 6 4 3 2 5 8 7 11 10 9 199995 12 13 17 14 16 15 199991 19 18 199987 21 20 22 24 23 199983 199978 29 27 26 25 28 199975 199974 199970 199969 33 32 30 31 38 34 36 35 37 40 39 199966 45 42 41 44 43 48 47 46 53 49 52 50 51 54 199965 57 56 55 58 199960 60 59 199957 65 64 63 61 62 67 66 7...
output:
772992430
result:
ok 1 number(s): "772992430"
Test #93:
score: 0
Accepted
time: 623ms
memory: 39840kb
input:
200000 5 1 199995 6 5 3 2 4 199993 199989 11 9 8 7 10 199988 13 12 199986 199985 199984 14 15 199983 199979 199974 16 199969 18 17 199965 199961 199959 22 20 19 21 26 23 24 25 199955 199951 27 199950 28 199945 199940 30 29 35 33 32 31 34 39 37 36 38 199936 41 40 199931 42 199930 44 43 47 45 46 50 49...
output:
713625740
result:
ok 1 number(s): "713625740"
Test #94:
score: 0
Accepted
time: 1ms
memory: 4612kb
input:
2 2 1 0 1 0 2
output:
4
result:
ok 1 number(s): "4"
Test #95:
score: 0
Accepted
time: 1ms
memory: 4600kb
input:
3 3 1 2 0 1 0 2 0 3
output:
14
result:
ok 1 number(s): "14"
Test #96:
score: 0
Accepted
time: 1ms
memory: 4616kb
input:
4 4 1 2 3 0 1 0 2 0 3 0 4
output:
48
result:
ok 1 number(s): "48"
Test #97:
score: 0
Accepted
time: 0ms
memory: 4616kb
input:
10 10 8 2 1 3 4 6 5 7 9 0 1 0 2 0 3 0 4 0 5 0 6 0 7 0 8 0 9 0 10
output:
71296
result:
ok 1 number(s): "71296"
Test #98:
score: 0
Accepted
time: 1ms
memory: 4908kb
input:
100 100 71 14 3 1 2 9 6 4 5 8 7 13 12 11 10 60 51 27 20 17 16 15 18 19 21 23 22 25 24 26 43 40 35 28 33 29 31 30 32 34 39 36 38 37 41 42 50 44 48 47 45 46 49 55 52 54 53 59 58 56 57 69 65 61 64 62 63 66 68 67 70 74 73 72 87 78 77 75 76 80 79 86 81 85 83 82 84 99 92 90 88 89 91 98 94 93 96 95 97 0 1 ...
output:
614246259
result:
ok 1 number(s): "614246259"
Test #99:
score: 0
Accepted
time: 0ms
memory: 4752kb
input:
1000 1000 884 218 75 24 15 11 1 8 2 3 7 6 5 4 10 9 14 13 12 17 16 23 20 18 19 22 21 41 25 28 27 26 36 31 30 29 33 32 35 34 37 38 40 39 69 51 46 44 43 42 45 50 49 47 48 57 54 53 52 56 55 65 61 58 59 60 64 62 63 66 67 68 70 73 72 71 74 201 150 140 83 79 76 78 77 81 80 82 135 102 87 86 84 85 98 91 90 8...
output:
490260340
result:
ok 1 number(s): "490260340"
Test #100:
score: 0
Accepted
time: 31ms
memory: 6048kb
input:
10000 10000 4195 1722 1337 767 660 561 320 27 8 4 1 2 3 7 5 6 15 11 10 9 12 14 13 18 16 17 19 26 24 21 20 23 22 25 164 62 52 36 29 28 34 30 31 32 33 35 45 37 42 40 38 39 41 44 43 46 50 48 47 49 51 61 53 54 60 58 55 56 57 59 109 70 64 63 69 65 68 67 66 99 73 72 71 75 74 87 85 79 78 76 77 84 80 83 82 ...
output:
875958203
result:
ok 1 number(s): "875958203"
Test #101:
score: 0
Accepted
time: 433ms
memory: 19196kb
input:
100000 100000 31189 14939 12564 1034 307 29 11 3 2 1 7 4 6 5 9 8 10 15 14 13 12 28 27 17 16 24 20 18 19 21 22 23 26 25 150 135 93 54 49 43 35 30 34 32 31 33 38 37 36 42 39 41 40 44 47 46 45 48 51 50 53 52 71 64 58 55 57 56 63 60 59 62 61 70 67 66 65 69 68 78 76 72 73 75 74 77 87 83 82 79 81 80 86 84...
output:
646402656
result:
ok 1 number(s): "646402656"
Test #102:
score: 0
Accepted
time: 967ms
memory: 33980kb
input:
199999 199999 43677 26620 24009 1060 922 441 387 12 5 3 2 1 4 10 7 6 8 9 11 201 20 14 13 17 15 16 18 19 130 29 22 21 28 23 27 26 25 24 54 46 37 33 31 30 32 36 35 34 41 38 40 39 43 42 44 45 53 50 49 47 48 51 52 55 121 78 70 66 65 64 63 60 57 56 59 58 61 62 67 68 69 75 73 71 72 74 76 77 87 84 80 79 83...
output:
459959065
result:
ok 1 number(s): "459959065"
Test #103:
score: 0
Accepted
time: 941ms
memory: 34092kb
input:
200000 200000 23147 4701 1478 883 200 73 53 52 44 42 26 5 1 4 3 2 17 12 9 8 7 6 11 10 16 13 14 15 25 21 18 19 20 22 23 24 32 27 30 28 29 31 34 33 36 35 38 37 40 39 41 43 48 45 46 47 51 50 49 65 59 56 54 55 57 58 62 61 60 63 64 68 67 66 69 70 71 72 148 76 74 75 135 131 97 78 77 83 81 79 80 82 92 86 8...
output:
121976102
result:
ok 1 number(s): "121976102"
Test #104:
score: 0
Accepted
time: 388ms
memory: 34304kb
input:
199998 199998 5 3 2 1 4 199997 199994 199989 9 6 7 8 11 10 199984 199983 199982 16 15 13 12 14 199977 199972 199967 19 17 18 199966 20 199963 199961 22 21 27 23 25 24 26 199960 30 28 29 199959 199954 32 31 33 35 34 37 36 199953 199952 38 199950 199946 199944 199939 199938 43 40 39 42 41 47 44 45 46 ...
output:
303906212
result:
ok 1 number(s): "303906212"
Test #105:
score: 0
Accepted
time: 384ms
memory: 34264kb
input:
199999 199999 5 1 2 4 3 199995 6 199993 8 7 199988 199986 199982 11 9 10 199980 199977 199972 199967 15 13 12 14 199964 16 20 17 18 19 21 199963 199962 199959 25 24 22 23 26 199958 199957 28 27 30 29 32 31 36 35 33 34 38 37 39 42 41 40 199954 199953 47 44 43 45 46 48 51 49 50 199950 55 54 53 52 1999...
output:
891471459
result:
ok 1 number(s): "891471459"
Test #106:
score: 0
Accepted
time: 379ms
memory: 34292kb
input:
200000 200000 199998 199995 199994 199993 5 1 2 3 4 199989 7 6 199985 199980 199976 199975 199973 199972 199970 199968 10 9 8 13 12 11 199967 199962 199961 199956 199954 199950 199949 16 14 15 199947 18 17 22 20 19 21 199943 26 23 24 25 199941 199936 199932 199928 28 27 199924 199922 199921 29 19992...
output:
228098903
result:
ok 1 number(s): "228098903"
Test #107:
score: 0
Accepted
time: 49ms
memory: 7992kb
input:
13327 13327 13326 6663 6185 3092 1546 773 386 193 96 48 24 12 6 3 1 2 4 5 9 7 8 10 11 18 15 13 14 16 17 21 19 20 22 23 36 30 27 25 26 28 29 33 31 32 34 35 42 39 37 38 40 41 45 43 44 46 47 72 60 54 51 49 50 52 53 57 55 56 58 59 66 63 61 62 64 65 69 67 68 70 71 84 78 75 73 74 76 77 81 79 80 82 83 90 8...
output:
903762303
result:
ok 1 number(s): "903762303"
Test #108:
score: 0
Accepted
time: 49ms
memory: 6356kb
input:
13327 13327 13326 6663 6185 3092 1546 773 386 193 96 48 24 12 6 1 2 3 4 5 9 7 8 10 11 18 15 13 14 16 17 21 19 20 22 23 36 30 27 25 26 28 29 33 31 32 34 35 42 39 37 38 40 41 45 43 44 46 47 72 60 54 51 49 50 52 53 57 55 56 58 59 66 63 61 62 64 65 69 67 68 70 71 84 78 75 73 74 76 77 81 79 80 82 83 90 8...
output:
677206413
result:
ok 1 number(s): "677206413"
Test #109:
score: 0
Accepted
time: 52ms
memory: 6316kb
input:
13326 13326 6663 6185 3092 1546 773 386 193 96 48 24 12 6 3 1 2 4 5 9 7 8 10 11 18 15 13 14 16 17 21 19 20 22 23 36 30 27 25 26 28 29 33 31 32 34 35 42 39 37 38 40 41 45 43 44 46 47 72 60 54 51 49 50 52 53 57 55 56 58 59 66 63 61 62 64 65 69 67 68 70 71 84 78 75 73 74 76 77 81 79 80 82 83 90 87 85 8...
output:
0
result:
ok 1 number(s): "0"
Test #110:
score: 0
Accepted
time: 45ms
memory: 5952kb
input:
10000 200000 461 103 46 4 2 1 3 43 15 5 7 6 13 8 11 9 10 12 14 36 20 17 16 19 18 32 27 25 21 22 24 23 26 30 29 28 31 35 34 33 42 41 38 37 39 40 44 45 86 68 55 54 52 48 47 50 49 51 53 60 59 58 56 57 61 63 62 64 65 66 67 83 77 69 76 75 72 71 70 73 74 79 78 82 81 80 84 85 90 87 89 88 94 92 91 93 101 95...
output:
406238058
result:
ok 1 number(s): "406238058"
Test #111:
score: 0
Accepted
time: 438ms
memory: 19192kb
input:
100000 200000 80572 52725 39147 13136 10126 1640 134 61 38 20 4 2 1 3 10 8 7 6 5 9 11 19 12 18 13 16 14 15 17 35 25 21 24 23 22 26 28 27 29 30 31 33 32 34 36 37 52 43 40 39 42 41 50 49 47 46 44 45 48 51 58 56 55 54 53 57 60 59 112 64 62 63 86 85 67 65 66 74 73 72 71 68 70 69 78 77 76 75 83 82 80 79 ...
output:
112475316
result:
ok 1 number(s): "112475316"
Test #112:
score: 0
Accepted
time: 1690ms
memory: 39580kb
input:
200000 10 30854 5167 4255 907 815 721 350 119 118 67 43 1 29 12 3 2 10 9 5 4 8 7 6 11 19 13 14 17 15 16 18 20 25 21 24 22 23 27 26 28 40 34 33 32 30 31 35 38 37 36 39 41 42 47 46 45 44 56 49 48 53 52 51 50 55 54 58 57 63 60 59 62 61 66 65 64 103 72 69 68 70 71 86 74 73 80 76 75 77 78 79 83 81 82 84 ...
output:
245341633
result:
ok 1 number(s): "245341633"
Test #113:
score: 0
Accepted
time: 1646ms
memory: 39648kb
input:
200000 20 29031 24947 12635 6350 5630 5077 4412 1230 1194 455 215 137 115 67 43 3 1 2 28 17 6 5 4 16 12 10 8 7 9 11 13 14 15 23 20 19 18 21 22 25 24 26 27 41 32 31 30 29 39 36 33 35 34 37 38 40 42 63 57 53 47 46 44 45 50 49 48 52 51 55 54 56 58 60 59 61 62 66 65 64 90 71 68 69 70 77 72 74 73 75 76 8...
output:
326899139
result:
ok 1 number(s): "326899139"
Test #114:
score: 0
Accepted
time: 1561ms
memory: 39584kb
input:
200000 50 157867 111962 29766 13620 12379 10622 9272 1468 623 100 23 12 5 2 1 4 3 8 7 6 9 10 11 19 16 13 15 14 17 18 22 21 20 67 56 41 33 26 24 25 27 30 28 29 31 32 38 35 34 37 36 40 39 54 53 47 45 43 42 44 46 51 49 48 50 52 55 62 61 58 57 59 60 64 63 66 65 90 85 68 84 75 71 69 70 73 72 74 80 77 76 ...
output:
565344166
result:
ok 1 number(s): "565344166"
Test #115:
score: 0
Accepted
time: 1534ms
memory: 39580kb
input:
200000 100 24471 5360 3862 396 284 138 22 3 2 1 16 4 9 7 5 6 8 13 10 12 11 15 14 20 17 19 18 21 127 51 39 33 30 23 29 25 24 27 26 28 32 31 37 36 35 34 38 42 40 41 46 44 43 45 47 48 49 50 91 83 62 53 52 59 55 54 58 57 56 60 61 74 72 63 66 64 65 69 67 68 70 71 73 77 75 76 80 78 79 81 82 90 87 84 86 85...
output:
56996486
result:
ok 1 number(s): "56996486"
Test #116:
score: 0
Accepted
time: 1462ms
memory: 39576kb
input:
200000 200 56711 47863 41971 22386 17492 4152 1271 612 550 375 317 279 167 10 6 3 1 2 5 4 7 8 9 89 66 15 12 11 13 14 60 45 35 20 19 16 18 17 25 24 23 22 21 32 31 30 29 27 26 28 33 34 40 37 36 38 39 43 42 41 44 59 47 46 58 52 51 48 49 50 57 55 53 54 56 65 62 61 63 64 80 70 67 69 68 76 74 71 72 73 75 ...
output:
335141608
result:
ok 1 number(s): "335141608"
Test #117:
score: 0
Accepted
time: 1425ms
memory: 39580kb
input:
200000 500 142203 48936 22845 22275 15156 10452 6047 1908 801 322 195 172 23 20 7 2 1 5 4 3 6 12 10 9 8 11 13 16 15 14 18 17 19 22 21 27 24 26 25 82 53 46 42 40 37 31 29 28 30 36 34 33 32 35 38 39 41 44 43 45 47 52 51 50 49 48 72 55 54 59 57 56 58 61 60 71 67 64 62 63 66 65 70 68 69 77 74 73 75 76 8...
output:
837766124
result:
ok 1 number(s): "837766124"
Test #118:
score: 0
Accepted
time: 1415ms
memory: 39548kb
input:
200000 1000 99940 83118 32838 29563 28568 18514 1937 1612 482 353 44 18 2 1 4 3 9 7 6 5 8 10 13 11 12 17 15 14 16 20 19 33 28 27 23 22 21 25 24 26 30 29 32 31 40 39 37 35 34 36 38 42 41 43 86 49 47 45 46 48 79 50 72 65 58 57 53 51 52 54 56 55 64 59 62 60 61 63 68 66 67 69 70 71 75 74 73 76 78 77 85 ...
output:
976889971
result:
ok 1 number(s): "976889971"
Test #119:
score: 0
Accepted
time: 1207ms
memory: 39304kb
input:
200000 10000 11819 5742 3664 3200 791 411 7 6 1 3 2 4 5 184 58 41 20 14 8 9 13 11 10 12 17 15 16 18 19 28 24 23 22 21 27 25 26 29 33 32 30 31 35 34 36 40 38 37 39 45 43 42 44 54 53 52 46 48 47 51 50 49 55 57 56 155 86 75 67 63 60 59 62 61 65 64 66 71 68 69 70 74 72 73 84 82 78 76 77 81 79 80 83 85 1...
output:
159288979
result:
ok 1 number(s): "159288979"
Test #120:
score: 0
Accepted
time: 1166ms
memory: 38692kb
input:
200000 20000 72970 42061 7644 5479 606 489 26 18 14 7 2 1 6 4 3 5 9 8 12 10 11 13 15 16 17 25 20 19 21 22 24 23 169 99 56 45 40 30 29 27 28 33 32 31 38 37 35 34 36 39 41 44 42 43 49 46 48 47 50 54 51 53 52 55 84 69 63 60 57 58 59 61 62 66 65 64 68 67 79 74 72 71 70 73 76 75 78 77 81 80 83 82 97 91 8...
output:
185731487
result:
ok 1 number(s): "185731487"
Test #121:
score: 0
Accepted
time: 1087ms
memory: 37904kb
input:
200000 50000 158723 150744 3080 2212 725 85 73 3 2 1 49 26 4 5 14 12 9 6 7 8 10 11 13 24 17 15 16 23 18 19 22 20 21 25 39 27 36 35 34 30 28 29 32 31 33 38 37 42 41 40 44 43 47 45 46 48 67 57 52 51 50 54 53 55 56 63 62 59 58 61 60 66 64 65 70 69 68 72 71 76 75 74 81 78 77 79 80 84 83 82 379 211 157 9...
output:
145898857
result:
ok 1 number(s): "145898857"
Test #122:
score: 0
Accepted
time: 1057ms
memory: 36568kb
input:
200000 100000 83103 18085 6593 1139 322 320 225 97 60 21 8 1 6 5 4 2 3 7 9 18 10 14 13 11 12 16 15 17 19 20 56 49 39 27 25 24 22 23 26 31 28 30 29 32 33 35 34 38 36 37 42 41 40 48 46 44 43 45 47 52 51 50 53 54 55 57 58 59 79 74 64 62 61 63 68 65 67 66 73 71 69 70 72 76 75 77 78 92 85 80 84 82 81 83 ...
output:
146686318
result:
ok 1 number(s): "146686318"
Test #123:
score: 0
Accepted
time: 982ms
memory: 34732kb
input:
199999 200000 148657 5359 2416 1471 777 736 145 139 108 85 79 44 38 22 14 11 10 2 1 5 4 3 8 7 6 9 13 12 20 16 15 17 19 18 21 33 25 23 24 32 30 28 27 26 29 31 35 34 37 36 43 40 39 42 41 67 58 51 47 45 46 49 48 50 54 53 52 57 55 56 59 65 60 62 61 63 64 66 77 68 72 69 70 71 76 75 74 73 78 82 80 81 83 8...
output:
160174881
result:
ok 1 number(s): "160174881"
Test #124:
score: 0
Accepted
time: 973ms
memory: 34828kb
input:
200000 199999 28800 24159 19396 17100 2062 1885 91 55 12 6 3 1 2 4 5 10 7 8 9 11 39 18 13 17 14 15 16 30 25 24 22 20 19 21 23 28 26 27 29 36 34 31 32 33 35 38 37 50 44 43 40 41 42 49 47 45 46 48 51 52 53 54 63 56 57 61 58 59 60 62 78 77 67 65 64 66 75 71 70 68 69 74 72 73 76 88 80 79 83 82 81 86 84 ...
output:
269759742
result:
ok 1 number(s): "269759742"
Test #125:
score: 0
Accepted
time: 1007ms
memory: 34864kb
input:
200000 200000 107152 2973 2450 1482 1319 216 29 19 7 5 3 2 1 4 6 16 8 9 15 12 10 11 14 13 18 17 21 20 26 25 22 23 24 28 27 146 88 58 39 35 34 33 32 31 30 37 36 38 49 42 40 41 46 43 44 45 48 47 52 51 50 54 53 55 57 56 73 70 69 62 61 59 60 64 63 66 65 67 68 71 72 80 79 75 74 77 76 78 86 82 81 83 85 84...
output:
17504745
result:
ok 1 number(s): "17504745"
Test #126:
score: 0
Accepted
time: 28ms
memory: 5912kb
input:
10000 200000 9999 9994 5 4 3 1 2 6 9992 11 10 9 7 8 13 12 9991 9987 17 15 14 16 9984 9982 9981 9979 9975 9970 9965 21 18 20 19 26 22 25 23 24 9960 31 29 28 27 30 36 34 33 32 35 9959 9954 9953 9949 9944 38 37 42 40 39 41 46 45 44 43 47 9940 48 50 49 55 54 51 53 52 9938 57 56 59 58 62 61 60 66 63 64 6...
output:
360321326
result:
ok 1 number(s): "360321326"
Test #127:
score: 0
Accepted
time: 198ms
memory: 19308kb
input:
100000 200000 3 1 2 99995 99994 6 5 4 99989 99987 99982 99980 99976 11 7 8 10 9 99975 12 99974 13 16 14 15 99972 19 17 18 23 22 20 21 99968 99967 99964 99959 28 25 24 26 27 32 31 29 30 99957 99955 99953 34 33 39 37 36 35 38 40 42 41 99952 99951 99949 99944 46 44 43 45 49 48 47 50 51 52 57 56 54 53 5...
output:
110743646
result:
ok 1 number(s): "110743646"
Test #128:
score: 0
Accepted
time: 608ms
memory: 39764kb
input:
200000 10 3 1 2 199997 5 4 199995 8 6 7 10 9 11 199994 199992 199990 199988 199985 16 12 13 15 14 18 17 20 19 199981 24 21 23 22 199980 27 26 25 28 199979 199976 199973 199970 31 29 30 36 33 32 35 34 37 39 38 199967 42 41 40 199965 43 199960 199955 44 48 46 45 47 52 49 50 51 199953 199948 55 53 54 6...
output:
903009002
result:
ok 1 number(s): "903009002"
Test #129:
score: 0
Accepted
time: 622ms
memory: 39752kb
input:
200000 20 3 2 1 4 5 9 8 6 7 14 11 10 12 13 16 15 18 17 19 199998 199996 199995 24 21 20 22 23 27 26 25 28 199990 30 29 32 31 199988 37 33 35 34 36 199986 199985 199984 39 38 43 40 42 41 199979 199977 199973 199971 47 44 45 46 199967 51 48 49 50 55 52 53 54 60 58 56 57 59 199964 199963 62 61 63 67 64...
output:
78340456
result:
ok 1 number(s): "78340456"
Test #130:
score: 0
Accepted
time: 634ms
memory: 39848kb
input:
200000 50 5 1 4 3 2 9 6 8 7 12 10 11 199999 15 13 14 19 16 17 18 20 199997 199993 24 22 21 23 199988 199985 199980 199978 25 28 26 27 199975 29 33 32 30 31 199970 199967 37 35 34 36 42 39 38 41 40 45 44 43 199964 199963 199960 47 46 199955 48 199953 199948 53 52 51 50 49 58 56 54 55 57 59 199945 199...
output:
997438867
result:
ok 1 number(s): "997438867"
Test #131:
score: 0
Accepted
time: 621ms
memory: 39708kb
input:
200000 100 199997 1 3 2 7 6 5 4 12 11 9 8 10 13 14 199995 17 16 15 18 199991 199988 199985 199982 20 19 199980 23 21 22 199975 199972 199970 199968 27 25 24 26 199964 199961 30 28 29 35 34 31 33 32 39 38 37 36 43 40 41 42 44 199957 199954 199952 199949 45 49 48 47 46 53 52 51 50 199948 56 54 55 58 5...
output:
751622484
result:
ok 1 number(s): "751622484"
Test #132:
score: 0
Accepted
time: 616ms
memory: 39752kb
input:
200000 200 199995 199991 199990 199985 199980 199977 199975 199970 3 1 2 7 6 5 4 199967 9 8 199964 199959 10 199957 199952 199951 12 11 16 14 13 15 17 19 18 199949 199945 199944 199942 199939 21 20 22 199934 199933 24 23 199929 199924 199922 199919 26 25 199918 29 27 28 34 31 30 32 33 199913 37 36 3...
output:
699912733
result:
ok 1 number(s): "699912733"
Test #133:
score: 0
Accepted
time: 620ms
memory: 39752kb
input:
200000 500 3 1 2 8 4 5 7 6 13 11 10 9 12 18 17 16 15 14 199999 199995 19 199993 20 21 23 22 24 29 26 25 28 27 31 30 33 32 199988 199984 199982 37 36 34 35 199981 199980 199977 199973 41 38 39 40 42 199972 199968 199966 45 43 44 199962 50 47 46 48 49 54 52 51 53 56 55 58 57 61 60 59 199957 66 64 62 6...
output:
754861231
result:
ok 1 number(s): "754861231"
Test #134:
score: 0
Accepted
time: 609ms
memory: 39788kb
input:
200000 1000 199996 199995 3 1 2 199991 6 5 4 11 9 7 8 10 199988 199983 199978 13 12 199974 199970 199969 199965 14 199964 16 15 17 21 19 18 20 199963 26 22 23 25 24 27 199960 199955 30 28 29 34 31 33 32 199950 199946 37 35 36 199942 199940 199935 199934 199933 39 38 199932 43 40 41 42 44 46 45 49 47...
output:
846865308
result:
ok 1 number(s): "846865308"
Test #135:
score: 0
Accepted
time: 599ms
memory: 39488kb
input:
200000 10000 199996 199991 199988 199983 3 2 1 199981 199979 6 4 5 9 7 8 14 12 11 10 13 199978 199977 199974 199972 19 18 15 17 16 199967 199963 199958 24 22 20 21 23 199954 27 25 26 31 30 29 28 33 32 199952 36 34 35 199951 38 37 40 39 43 41 42 199949 48 47 45 44 46 50 49 51 199945 52 53 58 57 54 55...
output:
658784652
result:
ok 1 number(s): "658784652"
Test #136:
score: 0
Accepted
time: 584ms
memory: 39244kb
input:
200000 20000 4 1 2 3 8 7 5 6 13 9 12 10 11 199997 14 16 15 199996 20 19 18 17 22 21 25 24 23 29 27 26 28 199993 32 31 30 199989 37 33 35 34 36 199988 40 39 38 44 41 43 42 48 45 47 46 199985 199982 199978 50 49 199974 54 52 51 53 199969 55 60 58 57 56 59 65 63 62 61 64 70 69 67 66 68 199968 73 71 72 ...
output:
392055844
result:
ok 1 number(s): "392055844"
Test #137:
score: 0
Accepted
time: 544ms
memory: 38392kb
input:
200000 50000 199998 199996 4 3 2 1 199995 199994 199991 199987 199985 5 7 6 199984 199979 8 199975 10 9 199970 199969 15 13 12 11 14 199968 17 16 20 18 19 22 21 27 24 23 26 25 31 30 28 29 199966 199962 36 32 33 35 34 38 37 41 39 40 199961 46 44 42 43 45 199958 51 48 47 50 49 199955 199952 199950 199...
output:
74961467
result:
ok 1 number(s): "74961467"
Test #138:
score: 0
Accepted
time: 490ms
memory: 37092kb
input:
200000 100000 5 4 3 2 1 199998 10 9 8 7 6 13 12 11 15 14 199996 199995 199991 19 18 17 16 199990 21 20 23 22 24 199989 27 25 26 199984 29 28 199980 199976 199974 199972 34 33 32 31 30 199971 199970 35 199966 39 36 38 37 43 40 42 41 47 46 45 44 49 48 54 50 53 51 52 199964 59 55 58 57 56 199960 199956...
output:
27019826
result:
ok 1 number(s): "27019826"
Test #139:
score: 0
Accepted
time: 417ms
memory: 35620kb
input:
199999 200000 199994 3 2 1 7 6 5 4 199993 199988 199984 199980 12 9 8 10 11 14 13 199977 199974 17 16 15 199969 199965 199964 18 199963 23 20 19 21 22 199960 28 25 24 27 26 199956 33 32 29 30 31 35 34 199953 40 36 39 38 37 199950 199948 199944 44 41 43 42 199941 45 50 49 46 47 48 52 51 56 54 53 55 5...
output:
10648822
result:
ok 1 number(s): "10648822"
Test #140:
score: 0
Accepted
time: 428ms
memory: 35812kb
input:
200000 199999 199996 199994 2 1 199993 6 3 5 4 9 7 8 11 10 14 12 13 199989 199986 15 199982 199980 18 17 16 199979 199974 199973 19 199971 23 20 21 22 199966 199961 199957 199955 199952 199949 26 25 24 27 199944 29 28 31 30 35 32 33 34 39 36 37 38 199942 41 40 199938 199936 199935 46 44 43 42 45 51 ...
output:
184259513
result:
ok 1 number(s): "184259513"
Test #141:
score: 0
Accepted
time: 582ms
memory: 35752kb
input:
200000 200000 1 4 3 2 5 7 6 199997 199995 9 8 199990 199985 14 13 12 10 11 15 199984 17 16 19 18 21 20 25 24 22 23 199982 30 29 28 27 26 35 33 32 31 34 199979 199976 199975 199973 40 38 37 36 39 199971 45 43 42 41 44 199970 199967 199963 199961 46 47 48 199958 199955 50 49 55 53 51 52 54 199954 59 5...
output:
214366829
result:
ok 1 number(s): "214366829"
Test #142:
score: 0
Accepted
time: 24ms
memory: 7880kb
input:
10000 200000 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99...
output:
574245653
result:
ok 1 number(s): "574245653"
Test #143:
score: 0
Accepted
time: 137ms
memory: 19188kb
input:
100000 200000 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 9...
output:
35727732
result:
ok 1 number(s): "35727732"
Test #144:
score: 0
Accepted
time: 338ms
memory: 34900kb
input:
199999 200000 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 9...
output:
863354849
result:
ok 1 number(s): "863354849"
Test #145:
score: 0
Accepted
time: 386ms
memory: 36620kb
input:
200000 100000 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 9...
output:
211532409
result:
ok 1 number(s): "211532409"
Test #146:
score: 0
Accepted
time: 320ms
memory: 34780kb
input:
200000 199999 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 9...
output:
826464901
result:
ok 1 number(s): "826464901"
Test #147:
score: 0
Accepted
time: 334ms
memory: 34804kb
input:
200000 200000 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 9...
output:
32596084
result:
ok 1 number(s): "32596084"
Test #148:
score: 0
Accepted
time: 46ms
memory: 5988kb
input:
10000 200000 5000 2500 1250 625 312 156 78 39 19 9 4 2 1 3 6 5 7 8 14 11 10 12 13 16 15 17 18 29 24 21 20 22 23 26 25 27 28 34 31 30 32 33 36 35 37 38 58 48 43 41 40 42 45 44 46 47 53 50 49 51 52 55 54 56 57 68 63 60 59 61 62 65 64 66 67 73 70 69 71 72 75 74 76 77 117 97 87 82 80 79 81 84 83 85 86 9...
output:
956214004
result:
ok 1 number(s): "956214004"
Test #149:
score: 0
Accepted
time: 569ms
memory: 19288kb
input:
100000 200000 50000 25000 12500 6250 3125 1562 781 390 195 97 48 24 12 6 3 1 2 4 5 9 7 8 10 11 18 15 13 14 16 17 21 19 20 22 23 36 30 27 25 26 28 29 33 31 32 34 35 42 39 37 38 40 41 45 43 44 46 47 72 60 54 51 49 50 52 53 57 55 56 58 59 66 63 61 62 64 65 69 67 68 70 71 84 78 75 73 74 76 77 81 79 80 8...
output:
266826161
result:
ok 1 number(s): "266826161"
Test #150:
score: 0
Accepted
time: 1294ms
memory: 35276kb
input:
199999 200000 99999 49999 24999 12499 6249 3124 1562 781 390 195 97 48 24 12 6 3 1 2 4 5 9 7 8 10 11 18 15 13 14 16 17 21 19 20 22 23 36 30 27 25 26 28 29 33 31 32 34 35 42 39 37 38 40 41 45 43 44 46 47 72 60 54 51 49 50 52 53 57 55 56 58 59 66 63 61 62 64 65 69 67 68 70 71 84 78 75 73 74 76 77 81 7...
output:
243676944
result:
ok 1 number(s): "243676944"
Test #151:
score: 0
Accepted
time: 1349ms
memory: 37208kb
input:
200000 100000 100000 50000 25000 12500 6250 3125 1562 781 390 195 97 48 24 12 6 3 1 2 4 5 9 7 8 10 11 18 15 13 14 16 17 21 19 20 22 23 36 30 27 25 26 28 29 33 31 32 34 35 42 39 37 38 40 41 45 43 44 46 47 72 60 54 51 49 50 52 53 57 55 56 58 59 66 63 61 62 64 65 69 67 68 70 71 84 78 75 73 74 76 77 81 ...
output:
540781544
result:
ok 1 number(s): "540781544"
Test #152:
score: 0
Accepted
time: 1295ms
memory: 35240kb
input:
200000 199999 100000 50000 25000 12500 6250 3125 1562 781 390 195 97 48 24 12 6 3 1 2 4 5 9 7 8 10 11 18 15 13 14 16 17 21 19 20 22 23 36 30 27 25 26 28 29 33 31 32 34 35 42 39 37 38 40 41 45 43 44 46 47 72 60 54 51 49 50 52 53 57 55 56 58 59 66 63 61 62 64 65 69 67 68 70 71 84 78 75 73 74 76 77 81 ...
output:
27359347
result:
ok 1 number(s): "27359347"
Test #153:
score: 0
Accepted
time: 1286ms
memory: 35196kb
input:
200000 200000 100000 50000 25000 12500 6250 3125 1562 781 390 195 97 48 24 12 6 3 1 2 4 5 9 7 8 10 11 18 15 13 14 16 17 21 19 20 22 23 36 30 27 25 26 28 29 33 31 32 34 35 42 39 37 38 40 41 45 43 44 46 47 72 60 54 51 49 50 52 53 57 55 56 58 59 66 63 61 62 64 65 69 67 68 70 71 84 78 75 73 74 76 77 81 ...
output:
754017498
result:
ok 1 number(s): "754017498"
Test #154:
score: 0
Accepted
time: 49ms
memory: 8168kb
input:
13327 13326 13326 6663 6185 3092 1546 773 386 193 96 48 24 12 6 3 1 2 4 5 9 7 8 10 11 18 15 13 14 16 17 21 19 20 22 23 36 30 27 25 26 28 29 33 31 32 34 35 42 39 37 38 40 41 45 43 44 46 47 72 60 54 51 49 50 52 53 57 55 56 58 59 66 63 61 62 64 65 69 67 68 70 71 84 78 75 73 74 76 77 81 79 80 82 83 90 8...
output:
0
result:
ok 1 number(s): "0"
Test #155:
score: 0
Accepted
time: 52ms
memory: 7476kb
input:
13328 13327 13327 13326 6663 6185 3092 1546 773 386 193 96 48 24 12 6 1 2 3 4 5 9 7 8 10 11 18 15 13 14 16 17 21 19 20 22 23 36 30 27 25 26 28 29 33 31 32 34 35 42 39 37 38 40 41 45 43 44 46 47 72 60 54 51 49 50 52 53 57 55 56 58 59 66 63 61 62 64 65 69 67 68 70 71 84 78 75 73 74 76 77 81 79 80 82 8...
output:
551817976
result:
ok 1 number(s): "551817976"
Test #156:
score: 0
Accepted
time: 48ms
memory: 6260kb
input:
13328 13327 13327 13326 6663 6185 3092 1546 773 386 193 96 48 24 12 6 3 1 2 4 5 9 7 8 10 11 18 15 13 14 16 17 21 19 20 22 23 36 30 27 25 26 28 29 33 31 32 34 35 42 39 37 38 40 41 45 43 44 46 47 72 60 54 51 49 50 52 53 57 55 56 58 59 66 63 61 62 64 65 69 67 68 70 71 84 78 75 73 74 76 77 81 79 80 82 8...
output:
573075128
result:
ok 1 number(s): "573075128"
Extra Test:
score: 0
Extra Test Passed