QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#673574 | #8231. Festival Decorating | maspy | AC ✓ | 3884ms | 52828kb | C++23 | 32.9kb | 2024-10-25 00:16:57 | 2024-10-25 00:16:57 |
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/mod/modint_common.hpp"
struct has_mod_impl {
template <class T>
static auto check(T &&x) -> decltype(x.get_mod(), std::true_type{});
template <class T>
static auto check(...) -> std::false_type;
};
template <class T>
class has_mod : public decltype(has_mod_impl::check<T>(std::declval<T>())) {};
template <typename mint>
mint inv(int n) {
static const int mod = mint::get_mod();
static vector<mint> dat = {0, 1};
assert(0 <= n);
if (n >= mod) n %= mod;
while (len(dat) <= n) {
int k = len(dat);
int q = (mod + k - 1) / k;
dat.eb(dat[k * q - mod] * mint::raw(q));
}
return dat[n];
}
template <typename mint>
mint fact(int n) {
static const int mod = mint::get_mod();
assert(0 <= n && n < mod);
static vector<mint> dat = {1, 1};
while (len(dat) <= n) dat.eb(dat[len(dat) - 1] * mint::raw(len(dat)));
return dat[n];
}
template <typename mint>
mint fact_inv(int n) {
static vector<mint> dat = {1, 1};
if (n < 0) return mint(0);
while (len(dat) <= n) dat.eb(dat[len(dat) - 1] * inv<mint>(len(dat)));
return dat[n];
}
template <class mint, class... Ts>
mint fact_invs(Ts... xs) {
return (mint(1) * ... * fact_inv<mint>(xs));
}
template <typename mint, class Head, class... Tail>
mint multinomial(Head &&head, Tail &&... tail) {
return fact<mint>(head) * fact_invs<mint>(std::forward<Tail>(tail)...);
}
template <typename mint>
mint C_dense(int n, int k) {
static vvc<mint> C;
static int H = 0, W = 0;
auto calc = [&](int i, int j) -> mint {
if (i == 0) return (j == 0 ? mint(1) : mint(0));
return C[i - 1][j] + (j ? C[i - 1][j - 1] : 0);
};
if (W <= k) {
FOR(i, H) {
C[i].resize(k + 1);
FOR(j, W, k + 1) { C[i][j] = calc(i, j); }
}
W = k + 1;
}
if (H <= n) {
C.resize(n + 1);
FOR(i, H, n + 1) {
C[i].resize(W);
FOR(j, W) { C[i][j] = calc(i, j); }
}
H = n + 1;
}
return C[n][k];
}
template <typename mint, bool large = false, bool dense = false>
mint C(ll n, ll k) {
assert(n >= 0);
if (k < 0 || n < k) return 0;
if constexpr (dense) return C_dense<mint>(n, k);
if constexpr (!large) return multinomial<mint>(n, k, n - k);
k = min(k, n - k);
mint x(1);
FOR(i, k) x *= mint(n - i);
return x * fact_inv<mint>(k);
}
template <typename mint, bool large = false>
mint C_inv(ll n, ll k) {
assert(n >= 0);
assert(0 <= k && k <= n);
if (!large) return fact_inv<mint>(n) * fact<mint>(k) * fact<mint>(n - k);
return mint(1) / C<mint, 1>(n, k);
}
// [x^d](1-x)^{-n}
template <typename mint, bool large = false, bool dense = false>
mint C_negative(ll n, ll d) {
assert(n >= 0);
if (d < 0) return mint(0);
if (n == 0) { return (d == 0 ? mint(1) : mint(0)); }
return C<mint, large, dense>(n + d - 1, d);
}
#line 3 "/home/maspy/compro/library/mod/modint.hpp"
template <int mod>
struct modint {
static constexpr u32 umod = u32(mod);
static_assert(umod < u32(1) << 31);
u32 val;
static modint raw(u32 v) {
modint x;
x.val = v;
return x;
}
constexpr modint() : val(0) {}
constexpr modint(u32 x) : val(x % umod) {}
constexpr modint(u64 x) : val(x % umod) {}
constexpr modint(u128 x) : val(x % umod) {}
constexpr modint(int x) : val((x %= mod) < 0 ? x + mod : x){};
constexpr modint(ll x) : val((x %= mod) < 0 ? x + mod : x){};
constexpr modint(i128 x) : val((x %= mod) < 0 ? x + mod : x){};
bool operator<(const modint &other) const { return val < other.val; }
modint &operator+=(const modint &p) {
if ((val += p.val) >= umod) val -= umod;
return *this;
}
modint &operator-=(const modint &p) {
if ((val += umod - p.val) >= umod) val -= umod;
return *this;
}
modint &operator*=(const modint &p) {
val = u64(val) * p.val % umod;
return *this;
}
modint &operator/=(const modint &p) {
*this *= p.inverse();
return *this;
}
modint operator-() const { return modint::raw(val ? mod - val : u32(0)); }
modint operator+(const modint &p) const { return modint(*this) += p; }
modint operator-(const modint &p) const { return modint(*this) -= p; }
modint operator*(const modint &p) const { return modint(*this) *= p; }
modint operator/(const modint &p) const { return modint(*this) /= p; }
bool operator==(const modint &p) const { return val == p.val; }
bool operator!=(const modint &p) const { return val != p.val; }
modint inverse() const {
int a = val, b = mod, u = 1, v = 0, t;
while (b > 0) {
t = a / b;
swap(a -= t * b, b), swap(u -= t * v, v);
}
return modint(u);
}
modint pow(ll n) const {
assert(n >= 0);
modint ret(1), mul(val);
while (n > 0) {
if (n & 1) ret *= mul;
mul *= mul;
n >>= 1;
}
return ret;
}
static constexpr int get_mod() { return mod; }
// (n, r), r は 1 の 2^n 乗根
static constexpr pair<int, int> ntt_info() {
if (mod == 120586241) return {20, 74066978};
if (mod == 167772161) return {25, 17};
if (mod == 469762049) return {26, 30};
if (mod == 754974721) return {24, 362};
if (mod == 880803841) return {23, 211};
if (mod == 943718401) return {22, 663003469};
if (mod == 998244353) return {23, 31};
if (mod == 1004535809) return {21, 582313106};
if (mod == 1012924417) return {21, 368093570};
return {-1, -1};
}
static constexpr bool can_ntt() { return ntt_info().fi != -1; }
};
#ifdef FASTIO
template <int mod>
void rd(modint<mod> &x) {
fastio::rd(x.val);
x.val %= mod;
// assert(0 <= x.val && x.val < mod);
}
template <int mod>
void wt(modint<mod> x) {
fastio::wt(x.val);
}
#endif
using modint107 = modint<1000000007>;
using modint998 = modint<998244353>;
#line 2 "/home/maspy/compro/library/mod/mod_inv.hpp"
// long でも大丈夫
// (val * x - 1) が mod の倍数になるようにする
// 特に mod=0 なら x=0 が満たす
ll mod_inv(ll val, ll mod) {
if (mod == 0) return 0;
mod = abs(mod);
val %= mod;
if (val < 0) val += mod;
ll a = val, b = mod, u = 1, v = 0, t;
while (b > 0) {
t = a / b;
swap(a -= t * b, b), swap(u -= t * v, v);
}
if (u < 0) u += mod;
return u;
}
#line 2 "/home/maspy/compro/library/mod/crt3.hpp"
constexpr u32 mod_pow_constexpr(u64 a, u64 n, u32 mod) {
a %= mod;
u64 res = 1;
FOR(32) {
if (n & 1) res = res * a % mod;
a = a * a % mod, n /= 2;
}
return res;
}
template <typename T, u32 p0, u32 p1>
T CRT2(u64 a0, u64 a1) {
static_assert(p0 < p1);
static constexpr u64 x0_1 = mod_pow_constexpr(p0, p1 - 2, p1);
u64 c = (a1 - a0 + p1) * x0_1 % p1;
return a0 + c * p0;
}
template <typename T, u32 p0, u32 p1, u32 p2>
T CRT3(u64 a0, u64 a1, u64 a2) {
static_assert(p0 < p1 && p1 < p2);
static constexpr u64 x1 = mod_pow_constexpr(p0, p1 - 2, p1);
static constexpr u64 x2 = mod_pow_constexpr(u64(p0) * p1 % p2, p2 - 2, p2);
static constexpr u64 p01 = u64(p0) * p1;
u64 c = (a1 - a0 + p1) * x1 % p1;
u64 ans_1 = a0 + c * p0;
c = (a2 - ans_1 % p2 + p2) * x2 % p2;
return T(ans_1) + T(c) * T(p01);
}
template <typename T, u32 p0, u32 p1, u32 p2, u32 p3>
T CRT4(u64 a0, u64 a1, u64 a2, u64 a3) {
static_assert(p0 < p1 && p1 < p2 && p2 < p3);
static constexpr u64 x1 = mod_pow_constexpr(p0, p1 - 2, p1);
static constexpr u64 x2 = mod_pow_constexpr(u64(p0) * p1 % p2, p2 - 2, p2);
static constexpr u64 x3 = mod_pow_constexpr(u64(p0) * p1 % p3 * p2 % p3, p3 - 2, p3);
static constexpr u64 p01 = u64(p0) * p1;
u64 c = (a1 - a0 + p1) * x1 % p1;
u64 ans_1 = a0 + c * p0;
c = (a2 - ans_1 % p2 + p2) * x2 % p2;
u128 ans_2 = ans_1 + c * static_cast<u128>(p01);
c = (a3 - ans_2 % p3 + p3) * x3 % p3;
return T(ans_2) + T(c) * T(p01) * T(p2);
}
template <typename T, u32 p0, u32 p1, u32 p2, u32 p3, u32 p4>
T CRT5(u64 a0, u64 a1, u64 a2, u64 a3, u64 a4) {
static_assert(p0 < p1 && p1 < p2 && p2 < p3 && p3 < p4);
static constexpr u64 x1 = mod_pow_constexpr(p0, p1 - 2, p1);
static constexpr u64 x2 = mod_pow_constexpr(u64(p0) * p1 % p2, p2 - 2, p2);
static constexpr u64 x3 = mod_pow_constexpr(u64(p0) * p1 % p3 * p2 % p3, p3 - 2, p3);
static constexpr u64 x4 = mod_pow_constexpr(u64(p0) * p1 % p4 * p2 % p4 * p3 % p4, p4 - 2, p4);
static constexpr u64 p01 = u64(p0) * p1;
static constexpr u64 p23 = u64(p2) * p3;
u64 c = (a1 - a0 + p1) * x1 % p1;
u64 ans_1 = a0 + c * p0;
c = (a2 - ans_1 % p2 + p2) * x2 % p2;
u128 ans_2 = ans_1 + c * static_cast<u128>(p01);
c = static_cast<u64>(a3 - ans_2 % p3 + p3) * x3 % p3;
u128 ans_3 = ans_2 + static_cast<u128>(c * p2) * p01;
c = static_cast<u64>(a4 - ans_3 % p4 + p4) * x4 % p4;
return T(ans_3) + T(c) * T(p01) * T(p23);
}
#line 2 "/home/maspy/compro/library/poly/convolution_naive.hpp"
template <class T, typename enable_if<!has_mod<T>::value>::type* = nullptr>
vc<T> convolution_naive(const vc<T>& a, const vc<T>& b) {
int n = int(a.size()), m = int(b.size());
if (n > m) return convolution_naive<T>(b, a);
if (n == 0) return {};
vector<T> ans(n + m - 1);
FOR(i, n) FOR(j, m) ans[i + j] += a[i] * b[j];
return ans;
}
template <class T, typename enable_if<has_mod<T>::value>::type* = nullptr>
vc<T> convolution_naive(const vc<T>& a, const vc<T>& b) {
int n = int(a.size()), m = int(b.size());
if (n > m) return convolution_naive<T>(b, a);
if (n == 0) return {};
vc<T> ans(n + m - 1);
if (n <= 16 && (T::get_mod() < (1 << 30))) {
for (int k = 0; k < n + m - 1; ++k) {
int s = max(0, k - m + 1);
int t = min(n, k + 1);
u64 sm = 0;
for (int i = s; i < t; ++i) { sm += u64(a[i].val) * (b[k - i].val); }
ans[k] = sm;
}
} else {
for (int k = 0; k < n + m - 1; ++k) {
int s = max(0, k - m + 1);
int t = min(n, k + 1);
u128 sm = 0;
for (int i = s; i < t; ++i) { sm += u64(a[i].val) * (b[k - i].val); }
ans[k] = T::raw(sm % T::get_mod());
}
}
return ans;
}
#line 2 "/home/maspy/compro/library/poly/convolution_karatsuba.hpp"
// 任意の環でできる
template <typename T>
vc<T> convolution_karatsuba(const vc<T>& f, const vc<T>& g) {
const int thresh = 30;
if (min(len(f), len(g)) <= thresh) return convolution_naive(f, g);
int n = max(len(f), len(g));
int m = ceil(n, 2);
vc<T> f1, f2, g1, g2;
if (len(f) < m) f1 = f;
if (len(f) >= m) f1 = {f.begin(), f.begin() + m};
if (len(f) >= m) f2 = {f.begin() + m, f.end()};
if (len(g) < m) g1 = g;
if (len(g) >= m) g1 = {g.begin(), g.begin() + m};
if (len(g) >= m) g2 = {g.begin() + m, g.end()};
vc<T> a = convolution_karatsuba(f1, g1);
vc<T> b = convolution_karatsuba(f2, g2);
FOR(i, len(f2)) f1[i] += f2[i];
FOR(i, len(g2)) g1[i] += g2[i];
vc<T> c = convolution_karatsuba(f1, g1);
vc<T> F(len(f) + len(g) - 1);
assert(2 * m + len(b) <= len(F));
FOR(i, len(a)) F[i] += a[i], c[i] -= a[i];
FOR(i, len(b)) F[2 * m + i] += b[i], c[i] -= b[i];
if (c.back() == T(0)) c.pop_back();
FOR(i, len(c)) if (c[i] != T(0)) F[m + i] += c[i];
return F;
}
#line 2 "/home/maspy/compro/library/poly/ntt.hpp"
template <class mint>
void ntt(vector<mint>& a, bool inverse) {
assert(mint::can_ntt());
const int rank2 = mint::ntt_info().fi;
const int mod = mint::get_mod();
static array<mint, 30> root, iroot;
static array<mint, 30> rate2, irate2;
static array<mint, 30> rate3, irate3;
assert(rank2 != -1 && len(a) <= (1 << max(0, rank2)));
static bool prepared = 0;
if (!prepared) {
prepared = 1;
root[rank2] = mint::ntt_info().se;
iroot[rank2] = mint(1) / root[rank2];
FOR_R(i, rank2) {
root[i] = root[i + 1] * root[i + 1];
iroot[i] = iroot[i + 1] * iroot[i + 1];
}
mint prod = 1, iprod = 1;
for (int i = 0; i <= rank2 - 2; i++) {
rate2[i] = root[i + 2] * prod;
irate2[i] = iroot[i + 2] * iprod;
prod *= iroot[i + 2];
iprod *= root[i + 2];
}
prod = 1, iprod = 1;
for (int i = 0; i <= rank2 - 3; i++) {
rate3[i] = root[i + 3] * prod;
irate3[i] = iroot[i + 3] * iprod;
prod *= iroot[i + 3];
iprod *= root[i + 3];
}
}
int n = int(a.size());
int h = topbit(n);
assert(n == 1 << h);
if (!inverse) {
int len = 0;
while (len < h) {
if (h - len == 1) {
int p = 1 << (h - len - 1);
mint rot = 1;
FOR(s, 1 << len) {
int offset = s << (h - len);
FOR(i, p) {
auto l = a[i + offset];
auto r = a[i + offset + p] * rot;
a[i + offset] = l + r;
a[i + offset + p] = l - r;
}
rot *= rate2[topbit(~s & -~s)];
}
len++;
} else {
int p = 1 << (h - len - 2);
mint rot = 1, imag = root[2];
for (int s = 0; s < (1 << len); s++) {
mint rot2 = rot * rot;
mint rot3 = rot2 * rot;
int offset = s << (h - len);
for (int i = 0; i < p; i++) {
u64 mod2 = u64(mod) * mod;
u64 a0 = a[i + offset].val;
u64 a1 = u64(a[i + offset + p].val) * rot.val;
u64 a2 = u64(a[i + offset + 2 * p].val) * rot2.val;
u64 a3 = u64(a[i + offset + 3 * p].val) * rot3.val;
u64 a1na3imag = (a1 + mod2 - a3) % mod * imag.val;
u64 na2 = mod2 - a2;
a[i + offset] = a0 + a2 + a1 + a3;
a[i + offset + 1 * p] = a0 + a2 + (2 * mod2 - (a1 + a3));
a[i + offset + 2 * p] = a0 + na2 + a1na3imag;
a[i + offset + 3 * p] = a0 + na2 + (mod2 - a1na3imag);
}
rot *= rate3[topbit(~s & -~s)];
}
len += 2;
}
}
} else {
mint coef = mint(1) / mint(len(a));
FOR(i, len(a)) a[i] *= coef;
int len = h;
while (len) {
if (len == 1) {
int p = 1 << (h - len);
mint irot = 1;
FOR(s, 1 << (len - 1)) {
int offset = s << (h - len + 1);
FOR(i, p) {
u64 l = a[i + offset].val;
u64 r = a[i + offset + p].val;
a[i + offset] = l + r;
a[i + offset + p] = (mod + l - r) * irot.val;
}
irot *= irate2[topbit(~s & -~s)];
}
len--;
} else {
int p = 1 << (h - len);
mint irot = 1, iimag = iroot[2];
FOR(s, (1 << (len - 2))) {
mint irot2 = irot * irot;
mint irot3 = irot2 * irot;
int offset = s << (h - len + 2);
for (int i = 0; i < p; i++) {
u64 a0 = a[i + offset + 0 * p].val;
u64 a1 = a[i + offset + 1 * p].val;
u64 a2 = a[i + offset + 2 * p].val;
u64 a3 = a[i + offset + 3 * p].val;
u64 x = (mod + a2 - a3) * iimag.val % mod;
a[i + offset] = a0 + a1 + a2 + a3;
a[i + offset + 1 * p] = (a0 + mod - a1 + x) * irot.val;
a[i + offset + 2 * p] = (a0 + a1 + 2 * mod - a2 - a3) * irot2.val;
a[i + offset + 3 * p] = (a0 + 2 * mod - a1 - x) * irot3.val;
}
irot *= irate3[topbit(~s & -~s)];
}
len -= 2;
}
}
}
}
#line 8 "/home/maspy/compro/library/poly/convolution.hpp"
template <class mint>
vector<mint> convolution_ntt(vector<mint> a, vector<mint> b) {
if (a.empty() || b.empty()) return {};
int n = int(a.size()), m = int(b.size());
int sz = 1;
while (sz < n + m - 1) sz *= 2;
// sz = 2^k のときの高速化。分割統治的なやつで損しまくるので。
if ((n + m - 3) <= sz / 2) {
auto a_last = a.back(), b_last = b.back();
a.pop_back(), b.pop_back();
auto c = convolution(a, b);
c.resize(n + m - 1);
c[n + m - 2] = a_last * b_last;
FOR(i, len(a)) c[i + len(b)] += a[i] * b_last;
FOR(i, len(b)) c[i + len(a)] += b[i] * a_last;
return c;
}
a.resize(sz), b.resize(sz);
bool same = a == b;
ntt(a, 0);
if (same) {
b = a;
} else {
ntt(b, 0);
}
FOR(i, sz) a[i] *= b[i];
ntt(a, 1);
a.resize(n + m - 1);
return a;
}
template <typename mint>
vector<mint> convolution_garner(const vector<mint>& a, const vector<mint>& b) {
int n = len(a), m = len(b);
if (!n || !m) return {};
static constexpr int p0 = 167772161;
static constexpr int p1 = 469762049;
static constexpr int p2 = 754974721;
using mint0 = modint<p0>;
using mint1 = modint<p1>;
using mint2 = modint<p2>;
vc<mint0> a0(n), b0(m);
vc<mint1> a1(n), b1(m);
vc<mint2> a2(n), b2(m);
FOR(i, n) a0[i] = a[i].val, a1[i] = a[i].val, a2[i] = a[i].val;
FOR(i, m) b0[i] = b[i].val, b1[i] = b[i].val, b2[i] = b[i].val;
auto c0 = convolution_ntt<mint0>(a0, b0);
auto c1 = convolution_ntt<mint1>(a1, b1);
auto c2 = convolution_ntt<mint2>(a2, b2);
vc<mint> c(len(c0));
FOR(i, n + m - 1) { c[i] = CRT3<mint, p0, p1, p2>(c0[i].val, c1[i].val, c2[i].val); }
return c;
}
vector<ll> convolution(vector<ll> a, vector<ll> b) {
int n = len(a), m = len(b);
if (!n || !m) return {};
if (min(n, m) <= 2500) return convolution_naive(a, b);
ll mi_a = MIN(a), mi_b = MIN(b);
for (auto& x: a) x -= mi_a;
for (auto& x: b) x -= mi_b;
assert(MAX(a) * MAX(b) <= 1e18);
auto Ac = cumsum<ll>(a), Bc = cumsum<ll>(b);
vi res(n + m - 1);
for (int k = 0; k < n + m - 1; ++k) {
int s = max(0, k - m + 1);
int t = min(n, k + 1);
res[k] += (t - s) * mi_a * mi_b;
res[k] += mi_a * (Bc[k - s + 1] - Bc[k - t + 1]);
res[k] += mi_b * (Ac[t] - Ac[s]);
}
static constexpr u32 MOD1 = 1004535809;
static constexpr u32 MOD2 = 1012924417;
using mint1 = modint<MOD1>;
using mint2 = modint<MOD2>;
vc<mint1> a1(n), b1(m);
vc<mint2> a2(n), b2(m);
FOR(i, n) a1[i] = a[i], a2[i] = a[i];
FOR(i, m) b1[i] = b[i], b2[i] = b[i];
auto c1 = convolution_ntt<mint1>(a1, b1);
auto c2 = convolution_ntt<mint2>(a2, b2);
FOR(i, n + m - 1) { res[i] += CRT2<u64, MOD1, MOD2>(c1[i].val, c2[i].val); }
return res;
}
template <typename mint>
vc<mint> convolution(const vc<mint>& a, const vc<mint>& b) {
int n = len(a), m = len(b);
if (!n || !m) return {};
if (mint::can_ntt()) {
if (min(n, m) <= 50) return convolution_karatsuba<mint>(a, b);
return convolution_ntt(a, b);
}
if (min(n, m) <= 200) return convolution_karatsuba<mint>(a, b);
return convolution_garner(a, b);
}
#line 5 "main.cpp"
/*
存在判定だけならたたみこみ
log(n)回たたみこんじゃっていいか?
*/
void solve() {
LL(N, Q);
int K = 250100;
vi color(K);
vi idx(K);
FOR(i, N) {
INT(x, c);
color[x] = c;
idx[x] = i + 1;
}
vi ANS(K, infty<int>);
auto upd = [&](int L, int R) -> void {
vi A0(K), B0(K);
vi A1(K), B1(K);
vi A2(K), B2(K);
FOR(i, K) {
if (color[i] == 0) continue;
B0[i] = 1;
B1[i] = color[i];
B2[i] = color[i] * color[i];
if (L <= idx[i] && idx[i] < R) {
A0[i] = B0[i];
A1[i] = B1[i];
A2[i] = B2[i];
}
}
reverse(all(A0));
reverse(all(A1));
reverse(all(A2));
vi X0 = convolution(A0, B2);
vi X1 = convolution(A1, B1);
vi X2 = convolution(A2, B0);
FOR(k, K + K - 1) {
ll x = X0[k] + X2[k] - 2 * X1[k];
assert(x >= 0);
if (x == 0) continue;
// k==(K-1-i)+j
ll d = k + 1 - K;
if (1 <= d && d < K) { chmin(ANS[d], L); }
}
};
int L = 1, R = 2;
while (1) {
if (L >= K) break;
upd(L, R);
L += L, R += R;
}
FOR(d, K) if (ANS[d] == infty<int>) ANS[d] = 0;
FOR(Q) {
LL(d);
print(ANS[d]);
}
}
signed main() { solve(); }
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 3755ms
memory: 52564kb
input:
4 5 3 1 1 2 5 1 6 2 1 2 3 4 5
output:
2 2 1 2 0
result:
ok 5 numbers
Test #2:
score: 0
Accepted
time: 3765ms
memory: 52548kb
input:
10000 99999 67296 2 19835 1 93435 1 12756 2 38971 2 58322 2 4419 1 58583 1 68865 1 14192 1 66909 1 31419 2 40656 2 60289 2 79053 1 82880 1 28930 2 46115 1 9805 1 45096 2 29874 1 37171 2 55385 2 69812 1 16845 2 36030 2 58316 1 53401 1 35239 1 40363 1 29811 2 46440 2 98911 1 86466 2 9707 1 41909 2 616...
output:
32 64 8 32 64 4 2 32 8 2 2 16 16 32 4 8 32 4 64 2 64 2 2 4 16 8 8 32 16 64 8 64 8 8 8 2 16 8 8 64 16 4 16 8 8 4 8 2 16 8 32 8 32 8 32 16 8 32 32 16 16 32 16 32 8 2 8 8 8 16 16 2 32 4 64 32 32 32 8 8 16 1 32 2 8 8 8 16 16 8 32 4 4 32 32 4 2 16 4 4 16 32 4 8 32 8 64 64 32 32 8 32 16 8 4 64 64 4 4 16 8...
result:
ok 99999 numbers
Test #3:
score: 0
Accepted
time: 3757ms
memory: 52668kb
input:
30000 99999 51883 1 2142 1 69096 2 63011 1 70418 2 56529 1 65292 2 28901 2 78364 1 96477 1 43396 2 84388 1 29343 2 41141 2 94692 1 91222 1 30872 2 17288 2 11547 1 81095 2 16542 1 38652 1 54120 2 83684 2 70599 1 55085 1 91457 1 37800 1 46297 1 81164 1 79807 2 58484 1 43670 1 7180 2 58437 1 96924 2 63...
output:
2 1 2 16 4 8 8 4 2 4 1 4 4 8 8 2 8 1 4 2 1 2 8 8 8 1 8 2 1 2 4 8 1 2 16 8 16 8 1 4 1 2 4 4 4 4 2 4 2 2 8 8 16 2 4 4 2 4 8 2 8 16 4 4 1 2 4 16 4 2 2 2 4 16 2 2 2 4 4 8 8 8 4 16 8 8 1 4 4 2 1 8 16 8 2 2 4 4 2 8 8 8 1 4 8 8 4 1 1 8 4 4 1 4 1 4 2 2 2 4 4 8 8 8 4 1 2 2 4 8 2 4 8 2 8 1 2 4 4 4 16 4 16 2 4...
result:
ok 99999 numbers
Test #4:
score: 0
Accepted
time: 3750ms
memory: 52732kb
input:
100000 249999 101558 1 226768 2 215012 1 223802 2 3723 1 154951 1 95152 1 188191 2 128933 2 30706 1 141077 1 8377 2 160084 2 56011 1 11556 1 233668 2 42420 2 78212 1 245580 1 25824 2 61180 1 178193 2 179736 1 25607 2 160052 2 56056 2 93163 1 206849 2 28049 2 120634 2 44385 1 188594 1 195761 2 143744...
output:
8 4 2 1 2 2 8 2 2 2 8 4 1 4 2 4 16 1 2 2 8 1 1 4 2 16 8 2 1 2 8 4 2 1 1 8 4 4 1 1 8 4 1 8 1 4 4 4 16 4 1 4 1 8 2 8 4 1 1 8 2 4 4 8 4 8 2 1 4 4 2 2 8 2 4 1 8 1 8 4 4 8 2 1 4 2 4 2 1 4 1 4 1 2 8 2 8 2 2 4 4 4 1 4 4 2 4 2 2 2 2 2 2 4 1 4 4 4 4 1 4 1 4 4 1 4 2 8 1 4 4 2 2 1 4 1 2 1 8 16 2 2 1 2 1 16 2 2...
result:
ok 249999 numbers
Test #5:
score: 0
Accepted
time: 3833ms
memory: 52572kb
input:
150000 249999 29678 2 204012 1 242341 1 55873 2 133195 1 191930 2 158651 2 118376 2 166685 2 52303 2 77713 1 201614 2 135192 2 195257 1 42453 1 42856 1 205245 1 86911 2 192969 1 30106 1 78525 2 140326 2 144700 1 42186 1 215224 2 19113 2 160246 1 159685 1 10602 1 137178 1 102450 1 137587 2 171123 2 1...
output:
1 8 2 1 2 1 8 4 4 4 2 2 2 2 8 2 2 4 4 1 2 1 2 4 8 2 1 2 4 2 4 1 1 4 4 4 1 2 4 4 2 1 1 4 4 2 1 1 2 1 2 2 8 4 1 2 1 8 2 2 8 4 4 1 8 1 4 8 1 2 2 2 4 4 4 1 8 2 2 2 4 1 4 4 4 2 2 2 4 2 1 1 1 2 4 4 4 1 1 2 2 2 1 4 1 4 4 2 4 4 1 8 2 1 1 4 2 4 2 1 8 1 1 2 1 4 2 2 4 2 1 2 2 2 1 2 1 1 1 4 1 8 2 2 1 2 2 8 1 8 ...
result:
ok 249999 numbers
Test #6:
score: 0
Accepted
time: 3794ms
memory: 52644kb
input:
200000 249999 6248 1 183259 1 153451 2 85616 1 114994 2 98565 1 151656 1 220307 1 178381 2 11378 2 229267 2 229745 2 121994 2 127081 1 49355 1 227953 2 110071 1 227824 1 18185 2 140762 2 98797 1 3337 1 229512 2 31126 2 180753 1 206940 1 130823 2 115947 2 201783 1 113674 2 155525 2 112976 2 66144 1 1...
output:
2 4 2 2 2 1 2 2 4 2 1 4 1 1 1 1 1 2 8 4 2 1 2 2 2 1 1 1 2 2 4 2 1 2 1 2 1 1 1 1 2 2 4 1 1 1 4 1 2 1 2 2 8 4 2 1 2 2 1 2 1 1 2 2 4 2 1 1 1 1 2 1 8 8 2 1 2 1 2 2 1 1 1 2 1 1 1 4 4 1 1 1 2 2 1 1 1 2 1 1 2 1 2 4 4 2 2 4 4 2 1 1 2 2 4 2 4 2 1 2 4 2 1 1 4 1 2 1 4 1 1 1 2 1 4 2 1 1 2 1 1 2 2 1 2 1 1 2 1 4 ...
result:
ok 249999 numbers
Test #7:
score: 0
Accepted
time: 3794ms
memory: 52756kb
input:
250000 249999 43395 2 176047 2 182604 2 174584 1 84087 1 171284 2 62939 2 167394 1 91843 1 6316 1 172364 1 60476 1 137969 2 164958 1 49683 2 230414 1 106627 1 120532 1 245073 2 179049 2 34146 2 88698 1 150706 1 99450 1 241792 2 70708 1 69060 2 175739 1 38005 2 65970 1 66335 2 182109 1 32837 1 71265 ...
output:
1 1 2 1 2 1 1 2 2 2 1 8 2 2 1 1 2 1 1 1 2 2 2 4 2 1 1 2 2 1 4 2 2 4 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 4 2 1 2 4 2 1 1 2 4 2 1 2 2 1 1 1 1 1 4 2 1 2 1 4 1 1 1 2 1 2 1 2 2 1 4 2 1 1 1 2 1 1 2 1 2 1 1 2 2 1 2 4 2 2 1 2 4 1 1 2 1 1 2 4 1 1 1 2 2 2 1 1 1 2 1 1 2 1 1 1 2 2 1 1 4 1 2 1 2 1 2 2 8 1 2 1 1 1 1 ...
result:
ok 249999 numbers
Test #8:
score: 0
Accepted
time: 3761ms
memory: 52476kb
input:
100000 249999 15193 3 145839 3 79432 1 108888 2 236993 3 238864 2 96951 2 249086 3 46743 1 32398 3 138017 3 52120 2 230778 2 21656 3 62564 3 208611 2 108357 1 235637 2 247827 1 247624 2 128781 2 13021 1 55702 2 43874 1 126878 2 177432 3 30826 3 100406 3 7564 1 201946 2 52522 3 249872 1 79661 3 13976...
output:
4 8 2 1 2 1 2 8 2 4 2 2 4 1 2 1 8 1 2 2 4 4 4 2 1 2 4 8 2 2 1 1 2 1 16 1 1 1 2 1 4 8 2 1 2 4 8 1 1 4 2 1 1 4 4 2 2 1 2 2 16 1 1 2 4 4 1 2 2 1 1 2 1 4 1 1 1 2 4 2 4 4 4 4 1 2 2 8 4 2 8 1 4 4 4 2 2 4 2 2 4 4 4 2 1 8 4 1 1 2 1 16 2 8 2 1 2 2 1 1 1 1 2 4 1 2 1 2 2 2 16 4 4 1 2 2 4 1 4 2 2 2 1 4 2 8 1 4 ...
result:
ok 249999 numbers
Test #9:
score: 0
Accepted
time: 3812ms
memory: 52644kb
input:
150000 249999 151797 3 132264 2 228119 2 62624 3 122655 1 93048 2 120758 3 96298 1 127189 3 79578 1 233029 1 166678 2 73775 2 132317 2 51322 1 6343 1 176933 2 106261 1 36493 2 159428 3 112870 3 117448 3 93008 1 154295 2 190828 2 74969 1 240852 1 46624 2 241429 3 65645 1 212721 2 110548 2 118236 2 20...
output:
2 1 1 2 2 2 1 2 4 4 2 2 4 4 2 1 2 4 2 2 1 4 1 4 2 1 2 1 1 1 1 2 1 2 2 4 2 1 2 1 8 2 4 1 4 4 1 8 4 1 1 1 2 2 2 1 4 2 1 2 2 1 1 2 4 1 4 2 2 1 2 1 1 4 1 1 1 1 2 1 1 1 1 2 1 1 2 4 1 2 2 1 2 1 1 4 4 4 2 1 2 1 2 4 4 4 1 1 2 2 2 2 2 1 1 4 1 2 1 2 2 4 2 1 2 4 1 8 2 2 2 2 2 2 2 1 1 4 2 1 4 2 4 2 1 2 1 4 2 2 ...
result:
ok 249999 numbers
Test #10:
score: 0
Accepted
time: 3774ms
memory: 52632kb
input:
200000 249999 47041 3 73295 1 221000 1 53265 2 201031 3 222816 2 231867 2 175711 2 150407 1 172427 1 241001 2 192843 2 13671 1 231028 3 208391 2 171533 2 166545 2 97954 3 192317 2 208872 1 231857 1 113741 1 219000 1 192008 3 112701 1 244639 3 224948 1 13585 2 184997 1 179230 3 149300 1 169950 1 9416...
output:
2 1 1 2 2 1 2 2 2 2 2 2 1 2 1 1 1 1 1 1 2 1 1 2 1 4 2 2 1 1 1 2 1 2 1 2 1 1 1 1 1 2 1 1 1 2 4 4 1 1 4 2 1 1 1 2 2 1 1 2 1 2 1 1 1 1 1 4 1 2 1 2 1 1 1 2 1 4 2 2 2 2 2 2 2 1 2 1 2 1 1 1 1 2 1 2 2 2 1 1 2 1 1 8 2 2 1 1 1 1 1 1 2 2 1 4 2 1 1 1 2 4 1 2 2 2 1 1 2 4 4 2 2 1 2 2 1 2 1 1 1 1 2 1 1 1 4 1 2 1 ...
result:
ok 249999 numbers
Test #11:
score: 0
Accepted
time: 3753ms
memory: 52596kb
input:
250000 249999 18119 2 48006 3 232814 2 214885 3 10886 3 761 1 28565 2 127342 3 100481 2 91912 2 169408 3 198992 3 32749 2 20324 3 32474 1 38005 2 240939 2 215900 2 200682 1 432 1 5669 3 84940 3 56161 1 203677 1 241950 1 113041 1 138836 3 153159 3 81938 1 61416 3 239183 2 180390 3 83045 3 107312 1 22...
output:
2 1 1 1 4 2 1 1 2 2 2 1 1 2 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 2 1 4 1 1 1 2 1 1 2 1 1 2 1 4 2 2 1 2 2 2 1 1 2 4 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 2 1 1 1 4 1 1 2 1 4 1 2 2 1 1 2 1 1 2 4 1 1 2 1 1 1 1 2 1 1 1 2 2 2 1 1 1 1 2 1 2 1 1 1 1 1 1 1 1 2 2 1 1 1 1 2 1 1 1 1 1 1 ...
result:
ok 249999 numbers
Test #12:
score: 0
Accepted
time: 3786ms
memory: 52660kb
input:
100000 249999 224336 2 97421 4 237741 10 33517 3 217556 5 236052 6 13864 5 189562 1 209432 1 150833 7 94408 10 220716 3 83847 9 61678 7 95666 3 36542 1 162104 1 158517 6 33248 8 43402 1 18134 8 112042 9 202559 9 183144 6 24872 6 27758 7 217309 8 73017 1 59520 9 187721 10 100252 6 138484 7 165554 7 1...
output:
4 8 4 1 1 4 1 2 4 2 1 4 8 2 8 2 2 1 2 2 2 4 2 1 1 4 2 4 2 4 2 2 2 2 4 2 2 1 4 1 1 8 1 2 2 1 1 2 1 1 1 2 2 1 8 1 4 1 4 1 2 4 2 1 8 2 1 1 1 4 8 1 8 2 2 4 2 2 2 2 2 2 2 1 1 2 16 2 4 2 1 2 2 1 4 4 1 4 2 2 2 2 1 4 2 1 16 1 2 2 4 2 1 2 1 2 1 1 1 2 1 1 1 1 1 4 1 1 1 2 1 1 1 2 2 1 4 2 1 1 2 2 1 1 2 1 2 2 1 ...
result:
ok 249999 numbers
Test #13:
score: 0
Accepted
time: 3765ms
memory: 52716kb
input:
150000 249999 166792 6 238330 4 84379 10 131925 6 168914 7 96461 6 127762 9 204071 4 243519 8 198906 6 161831 7 131281 8 115061 10 69493 4 208817 9 4190 10 195480 10 51511 6 80200 5 81104 6 131338 8 100895 2 207427 4 237681 3 206143 4 224139 6 17948 8 228982 10 200256 8 36233 9 146742 6 162442 2 165...
output:
1 2 2 2 2 1 1 1 1 1 2 1 2 2 1 4 2 2 1 1 4 1 2 4 1 1 2 2 1 2 1 2 2 1 2 4 1 1 1 1 1 1 2 1 4 2 2 2 4 1 1 1 1 2 2 1 2 8 4 1 1 1 1 2 2 1 4 1 1 1 2 1 2 1 1 1 1 1 2 2 2 1 2 2 4 2 1 1 1 1 2 2 1 2 1 1 2 1 1 1 1 1 4 1 1 1 2 8 2 2 2 1 1 2 2 2 1 2 4 2 1 2 2 1 2 2 1 2 2 2 1 1 2 1 1 1 1 2 2 1 1 1 4 1 1 2 1 1 1 1 ...
result:
ok 249999 numbers
Test #14:
score: 0
Accepted
time: 3884ms
memory: 52612kb
input:
200000 249999 200627 8 155259 8 116629 3 7460 8 212178 2 236426 2 247999 4 58552 9 226174 3 136423 3 68187 1 223717 1 115991 3 96943 9 99300 3 196487 3 82852 9 21321 8 146283 2 173037 8 22904 7 198079 10 22919 1 95543 6 237838 2 248787 7 186160 8 201677 8 44573 7 55166 3 60479 6 247478 2 247081 10 3...
output:
1 1 1 1 1 2 1 1 1 1 4 1 1 1 2 1 2 1 1 1 1 1 1 1 2 2 1 1 1 1 2 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 2 1 4 1 1 1 1 1 1 1 2 1 4 1 2 1 1 1 1 2 1 2 1 1 2 1 2 2 1 1 1 2 1 1 1 1 1 2 1 1 2 2 1 2 1 1 2 1 1 1 4 1 1 1 1 1 2 1 1 1 1 2 1 1 1 2 2 2 2 1 1 2 2 2 1 1 2 1 1 1 1 1 1 1 1 2 2 1 2 1 2 1 1 2 2 2 1 1 ...
result:
ok 249999 numbers
Test #15:
score: 0
Accepted
time: 3759ms
memory: 52712kb
input:
250000 249999 14095 6 220950 6 234662 3 35913 1 132258 4 200544 10 135104 7 148916 1 13117 5 190176 9 222898 8 91946 4 178090 4 18354 1 151369 2 12233 6 228757 6 161742 7 33667 9 79810 1 74379 10 162789 3 196843 7 223296 9 78881 10 103789 5 84979 7 234254 5 80219 2 27415 7 65636 6 245431 4 16975 7 2...
output:
2 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 2 1 1 2 1 2 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 ...
result:
ok 249999 numbers
Test #16:
score: 0
Accepted
time: 3752ms
memory: 52576kb
input:
250000 249999 234423 1 106490 1 209289 1 86924 1 54501 1 166355 1 228761 1 165944 1 172158 1 64661 1 167348 1 196763 1 98465 1 56621 1 138329 1 149908 1 58448 1 231726 1 171821 1 203962 1 80624 1 299 1 16257 1 193382 1 226372 1 103199 1 160198 1 206884 1 43643 1 246448 1 197980 1 164317 1 228968 1 1...
output:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
result:
ok 249999 numbers
Test #17:
score: 0
Accepted
time: 3769ms
memory: 52696kb
input:
100000 249999 93220 59 126118 58 114760 31 127602 91 78964 37 107468 28 17418 34 20051 6 25078 32 238158 11 143557 45 177110 45 101603 44 55221 8 27168 33 12698 44 96309 71 228393 7 85535 53 161888 73 97093 73 177327 72 151564 44 113400 33 80491 47 62362 93 15475 4 134593 67 204219 69 128232 67 1335...
output:
1 1 2 1 2 8 1 2 1 2 2 4 2 1 1 2 1 1 1 1 1 2 2 8 1 2 1 1 1 4 4 1 1 2 1 1 2 1 1 2 2 1 2 2 1 2 1 2 1 1 2 2 1 1 1 2 2 1 2 2 4 2 1 2 2 1 1 2 1 2 1 1 1 1 1 2 4 4 2 2 8 4 2 1 2 2 2 4 2 1 4 1 2 1 4 2 1 1 2 1 1 2 1 1 2 2 2 2 1 1 1 4 4 4 1 2 1 1 8 1 1 4 1 2 1 1 1 1 1 2 2 2 1 4 1 2 4 1 1 2 4 1 2 1 2 1 4 1 2 2 ...
result:
ok 249999 numbers
Test #18:
score: 0
Accepted
time: 3795ms
memory: 52828kb
input:
150000 249999 104484 72 183971 17 236903 47 85763 51 109721 7 115135 100 162866 62 13428 6 134736 85 108324 46 94466 1 175154 17 72231 54 166036 34 198137 84 146960 74 90976 26 210020 89 205699 80 7068 76 192964 51 93065 27 166315 35 80521 64 41842 13 83346 79 119551 5 96204 72 97493 66 92835 15 312...
output:
1 1 1 4 1 2 1 1 1 2 1 2 1 2 1 1 1 2 1 1 2 1 2 1 1 4 1 1 1 2 1 1 1 2 1 4 1 1 1 1 1 1 2 2 2 1 1 2 2 2 2 2 1 2 1 1 2 2 1 1 2 2 2 1 1 2 1 1 2 1 1 1 1 1 4 1 2 2 1 2 2 1 1 1 1 1 2 2 1 2 2 4 1 1 1 1 2 2 2 2 1 1 1 2 1 2 1 1 4 1 1 2 2 1 1 1 1 1 1 2 4 2 1 2 1 1 1 4 1 2 2 2 1 1 2 2 1 4 1 2 2 2 1 2 2 1 1 2 2 1 ...
result:
ok 249999 numbers
Test #19:
score: 0
Accepted
time: 3772ms
memory: 52720kb
input:
200000 249999 47102 39 120564 49 211340 98 112018 76 128324 79 13658 56 145481 5 212577 92 153372 83 195457 13 67116 53 183188 95 159717 50 223315 42 123415 47 143994 74 39260 51 58850 22 198700 27 22129 53 244348 12 112600 33 93161 52 165358 80 162648 46 238139 8 224484 6 236710 2 45342 99 44056 3 ...
output:
1 1 1 1 1 1 1 2 2 1 2 1 1 2 1 1 1 2 1 1 1 1 2 1 1 2 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 2 1 1 1 2 1 1 1 2 1 1 1 2 1 1 1 1 2 1 1 1 1 2 1 1 2 2 2 2 1 1 1 2 1 1 1 2 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 2 1 1 2 1 1 1 2 1 1 1 1 2 1 2 1 1 1 1 2 1 ...
result:
ok 249999 numbers
Test #20:
score: 0
Accepted
time: 3837ms
memory: 52784kb
input:
250000 249999 113549 52 245740 8 25655 22 218082 47 132245 45 218861 28 37315 30 111164 95 14826 36 107398 37 156792 14 48628 66 132434 72 28151 59 158589 94 7348 97 56728 5 190552 8 170423 55 65115 44 106177 86 202419 88 183685 47 200452 7 72434 8 161099 94 95797 19 92937 7 75848 100 238323 38 1721...
output:
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...
result:
ok 249999 numbers
Test #21:
score: 0
Accepted
time: 3746ms
memory: 52752kb
input:
100000 249999 215178 78 137308 320 85918 996 37671 196 229886 523 231932 923 231942 388 174478 949 3670 606 187312 514 113705 684 239037 255 207483 436 54280 528 227569 162 29778 206 139135 341 39789 362 191291 41 102694 729 208895 941 57449 360 30418 630 123629 754 39958 20 220635 888 43818 148 531...
output:
2 2 2 2 4 1 4 1 1 1 1 1 1 2 4 2 4 2 1 1 1 1 2 2 4 4 2 4 4 2 8 2 2 2 1 2 4 2 4 1 2 2 2 1 1 2 1 2 1 1 1 1 2 1 1 4 4 1 4 2 1 2 1 2 1 1 4 2 1 4 1 2 1 2 4 1 1 1 2 1 2 1 1 2 4 1 1 2 2 1 1 2 1 1 1 8 1 1 2 8 2 1 2 1 2 2 8 1 4 2 1 2 1 2 1 2 4 1 2 2 1 1 8 2 2 2 1 1 2 1 1 1 1 1 1 1 1 2 4 2 2 2 1 1 4 1 2 1 2 1 ...
result:
ok 249999 numbers
Test #22:
score: 0
Accepted
time: 3838ms
memory: 52628kb
input:
150000 249999 168799 574 236614 391 5626 61 80977 154 38826 825 210532 62 100484 431 137419 781 103555 171 155556 287 247529 26 33559 487 177031 92 195197 875 91976 329 199343 636 83803 545 106072 247 123800 617 25942 788 235116 540 75666 678 240796 87 116602 682 229461 207 234450 428 235548 279 159...
output:
1 2 1 1 2 1 1 1 1 1 2 2 4 1 1 1 1 1 2 1 1 2 1 1 1 1 1 4 2 1 1 4 1 1 1 1 1 1 1 4 2 1 2 1 1 2 2 1 1 1 4 1 1 1 1 1 1 1 2 2 1 2 2 2 2 1 4 2 1 2 1 2 1 2 2 1 2 2 1 1 1 1 2 2 2 2 1 4 1 2 1 2 2 1 2 1 2 1 2 1 2 1 1 2 1 4 1 1 2 2 1 1 1 4 4 2 1 1 1 1 1 1 2 1 2 1 2 1 1 2 1 1 8 2 2 4 2 1 1 1 2 2 4 1 1 1 1 1 2 1 ...
result:
ok 249999 numbers
Test #23:
score: 0
Accepted
time: 3736ms
memory: 52416kb
input:
200000 249999 220479 940 50222 148 184880 27 222833 69 4952 631 43460 820 140864 16 15536 585 121758 416 81558 785 139693 320 164815 379 6191 763 223454 81 202200 271 68519 74 25162 498 51853 454 170830 650 123228 426 131945 392 191834 517 152172 502 117499 506 103682 415 245558 424 146040 951 87752...
output:
1 2 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 2 2 1 1 1 1 1 2 1 1 1 2 1 1 1 1 1 1 1 2 1 1 2 1 1 1 1 1 2 1 1 1 1 1 2 2 1 1 2 1 2 1 1 1 1 1 1 2 1 2 1 2 1 1 1 1 2 1 2 2 1 2 1 1 2 1 1 1 2 1 1 1 1 1 1 1 1 1 2 1 1 1 2 1 2 1 1 1 2 2 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 2 1 2 2 1 2 2 1 1 2 1 1 1 1 1 1 2 1 1 1 1 2 1 1 1 ...
result:
ok 249999 numbers
Test #24:
score: 0
Accepted
time: 3799ms
memory: 52488kb
input:
250000 249999 71099 140 102518 514 183279 196 9460 731 155766 741 159169 471 240491 548 72124 713 92079 572 102680 262 27525 958 1818 610 245646 611 85560 428 14629 438 195435 311 30920 702 105014 531 9136 11 134312 381 88919 991 56603 642 102308 551 68202 138 12583 498 88565 667 69470 82 213748 540...
output:
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...
result:
ok 249999 numbers
Test #25:
score: 0
Accepted
time: 3786ms
memory: 52772kb
input:
100000 249999 143875 3079 35794 9717 78870 1826 154059 3784 185253 1989 50422 6248 142560 6933 142367 7270 199873 8171 232637 2149 766 6740 128174 8273 174253 2020 71559 974 33140 3168 247328 4196 235516 7852 118076 6395 165442 1875 15428 8418 143016 5686 122930 6 97686 6807 215402 719 152923 7495 1...
output:
2 4 1 4 1 4 2 1 2 1 2 1 2 2 2 2 8 2 4 8 4 4 4 1 1 2 4 2 2 1 2 1 2 2 1 4 1 2 1 4 8 2 2 4 2 1 1 2 1 4 2 4 2 2 2 2 4 8 1 1 1 4 1 1 1 2 2 1 2 8 2 1 1 4 1 2 2 1 4 4 1 4 4 1 2 1 1 1 4 2 1 1 4 2 1 2 8 1 4 4 2 2 4 1 1 2 4 4 1 2 1 1 2 4 1 2 1 2 1 2 1 2 1 1 2 1 2 4 2 2 2 2 2 1 1 2 2 4 8 4 2 4 4 2 2 2 4 2 2 1 ...
result:
ok 249999 numbers
Test #26:
score: 0
Accepted
time: 3783ms
memory: 52628kb
input:
150000 249999 208515 1037 226810 8037 78579 8990 196348 454 52075 3057 210394 7076 132508 6037 33903 3827 45161 3699 181439 3102 81472 8711 241071 8091 177966 9734 10995 5634 142541 4395 150681 2847 64108 3634 236691 6727 44362 3578 91381 3400 115765 7253 95492 6997 86886 4546 137861 3681 89217 9885...
output:
1 1 1 1 1 2 1 2 1 1 1 1 1 2 1 1 1 2 1 2 1 1 1 1 2 2 1 2 1 1 1 1 1 4 1 1 1 1 1 2 2 2 2 1 1 1 2 1 2 1 1 1 2 4 1 1 1 1 8 2 1 1 1 1 1 1 2 1 1 1 2 1 2 1 1 2 2 1 2 1 1 2 1 2 1 1 1 1 1 2 1 1 1 1 4 2 1 1 2 1 2 1 4 2 2 1 1 2 1 1 1 1 1 1 2 2 1 1 1 1 1 1 2 4 2 1 2 1 1 1 1 1 1 1 2 1 1 1 2 1 2 1 1 1 1 2 4 1 1 2 ...
result:
ok 249999 numbers
Test #27:
score: 0
Accepted
time: 3816ms
memory: 52484kb
input:
200000 249999 19515 6770 260 7289 46752 6511 235290 1326 69396 2617 218263 711 68770 3615 160983 5021 74125 2662 245771 8858 224783 7181 235656 4986 163114 3041 101632 1797 64682 4595 22763 4476 145956 9767 50440 3970 20831 9646 32979 365 147294 5959 5700 3518 167684 258 105791 2718 129850 8902 2168...
output:
1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 2 1 1 1 2 1 1 1 1 1 2 1 2 1 1 1 1 1 1 1 1 2 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 4 1 1 1 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 2 1 2 1 2 1 1 1 1 2 1 1 1 1 1 1 2 2 1 1 1 2 1 1 1 1 2 2 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 2 1 2 2 1 1 1 1 ...
result:
ok 249999 numbers
Test #28:
score: 0
Accepted
time: 3752ms
memory: 52716kb
input:
250000 249999 233586 2024 249814 5609 98965 9482 21269 7996 112196 3685 56401 4243 248656 5822 246725 8874 239803 3997 154988 7106 163971 9153 17019 4804 114980 9267 15470 7944 148695 5822 48302 5830 17357 1357 85078 1597 217000 5941 193654 6835 41788 6310 84917 509 111123 2589 219424 5680 217784 85...
output:
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...
result:
ok 249999 numbers
Test #29:
score: 0
Accepted
time: 3796ms
memory: 52752kb
input:
100000 249999 218060 20345 27334 62482 125176 75231 164701 51166 191015 8172 197002 40902 212572 96076 79429 83748 8322 65763 117710 55688 163851 18354 61106 26868 169159 5528 85864 73608 229644 69531 69326 96862 136553 87015 41717 8087 3709 40727 233990 84886 99712 32178 217040 75596 149456 83736 1...
output:
1 2 1 1 2 4 1 2 2 1 1 2 2 2 4 2 2 2 2 2 2 4 2 2 2 2 4 2 2 4 8 2 1 2 2 1 1 1 2 4 2 1 2 1 4 2 2 1 4 1 4 1 1 2 2 4 4 2 2 2 1 2 1 2 2 1 1 4 2 1 1 2 8 2 2 2 2 2 2 4 2 4 1 1 1 2 2 2 1 1 1 2 4 1 2 4 2 1 2 4 4 2 1 1 1 1 2 2 2 2 2 1 1 2 1 8 2 2 2 4 8 1 8 16 1 4 1 1 2 1 1 1 2 2 1 2 1 2 2 1 1 2 4 2 1 2 1 2 4 2...
result:
ok 249999 numbers
Test #30:
score: 0
Accepted
time: 3816ms
memory: 52644kb
input:
150000 249999 234931 117721 165760 121374 39901 90389 65401 36642 127661 143888 111190 11903 248547 55018 25670 51452 29737 77284 34785 88158 41023 86741 210736 96409 45042 131729 156818 38710 102234 58616 229573 45925 240495 63260 27301 13493 239464 120694 57130 18370 65373 113177 200234 111599 813...
output:
1 2 1 1 2 1 1 4 1 2 4 1 1 2 2 1 1 1 1 2 2 2 2 4 1 2 2 4 1 2 2 1 1 2 1 2 2 4 1 2 2 1 1 4 1 2 2 1 1 2 1 1 1 1 2 1 2 1 2 1 2 1 1 2 1 1 1 1 4 1 1 1 1 1 1 2 2 2 2 1 1 2 1 1 1 1 2 1 1 2 2 1 1 2 1 1 1 4 1 1 1 2 1 2 1 2 1 1 1 1 1 1 1 4 1 1 2 1 1 1 1 1 4 1 1 1 1 2 1 2 1 2 2 2 2 1 1 1 1 1 1 1 1 1 2 1 2 1 1 1 ...
result:
ok 249999 numbers
Test #31:
score: 0
Accepted
time: 3796ms
memory: 52684kb
input:
200000 249999 115119 166519 203638 63359 136662 96182 198943 18205 186741 173012 170532 142299 132543 22820 152237 171263 248127 46558 134531 159448 113450 155775 26555 131466 9868 37421 45419 144841 199395 140829 110924 34275 83572 11001 48496 65156 133341 100284 141543 60021 170546 6240 231712 152...
output:
1 1 1 1 2 1 1 1 2 1 2 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 2 2 2 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 2 1 1 1 1 1 2 1 2 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 2 4 1 2 1 1 1 1 2 1 ...
result:
ok 249999 numbers
Test #32:
score: 0
Accepted
time: 3861ms
memory: 52616kb
input:
250000 249999 81716 70790 72006 29146 86672 228636 88825 53682 198298 58728 197705 130597 169560 249058 143240 6263 156637 225375 177754 174622 67575 6866 139636 192494 53704 155110 8984 209943 65297 79914 153405 142122 225695 169949 96758 194754 245965 121739 212635 243505 234106 28727 242548 11416...
output:
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...
result:
ok 249999 numbers
Test #33:
score: 0
Accepted
time: 3773ms
memory: 52640kb
input:
250000 249999 250000 1 249999 1 249998 2 249997 2 249996 3 249995 3 249994 4 249993 4 249992 5 249991 5 249990 6 249989 6 249988 7 249987 7 249986 8 249985 8 249984 9 249983 9 249982 10 249981 10 249980 11 249979 11 249978 12 249977 12 249976 13 249975 13 249974 14 249973 14 249972 15 249971 15 2499...
output:
2 2 4 4 4 4 8 8 8 8 8 8 8 8 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64...
result:
ok 249999 numbers
Test #34:
score: 0
Accepted
time: 3788ms
memory: 52648kb
input:
250000 249999 250000 1 249999 1 249998 1 249997 2 249996 2 249995 2 249994 3 249993 3 249992 3 249991 4 249990 4 249989 4 249988 5 249987 5 249986 5 249985 6 249984 6 249983 6 249982 7 249981 7 249980 7 249979 8 249978 8 249977 8 249976 9 249975 9 249974 9 249973 10 249972 10 249971 10 249970 11 249...
output:
4 4 4 4 4 4 8 8 8 8 8 8 8 8 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64...
result:
ok 249999 numbers
Test #35:
score: 0
Accepted
time: 3721ms
memory: 52656kb
input:
250000 249999 250000 1 249999 1 249998 1 249997 1 249996 1 249995 2 249994 2 249993 2 249992 2 249991 2 249990 3 249989 3 249988 3 249987 3 249986 3 249985 4 249984 4 249983 4 249982 4 249981 4 249980 5 249979 5 249978 5 249977 5 249976 5 249975 6 249974 6 249973 6 249972 6 249971 6 249970 7 249969 ...
output:
4 4 4 4 4 4 8 8 8 8 8 8 8 8 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64...
result:
ok 249999 numbers
Test #36:
score: 0
Accepted
time: 3795ms
memory: 52780kb
input:
250000 249999 250000 1 249999 1 249998 1 249997 1 249996 1 249995 1 249994 1 249993 1 249992 1 249991 1 249990 1 249989 1 249988 1 249987 1 249986 1 249985 1 249984 1 249983 1 249982 1 249981 1 249980 1 249979 1 249978 1 249977 1 249976 1 249975 1 249974 1 249973 1 249972 1 249971 1 249970 1 249969 ...
output:
64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 ...
result:
ok 249999 numbers
Test #37:
score: 0
Accepted
time: 3789ms
memory: 52580kb
input:
250000 249999 250000 1 249999 1 249998 1 249997 1 249996 1 249995 1 249994 1 249993 1 249992 1 249991 1 249990 1 249989 1 249988 1 249987 1 249986 1 249985 1 249984 1 249983 1 249982 1 249981 1 249980 1 249979 1 249978 1 249977 1 249976 1 249975 1 249974 1 249973 1 249972 1 249971 1 249970 1 249969 ...
output:
256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 ...
result:
ok 249999 numbers
Test #38:
score: 0
Accepted
time: 3777ms
memory: 52692kb
input:
250000 249999 250000 1 249999 1 249998 1 249997 1 249996 1 249995 1 249994 1 249993 1 249992 1 249991 1 249990 1 249989 1 249988 1 249987 1 249986 1 249985 1 249984 1 249983 1 249982 1 249981 1 249980 1 249979 1 249978 1 249977 1 249976 1 249975 1 249974 1 249973 1 249972 1 249971 1 249970 1 249969 ...
output:
4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 ...
result:
ok 249999 numbers
Test #39:
score: 0
Accepted
time: 3819ms
memory: 52560kb
input:
250000 249999 250000 1 249999 1 249998 1 249997 1 249996 1 249995 1 249994 1 249993 1 249992 1 249991 1 249990 1 249989 1 249988 1 249987 1 249986 1 249985 1 249984 1 249983 1 249982 1 249981 1 249980 1 249979 1 249978 1 249977 1 249976 1 249975 1 249974 1 249973 1 249972 1 249971 1 249970 1 249969 ...
output:
32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 ...
result:
ok 249999 numbers
Test #40:
score: 0
Accepted
time: 3791ms
memory: 52712kb
input:
250000 249999 250000 1 249999 1 249998 1 249997 1 249996 1 249995 1 249994 1 249993 1 249992 1 249991 1 249990 1 249989 1 249988 1 249987 1 249986 1 249985 1 249984 1 249983 1 249982 1 249981 1 249980 1 249979 1 249978 1 249977 1 249976 1 249975 1 249974 1 249973 1 249972 1 249971 1 249970 1 249969 ...
output:
131072 131072 131072 131072 131072 131072 131072 131072 131072 131072 131072 131072 131072 131072 131072 131072 131072 131072 131072 131072 131072 131072 131072 131072 131072 131072 131072 131072 131072 131072 131072 131072 131072 131072 131072 131072 131072 131072 131072 131072 131072 131072 131072...
result:
ok 249999 numbers
Test #41:
score: 0
Accepted
time: 3741ms
memory: 52604kb
input:
100000 250000 100000 1 99999 1 99998 1 99997 1 99996 1 99995 1 99994 1 99993 1 99992 1 99991 1 99990 1 99989 1 99988 1 99987 1 99986 1 99985 1 99984 1 99983 1 99982 1 99981 1 99980 1 99979 1 99978 1 99977 1 99976 1 99975 1 99974 1 99973 1 99972 1 99971 1 99970 1 99969 1 99968 1 99967 1 99966 1 99965...
output:
16384 16384 16384 16384 16384 16384 16384 16384 16384 16384 16384 16384 16384 16384 16384 16384 16384 16384 16384 16384 16384 16384 16384 16384 16384 16384 16384 16384 16384 16384 16384 16384 16384 16384 16384 16384 16384 16384 16384 16384 16384 16384 16384 16384 16384 16384 16384 16384 16384 16384 ...
result:
ok 250000 numbers
Test #42:
score: 0
Accepted
time: 3790ms
memory: 52720kb
input:
250000 249999 250000 1 249999 1 249998 2 249997 2 249996 3 249995 3 249994 4 249993 4 249992 5 249991 5 249990 6 249989 6 249988 7 249987 7 249986 8 249985 8 249984 9 249983 9 249982 10 249981 10 249980 11 249979 11 249978 12 249977 12 249976 13 249975 13 249974 14 249973 14 249972 15 249971 15 2499...
output:
2 2 4 4 4 4 8 8 8 8 8 8 8 8 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64...
result:
ok 249999 numbers
Test #43:
score: 0
Accepted
time: 3835ms
memory: 52720kb
input:
250000 249999 250000 1 249999 1 249998 1 249997 2 249996 2 249995 2 249994 3 249993 3 249992 3 249991 4 249990 4 249989 4 249988 5 249987 5 249986 5 249985 6 249984 6 249983 6 249982 7 249981 7 249980 7 249979 8 249978 8 249977 8 249976 9 249975 9 249974 9 249973 10 249972 10 249971 10 249970 11 249...
output:
4 4 4 4 4 4 8 8 8 8 8 8 8 8 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64...
result:
ok 249999 numbers
Test #44:
score: 0
Accepted
time: 3833ms
memory: 52620kb
input:
250000 249999 250000 1 249999 1 249998 1 249997 1 249996 1 249995 2 249994 2 249993 2 249992 2 249991 2 249990 3 249989 3 249988 3 249987 3 249986 3 249985 4 249984 4 249983 4 249982 4 249981 4 249980 5 249979 5 249978 5 249977 5 249976 5 249975 6 249974 6 249973 6 249972 6 249971 6 249970 7 249969 ...
output:
4 4 4 4 4 4 8 8 8 8 8 8 8 8 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64...
result:
ok 249999 numbers
Test #45:
score: 0
Accepted
time: 3739ms
memory: 52480kb
input:
250000 249999 250000 1 249999 1 249998 1 249997 1 249996 1 249995 1 249994 1 249993 1 249992 1 249991 1 249990 1 249989 1 249988 1 249987 1 249986 1 249985 1 249984 1 249983 1 249982 1 249981 1 249980 1 249979 1 249978 1 249977 1 249976 1 249975 1 249974 1 249973 1 249972 1 249971 1 249970 1 249969 ...
output:
64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 ...
result:
ok 249999 numbers
Test #46:
score: 0
Accepted
time: 3761ms
memory: 52484kb
input:
250000 249999 250000 1 249999 1 249998 1 249997 1 249996 1 249995 1 249994 1 249993 1 249992 1 249991 1 249990 1 249989 1 249988 1 249987 1 249986 1 249985 1 249984 1 249983 1 249982 1 249981 1 249980 1 249979 1 249978 1 249977 1 249976 1 249975 1 249974 1 249973 1 249972 1 249971 1 249970 1 249969 ...
output:
256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 256 ...
result:
ok 249999 numbers
Test #47:
score: 0
Accepted
time: 3797ms
memory: 52576kb
input:
250000 249999 250000 1 249999 1 249998 1 249997 1 249996 1 249995 1 249994 1 249993 1 249992 1 249991 1 249990 1 249989 1 249988 1 249987 1 249986 1 249985 1 249984 1 249983 1 249982 1 249981 1 249980 1 249979 1 249978 1 249977 1 249976 1 249975 1 249974 1 249973 1 249972 1 249971 1 249970 1 249969 ...
output:
4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 4096 ...
result:
ok 249999 numbers
Test #48:
score: 0
Accepted
time: 3729ms
memory: 52500kb
input:
250000 249999 250000 1 249999 1 249998 1 249997 1 249996 1 249995 1 249994 1 249993 1 249992 1 249991 1 249990 1 249989 1 249988 1 249987 1 249986 1 249985 1 249984 1 249983 1 249982 1 249981 1 249980 1 249979 1 249978 1 249977 1 249976 1 249975 1 249974 1 249973 1 249972 1 249971 1 249970 1 249969 ...
output:
32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 32768 ...
result:
ok 249999 numbers
Test #49:
score: 0
Accepted
time: 3761ms
memory: 52572kb
input:
250000 249999 250000 1 249999 1 249998 1 249997 1 249996 1 249995 1 249994 1 249993 1 249992 1 249991 1 249990 1 249989 1 249988 1 249987 1 249986 1 249985 1 249984 1 249983 1 249982 1 249981 1 249980 1 249979 1 249978 1 249977 1 249976 1 249975 1 249974 1 249973 1 249972 1 249971 1 249970 1 249969 ...
output:
131072 131072 131072 131072 131072 131072 131072 131072 131072 131072 131072 131072 131072 131072 131072 131072 131072 131072 131072 131072 131072 131072 131072 131072 131072 131072 131072 131072 131072 131072 131072 131072 131072 131072 131072 131072 131072 131072 131072 131072 131072 131072 131072...
result:
ok 249999 numbers
Test #50:
score: 0
Accepted
time: 3819ms
memory: 52704kb
input:
250000 250000 250000 1 249999 2 249998 2 249997 2 249996 2 249995 2 249994 2 249993 2 249992 2 249991 2 249990 2 249989 2 249988 2 249987 2 249986 2 249985 2 249984 2 249983 2 249982 2 249981 2 249980 2 249979 2 249978 2 249977 2 249976 2 249975 2 249974 2 249973 2 249972 2 249971 2 249970 2 249969 ...
output:
2 2 4 4 4 4 8 8 8 8 8 8 8 8 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64...
result:
ok 250000 numbers
Extra Test:
score: 0
Extra Test Passed