QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#757479#7899. Say Hello to the FuturemaspyAC ✓445ms17588kbC++2332.0kb2024-11-17 08:20:552024-11-17 08:20:55

Judging History

你现在查看的是最新测评结果

  • [2024-11-17 08:20:55]
  • 评测
  • 测评结果:AC
  • 用时:445ms
  • 内存:17588kb
  • [2024-11-17 08:20:55]
  • 提交

answer

#line 1 "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_sgn(int x) { return (__builtin_parity(x) & 1 ? -1 : 1); }
int popcnt_sgn(u32 x) { return (__builtin_parity(x) & 1 ? -1 : 1); }
int popcnt_sgn(ll x) { return (__builtin_parity(x) & 1 ? -1 : 1); }
int popcnt_sgn(u64 x) { return (__builtin_parity(x) & 1 ? -1 : 1); }
// (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 kth_bit(int k) {
  return T(1) << k;
}
template <typename T>
bool has_kth_bit(T x, int k) {
  return x >> k & 1;
}

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 "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 "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) {
  assert(n >= 0);
  if (k < 0 || n < k) return 0;
  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 "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 "library/alg/monoid/add.hpp"

template <typename E>
struct Monoid_Add {
  using X = E;
  using value_type = X;
  static constexpr X op(const X &x, const X &y) noexcept { return x + y; }
  static constexpr X inverse(const X &x) noexcept { return -x; }
  static constexpr X power(const X &x, ll n) noexcept { return X(n) * x; }
  static constexpr X unit() { return X(0); }
  static constexpr bool commute = true;
};
#line 3 "library/ds/fenwicktree/fenwicktree.hpp"

template <typename Monoid>
struct FenwickTree {
  using G = Monoid;
  using MX = Monoid;
  using E = typename G::value_type;
  int n;
  vector<E> dat;
  E total;

  FenwickTree() {}
  FenwickTree(int n) { build(n); }
  template <typename F>
  FenwickTree(int n, F f) {
    build(n, f);
  }
  FenwickTree(const vc<E>& v) { build(v); }

  void build(int m) {
    n = m;
    dat.assign(m, G::unit());
    total = G::unit();
  }
  void build(const vc<E>& v) {
    build(len(v), [&](int i) -> E { return v[i]; });
  }
  template <typename F>
  void build(int m, F f) {
    n = m;
    dat.clear();
    dat.reserve(n);
    total = G::unit();
    FOR(i, n) { dat.eb(f(i)); }
    for (int i = 1; i <= n; ++i) {
      int j = i + (i & -i);
      if (j <= n) dat[j - 1] = G::op(dat[i - 1], dat[j - 1]);
    }
    total = prefix_sum(m);
  }

  E prod_all() { return total; }
  E sum_all() { return total; }
  E sum(int k) { return prefix_sum(k); }
  E prod(int k) { return prefix_prod(k); }
  E prefix_sum(int k) { return prefix_prod(k); }
  E prefix_prod(int k) {
    chmin(k, n);
    E ret = G::unit();
    for (; k > 0; k -= k & -k) ret = G::op(ret, dat[k - 1]);
    return ret;
  }
  E sum(int L, int R) { return prod(L, R); }
  E prod(int L, int R) {
    chmax(L, 0), chmin(R, n);
    if (L == 0) return prefix_prod(R);
    assert(0 <= L && L <= R && R <= n);
    E pos = G::unit(), neg = G::unit();
    while (L < R) { pos = G::op(pos, dat[R - 1]), R -= R & -R; }
    while (R < L) { neg = G::op(neg, dat[L - 1]), L -= L & -L; }
    return G::op(pos, G::inverse(neg));
  }

  vc<E> get_all() {
    vc<E> res(n);
    FOR(i, n) res[i] = prod(i, i + 1);
    return res;
  }

  void add(int k, E x) { multiply(k, x); }
  void multiply(int k, E x) {
    static_assert(G::commute);
    total = G::op(total, x);
    for (++k; k <= n; k += k & -k) dat[k - 1] = G::op(dat[k - 1], x);
  }
  void set(int k, E x) { add(k, G::op(G::inverse(prod(k, k + 1)), x)); }

  template <class F>
  int max_right(const F check, int L = 0) {
    assert(check(G::unit()));
    E s = G::unit();
    int i = L;
    // 2^k 進むとダメ
    int k = [&]() {
      while (1) {
        if (i % 2 == 1) { s = G::op(s, G::inverse(dat[i - 1])), i -= 1; }
        if (i == 0) { return topbit(n) + 1; }
        int k = lowbit(i) - 1;
        if (i + (1 << k) > n) return k;
        E t = G::op(s, dat[i + (1 << k) - 1]);
        if (!check(t)) { return k; }
        s = G::op(s, G::inverse(dat[i - 1])), i -= i & -i;
      }
    }();
    while (k) {
      --k;
      if (i + (1 << k) - 1 < len(dat)) {
        E t = G::op(s, dat[i + (1 << k) - 1]);
        if (check(t)) { i += (1 << k), s = t; }
      }
    }
    return i;
  }

  // check(i, x)
  template <class F>
  int max_right_with_index(const F check, int L = 0) {
    assert(check(L, G::unit()));
    E s = G::unit();
    int i = L;
    // 2^k 進むとダメ
    int k = [&]() {
      while (1) {
        if (i % 2 == 1) { s = G::op(s, G::inverse(dat[i - 1])), i -= 1; }
        if (i == 0) { return topbit(n) + 1; }
        int k = lowbit(i) - 1;
        if (i + (1 << k) > n) return k;
        E t = G::op(s, dat[i + (1 << k) - 1]);
        if (!check(i + (1 << k), t)) { return k; }
        s = G::op(s, G::inverse(dat[i - 1])), i -= i & -i;
      }
    }();
    while (k) {
      --k;
      if (i + (1 << k) - 1 < len(dat)) {
        E t = G::op(s, dat[i + (1 << k) - 1]);
        if (check(i + (1 << k), t)) { i += (1 << k), s = t; }
      }
    }
    return i;
  }

  template <class F>
  int min_left(const F check, int R) {
    assert(check(G::unit()));
    E s = G::unit();
    int i = R;
    // false になるところまで戻る
    int k = 0;
    while (i > 0 && check(s)) {
      s = G::op(s, dat[i - 1]);
      k = lowbit(i);
      i -= i & -i;
    }
    if (check(s)) {
      assert(i == 0);
      return 0;
    }
    // 2^k 進むと ok になる
    // false を維持して進む
    while (k) {
      --k;
      E t = G::op(s, G::inverse(dat[i + (1 << k) - 1]));
      if (!check(t)) { i += (1 << k), s = t; }
    }
    return i + 1;
  }

  int kth(E k, int L = 0) {
    assert(k < sum_all());
    return max_right([&k](E x) -> bool { return x <= k; }, L);
  }
};
#line 2 "library/ds/offline_query/point_add_rectangle_sum.hpp"

template <typename AbelGroup, typename XY, bool SMALL_X = false>
struct Point_Add_Rectangle_Sum {
  using G = typename AbelGroup::value_type;
  using Point = tuple<XY, XY, G>;
  vector<Point> point;
  vector<tuple<XY, XY, XY, XY>> rect;

  Point_Add_Rectangle_Sum() {}

  void add_query(XY x, XY y, G w) { point.eb(x, y, w); }
  void sum_query(XY xl, XY xr, XY yl, XY yr) { rect.eb(xl, xr, yl, yr); }

  vector<G> calc() {
    int N = point.size(), Q = rect.size();
    if (N == 0 || Q == 0) return vector<G>(Q, AbelGroup::unit());
    // X 方向の座圧
    int NX = 0;
    if (!SMALL_X) {
      sort(all(point),
           [&](auto &x, auto &y) -> bool { return get<0>(x) < get<0>(y); });
      vc<XY> keyX;
      keyX.reserve(N);
      for (auto &&[a, b, c]: point) {
        if (len(keyX) == 0 || keyX.back() != a) { keyX.eb(a); }
        a = len(keyX) - 1;
      }
      for (auto &&[xl, xr, yl, yr]: rect) {
        xl = LB(keyX, xl);
        xr = LB(keyX, xr);
      }
      NX = len(keyX);
    }
    if (SMALL_X) {
      XY mx = infty<XY>;
      for (auto &&[x, y, g]: point) chmin(mx, x);
      for (auto &&[x, y, g]: point) x -= mx, chmax(NX, x + 1);
      for (auto &&[xl, xr, yl, yr]: rect) {
        xl -= mx, xr -= mx;
        xl = max(0, min<int>(xl, NX));
        xr = max(0, min<int>(xr, NX));
      }
    }

    vc<tuple<XY, int, int, int>> event(Q + Q);
    FOR(q, Q) {
      auto &[xl, xr, yl, yr] = rect[q];
      event[2 * q] = {yl, xl, xr, 2 * q};
      event[2 * q + 1] = {yr, xl, xr, 2 * q + 1};
    }
    sort(all(point),
         [&](auto &x, auto &y) -> bool { return get<1>(x) < get<1>(y); });
    sort(all(event),
         [&](auto &x, auto &y) -> bool { return get<0>(x) < get<0>(y); });

    FenwickTree<AbelGroup> bit(NX);
    vc<G> res(Q, AbelGroup::unit());
    int j = 0;
    for (auto &&[y, xl, xr, qq]: event) {
      while (j < N && get<1>(point[j]) < y) {
        bit.add(get<0>(point[j]), get<2>(point[j]));
        ++j;
      }
      G g = bit.sum(xl, xr);
      int q = qq / 2;
      if (qq % 2 == 0) g = AbelGroup::inverse(g);
      res[q] = AbelGroup::op(res[q], g);
    }
    return res;
  }
};
#line 6 "main.cpp"

using mint = modint998;

/*
まずは条件を満たす prefix, suffix の分割を求める
分割統治で

ちょうどひとつの区間でちょうどひとつの反例があるものの調整
反例となるのは区間 max
これも分割統治で何とかする
*/

vc<mint> solve_prefix(vc<int> A) {
  int N = len(A);
  vc<mint> dp(N + 1);
  dp[0] = 1;
  vc<int> MX(N + 1);

  auto calc = [&](vc<int> A, vc<mint> dp) -> vc<mint> {
    int N = len(dp);
    int M = N / 2;
    vc<int> MA(N);
    MA[M] = -1;
    FOR(j, M + 1, N) MA[j] = max(MA[j - 1], A[j - 1]);
    FOR_R(i, M) MA[i] = max(MA[i + 1], A[i]);

    // left > right
    {
      vc<mint> ADD(N + 1);
      int p = M;
      FOR_R(i, M) {
        while (p < N && MA[p] < MA[i]) ++p;
        // FOR(j, M, p) if (j - i >= MA[i]) dp[j] += dp[i];
        int a = max<int>(MA[i] + i, M), b = p;
        if (a < b) ADD[a] += dp[i], ADD[b] -= dp[i];
      }
      ADD = cumsum<mint>(ADD, 0);
      FOR(j, M, N) dp[j] += ADD[j];
    }
    // left<=right
    {
      auto dpc = cumsum<mint>(dp);
      int p = M;
      FOR(j, M, N) {
        while (0 <= p - 1 && MA[p - 1] <= MA[j]) --p;
        // FOR(i, p, M) if (j - i >= MA[j]) dp[j] += dp[i];
        int a = p, b = min<int>(M, j - MA[j] + 1);
        if (a < b) dp[j] += dpc[b] - dpc[a];
      }
    }
    return dp;
  };

  auto dfs = [&](auto& dfs, int L, int R) -> void {
    if (R == L + 1) { return; }
    int M = (L + R) / 2;
    dfs(dfs, L, M);
    vc<mint> sub = calc({A.begin() + L, A.begin() + (R - 1)}, {dp.begin() + L, dp.begin() + R});
    FOR(j, M, R) dp[j] = sub[j - L];
    dfs(dfs, M, R);
  };
  dfs(dfs, 0, N + 1);
  return dp;
}

void solve() {
  LL(N);
  VEC(int, A, N);

  vc<mint> X = solve_prefix(A);
  reverse(all(A));
  vc<mint> Y = solve_prefix(A);
  reverse(all(A));
  reverse(all(Y));
  SHOW(X);
  SHOW(Y);
  assert(X[N] == Y[0]);

  vc<mint> ANS(N, X[N]);

  auto calc = [&](vc<int> A, vc<mint> X, vc<mint> Y) -> vc<mint> {
    // 区間内 max2 も必要
    int N = len(X);
    int M = N / 2;
    vc<int> MA(N), MA_I(N);
    vc<int> MA2(N);
    MA[M] = -1, MA2[M] = -1;
    MA_I[M] = -1;
    FOR(j, M + 1, N) {
      if (MA[j - 1] < A[j - 1]) {
        MA2[j] = MA[j - 1], MA[j] = A[j - 1];
        MA_I[j] = j - 1;
      } else {
        MA[j] = MA[j - 1], MA2[j] = max(MA2[j - 1], A[j - 1]);
        MA_I[j] = MA_I[j - 1];
      }
    }
    FOR_R(i, M) {
      if (MA[i + 1] < A[i]) {
        MA2[i] = MA[i + 1], MA[i] = A[i];
        MA_I[i] = i;
      } else {
        MA[i] = MA[i + 1], MA2[i] = max(MA2[i + 1], A[i]);
        MA_I[i] = MA_I[i + 1];
      }
    }

    vc<mint> ANS(N - 1);

    // 左 2 つつまり left>=left2>right
    {
      auto Yc = cumsum<mint>(Y);
      int p = M;
      FOR_R(i, M) {
        while (p < N && MA[p] < MA2[i]) ++p;
        int idx = MA_I[i];
        if (idx == -1) continue;
        // left 2 では valid, left 1 では invalid
        // M<=j<p, i+MA2[i]<=j, j<i+MA[i]
        int a = max<int>(M, i + MA2[i]);
        int b = min<int>(p, i + MA[i]);
        // FOR(j, a, b) ANS[idx] += X[i] * Y[j];
        if (a < b) ANS[idx] += X[i] * (Yc[b] - Yc[a]);
      }
    }

    // 右 2 つつまり left<=right2
    {
      auto Xc = cumsum<mint>(X);
      int p = M;
      FOR(j, M, N) {
        while (0 < p && MA[p - 1] <= MA2[j]) --p;
        int idx = MA_I[j];
        if (idx == -1) continue;
        // right 2 では valid, right では invalid
        // p<=i<M, MA2[j]<=j-i, j-i<MA[j]
        int a = max<int>(p, j - MA[j] + 1);
        int b = min<int>(M, j - MA2[j] + 1);
        // FOR(i, a, b) ANS[idx] += X[i] * Y[j], SHOW(idx, i, j);
        if (a < b) ANS[idx] += (Xc[b] - Xc[a]) * Y[j];
      }
    }
    // 左1 右1 の場合 left > right, left2 <= right
    // rectangle sum になるのではないでしょうか
    {
      vc<int> label;
      Point_Add_Rectangle_Sum<Monoid_Add<mint>, int, 1> S;
      FOR(j, M, N) S.add_query(j, MA[j] - j, Y[j]);
      int s = M, t = M;
      FOR_R(i, M) {
        while (s < N && MA[s] < MA2[i]) ++s;
        while (t < N && MA[t] < MA[i]) ++t;
        int idx = MA_I[i];
        if (idx == -1 || s >= t) continue;
        // s<=j<t, MA[j]<=j-i, j-i<MA[i]
        int a = s, b = min<int>(t, i + MA[i]);
        if (a < b) {
          S.sum_query(a, b, -infty<int>, -i + 1);
          label.eb(i);
        }
      }
      auto val = S.calc();
      FOR(k, len(label)) {
        int i = label[k];
        int idx = MA_I[i];
        ANS[idx] += X[i] * val[k];
      }
    }
    // 右1 左1 の場合 right >= left, left > right2
    {
      vc<int> label;
      Point_Add_Rectangle_Sum<Monoid_Add<mint>, int, 1> S;
      FOR(i, M) S.add_query(i, i + MA[i], X[i]);
      int s = M, t = M;
      FOR(j, M, N) {
        while (s > 0 && MA[j] >= MA[s - 1]) --s;
        while (t > 0 && MA2[j] >= MA[t - 1]) --t;
        int idx = MA_I[j];
        if (idx == -1 || s >= t) continue;
        // s<=i<t, MA[i]<=j-i, j-i<MA[j]
        int a = max<int>(s, j - MA[j] + 1);
        int b = t;
        if (a < b) {
          S.sum_query(a, b, -infty<int>, j + 1);
          label.eb(j);
        }
      }
      auto val = S.calc();
      FOR(k, len(label)) {
        int j = label[k];
        int idx = MA_I[j];
        ANS[idx] += val[k] * Y[j];
      }
    }
    SHOW(A, X, Y, ANS);
    return ANS;
  };

  auto dfs = [&](auto& dfs, int L, int R) -> void {
    if (R == L + 1) return;
    int M = (L + R) / 2;
    dfs(dfs, L, M);
    vc<mint> sub = calc({A.begin() + L, A.begin() + (R - 1)}, {X.begin() + L, X.begin() + R}, {Y.begin() + L, Y.begin() + R});
    FOR(j, L, R - 1) ANS[j] += sub[j - L];
    dfs(dfs, M, R);
  };
  dfs(dfs, 0, N + 1);
  print(ANS);
}

signed main() {
  solve();
  return 0;
}

这程序好像有点Bug,我给组数据试试?

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 3844kb

input:

5
1 3 2 1 2

output:

3 6 3 3 6

result:

ok 5 tokens

Test #2:

score: 0
Accepted
time: 387ms
memory: 14576kb

input:

200000
15922 15391 11782 4758 1973 19909 16800 6438 3821 986 18599 2011 338 19886 12401 4169 11143 12665 3230 12565 15065 15056 5090 16908 13677 12634 11435 1425 8647 3876 10694 12256 3853 19901 5723 11065 6147 13613 13768 15794 14993 5819 8117 13871 14708 15099 7152 9810 14438 10557 3209 1265 13915...

output:

157122482 826457499 826457499 826457499 826457499 826457499 826457499 826457499 826457499 826457499 826457499 826457499 826457499 826457499 826457499 826457499 826457499 826457499 826457499 826457499 826457499 826457499 826457499 826457499 826457499 826457499 826457499 826457499 826457499 826457499 ...

result:

ok 200000 tokens

Test #3:

score: 0
Accepted
time: 379ms
memory: 14552kb

input:

200000
4065 9196 2588 18803 10818 17671 10483 13134 12147 19916 19382 19338 8864 7637 19542 14938 16362 7115 9159 9711 17907 17653 10175 3279 7471 3465 14016 13951 8676 2856 16709 5372 12237 18083 11052 16398 7140 9730 8800 18999 16808 8729 7608 6668 7049 6024 7892 18039 7278 12417 2440 13112 4039 5...

output:

47583147 370164779 370164779 370164779 370164779 370164779 370164779 370164779 370164779 345009231 370164779 370164779 370164779 370164779 370164779 370164779 370164779 370164779 370164779 370164779 370164779 370164779 370164779 370164779 370164779 370164779 370164779 370164779 370164779 370164779 3...

result:

ok 200000 tokens

Test #4:

score: 0
Accepted
time: 362ms
memory: 15032kb

input:

200000
1 1 1 1 4547 1 1 1 1 1 1 1 6329 1 1 19778 1 1 12258 1 1 1 1 1 18104 1 8123 1 329 1 1 1 1 1 1 1 1 4438 1 1 1 1 1 208 1 1 1 1 1 1 1 1 1 15603 1 1 1 1 1 1 1 1 1 1 5513 1 1 15427 1 1 1 1 1 1 1 18309 1 1 6333 1 1 1 1 1 1 1 1 1 13938 1 1 1 1 1 1 9229 1 1 1 1 1 1 1 1 1791 1 1 1 11747 1 1 1 1 8992 1 ...

output:

225508548 225508548 225508548 225508548 748768610 225508548 225508548 225508548 225508548 225508548 225508548 225508548 225508548 225508548 225508548 225508548 225508548 225508548 225508548 225508548 225508548 225508548 225508548 225508548 225508548 225508548 225508548 225508548 225508548 225508548 ...

result:

ok 200000 tokens

Test #5:

score: 0
Accepted
time: 366ms
memory: 15084kb

input:

200000
1 1 1 1 1 1 1 10166 1 1 9410 1 1 1 1 1 1 1 1 1 296 1 1 1 1 1 1 1 1 1 1 7392 4057 17616 1 1 1 1 3084 14799 1 1 13598 1 1 9848 1 1 1 1 1 8084 1 1 1 1 1 1 1 1 10519 1 1 1 1 1 14 1 1 1 1 1 1 1 1 1 1 14981 1 1 1 1 1 1 1 1 1 5144 7784 1 1 1 1 1 1 1 19661 1 14894 1 1 1 1 1 1 1 1 10449 1 1 1 16473 1 ...

output:

735167914 735167914 735167914 735167914 735167914 735167914 735167914 211149010 735167914 735167914 735167914 735167914 735167914 735167914 735167914 735167914 735167914 735167914 735167914 735167914 735167914 735167914 735167914 735167914 735167914 735167914 735167914 735167914 735167914 735167914 ...

result:

ok 200000 tokens

Test #6:

score: 0
Accepted
time: 334ms
memory: 14644kb

input:

200000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 5 1 6 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 3 1 1 1 1 1 1 1 3 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 6 1 1 1 1 1 1 1 1 6 1 1 1 2397 1 1 3 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 4 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 ...

output:

450552969 450552969 450552969 450552969 450552969 450552969 450552969 450552969 450552969 450552969 450552969 450552969 450552969 450552969 450552969 450552969 415221870 450552969 425969980 450552969 450552969 450552969 450552969 450552969 450552969 450552969 450552969 450552969 450552969 450552969 ...

result:

ok 200000 tokens

Test #7:

score: 0
Accepted
time: 332ms
memory: 14708kb

input:

200000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 9861 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 1739 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 2 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 1 1 1 1 1 1 1 1 1 1 1 11012 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1...

output:

723674232 723674232 723674232 723674232 723674232 723674232 723674232 723674232 723674232 723674232 723674232 723674232 723674232 723674232 723674232 723674232 723674232 723674232 723674232 723674232 723674232 723674232 723674232 76256586 723674232 723674232 723674232 723674232 723674232 723674232 7...

result:

ok 200000 tokens

Test #8:

score: 0
Accepted
time: 314ms
memory: 14744kb

input:

200000
1 1 1 1 1 1 1 1 1 1 29 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 5 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 5 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 2 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 8 1 1 1...

output:

529842888 529842888 529842888 529842888 529842888 529842888 529842888 529842888 529842888 529842888 773664190 529842888 529842888 529842888 529842888 529842888 529842888 529842888 529842888 529842888 529842888 529842888 529842888 529842888 529842888 529842888 529842888 529842888 529842888 529842888 ...

result:

ok 200000 tokens

Test #9:

score: 0
Accepted
time: 312ms
memory: 14784kb

input:

200000
1 1 1 1 1 2 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 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 5 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 4 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...

output:

806160702 806160702 806160702 806160702 806160702 364515698 806160702 806160702 806160702 806160702 806160702 806160702 806160702 806160702 806160702 806160702 806160702 806160702 806160702 806160702 806160702 806160702 331355896 806160702 806160702 806160702 806160702 806160702 806160702 806160702 ...

result:

ok 200000 tokens

Test #10:

score: 0
Accepted
time: 236ms
memory: 14856kb

input:

200000
1 1 1 1 1 1 1 1 1 3 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 2 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 18 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 7 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 4 1 1 1 1 1 1 1 1 1 1 1 4 1 1 1 1 1 1 1 1 1 ...

output:

819517227 819517227 819517227 819517227 819517227 819517227 819517227 819517227 819517227 640790101 819517227 819517227 819517227 819517227 819517227 819517227 819517227 819517227 819517227 819517227 819517227 819517227 819517227 819517227 819517227 819517227 94445283 819517227 819517227 819517227 8...

result:

ok 200000 tokens

Test #11:

score: 0
Accepted
time: 235ms
memory: 14688kb

input:

200000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 4 1 3 1 1 1 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 9 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 11 1 1 1 1 1 1 1 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 7 ...

output:

224346786 224346786 224346786 224346786 224346786 224346786 224346786 224346786 224346786 224346786 224346786 224346786 224346786 224346786 224346786 224346786 224346786 224346786 224346786 224346786 224346786 224346786 883675827 224346786 724940402 224346786 224346786 224346786 224346786 224346786 ...

result:

ok 200000 tokens

Test #12:

score: 0
Accepted
time: 352ms
memory: 14636kb

input:

200000
380 1947 45 613 973 1687 176 1238 889 1168 1165 626 1832 727 27 1848 512 31 1243 94 427 1462 389 1824 1026 1103 1317 212 774 1115 1076 150 797 348 761 1763 418 1681 1795 1813 309 762 1880 1081 1375 1988 98 41 1800 171 1116 1633 71 1241 1358 1420 19 688 1318 787 1655 1377 32 947 1232 953 76 39...

output:

425384391 717656467 717656467 717656467 717656467 717656467 717656467 717656467 717656467 717656467 717656467 717656467 717656467 717656467 717656467 717656467 717656467 717656467 717656467 717656467 717656467 717656467 717656467 717656467 717656467 717656467 717656467 717656467 717656467 717656467 ...

result:

ok 200000 tokens

Test #13:

score: 0
Accepted
time: 367ms
memory: 14600kb

input:

200000
255 1944 1577 1738 1298 700 988 1061 626 1361 769 1602 1611 1838 275 297 1330 1553 659 267 764 1775 657 342 153 1406 536 1475 1736 1701 1014 1391 1047 1147 1290 1280 1227 1570 1287 1822 1896 564 1016 325 155 830 121 33 1088 1784 1611 656 1566 1225 158 705 1729 1605 1313 875 102 333 1550 990 6...

output:

983788768 7611565 7611565 7611565 7611565 7611565 7611565 7611565 7611565 7611565 7611565 7611565 7611565 7611565 7611565 7611565 7611565 7611565 7611565 7611565 7611565 7611565 7611565 7611565 7611565 7611565 7611565 7611565 7611565 7611565 7611565 7611565 7611565 7611565 7611565 7611565 7611565 76...

result:

ok 200000 tokens

Test #14:

score: 0
Accepted
time: 343ms
memory: 14884kb

input:

200000
1 1 894 1 1 1 1 1 1 1 1 1 1 1666 1 1 1648 1 1 1 1 822 1 1 1 1 1 1 1 218 1 1 132 1 1 1 1 1 1 1 1067 1 1 1 1 1 1 1 1 1 1 1178 1 1 1 1 70 1 1 1 1 1 1 1 1 1665 243 1 1 1 1 1 1925 1 1 1 1 1 1 1 975 1 1 1 1 1 1 1 1 1 1469 1 1 1 1 1 1 1 1 1 839 1 359 1 1 1 1 1 1 1 1 1790 1 1 1 1388 1 1 1 1 1 1 1 1 1...

output:

718644419 718644419 103241866 718644419 718644419 718644419 718644419 718644419 718644419 718644419 718644419 718644419 718644419 718644419 718644419 718644419 718644419 718644419 718644419 718644419 718644419 718644419 718644419 718644419 718644419 718644419 718644419 718644419 718644419 718644419 ...

result:

ok 200000 tokens

Test #15:

score: 0
Accepted
time: 332ms
memory: 14840kb

input:

200000
1 1 1 1 1 1 1 1 1 714 1 1 1 1 1 661 1 1 1 1 1 1 1 1724 1 1 1 1 1 1 1 1 1 1 924 911 1 1 1 1 1 1 1192 1 1 1 1 1 1907 1 1 1 388 1 1 1 1 1 1 1 1 1 1 1910 1 1 1 1 1304 1 1 1 1 1 1 1 1 1168 1 1 1 1 1 1 1 1 1872 1 194 1 1 1 33 1 1 1602 1 1 1 1 1 1 324 1 1 1 1 1 1 1 1 1 1 28 1 1 1 1 1 1 701 1 1 1 1 1...

output:

422022560 422022560 422022560 422022560 422022560 422022560 422022560 422022560 422022560 767529344 422022560 422022560 422022560 422022560 422022560 422022560 422022560 422022560 422022560 422022560 422022560 422022560 422022560 422022560 422022560 422022560 422022560 422022560 422022560 422022560 ...

result:

ok 200000 tokens

Test #16:

score: 0
Accepted
time: 276ms
memory: 14884kb

input:

200000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1451 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

353202539 353202539 353202539 353202539 353202539 353202539 353202539 353202539 353202539 353202539 353202539 353202539 353202539 353202539 353202539 353202539 353202539 353202539 353202539 353202539 353202539 353202539 353202539 353202539 353202539 353202539 353202539 353202539 353202539 353202539 ...

result:

ok 200000 tokens

Test #17:

score: 0
Accepted
time: 280ms
memory: 14880kb

input:

200000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 812 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

858605372 858605372 858605372 858605372 858605372 858605372 858605372 858605372 858605372 858605372 858605372 858605372 858605372 858605372 858605372 858605372 858605372 858605372 858605372 858605372 858605372 858605372 858605372 858605372 858605372 858605372 858605372 858605372 858605372 858605372 ...

result:

ok 200000 tokens

Test #18:

score: 0
Accepted
time: 237ms
memory: 14908kb

input:

200000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

761164523 761164523 761164523 761164523 761164523 761164523 761164523 761164523 761164523 761164523 761164523 761164523 761164523 761164523 761164523 761164523 761164523 761164523 761164523 761164523 761164523 761164523 761164523 761164523 761164523 761164523 761164523 761164523 761164523 761164523 ...

result:

ok 200000 tokens

Test #19:

score: 0
Accepted
time: 225ms
memory: 14816kb

input:

200000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

90869376 90869376 90869376 90869376 90869376 90869376 90869376 90869376 90869376 90869376 90869376 90869376 90869376 90869376 90869376 90869376 90869376 90869376 90869376 90869376 90869376 90869376 90869376 90869376 90869376 90869376 90869376 90869376 90869376 90869376 90869376 90869376 90869376 908...

result:

ok 200000 tokens

Test #20:

score: 0
Accepted
time: 199ms
memory: 15128kb

input:

200000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

526920358 526920358 526920358 526920358 526920358 526920358 526920358 526920358 526920358 526920358 526920358 526920358 526920358 526920358 526920358 526920358 526920358 526920358 526920358 526920358 526920358 526920358 526920358 526920358 526920358 526920358 526920358 526920358 526920358 526920358 ...

result:

ok 200000 tokens

Test #21:

score: 0
Accepted
time: 192ms
memory: 14828kb

input:

200000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

24467815 24467815 24467815 24467815 24467815 24467815 24467815 24467815 24467815 24467815 24467815 24467815 24467815 24467815 24467815 24467815 24467815 24467815 24467815 24467815 24467815 24467815 24467815 24467815 24467815 24467815 24467815 24467815 24467815 24467815 24467815 24467815 24467815 244...

result:

ok 200000 tokens

Test #22:

score: 0
Accepted
time: 334ms
memory: 14736kb

input:

200000
53 129 38 148 167 107 148 99 161 198 71 149 103 49 36 144 57 11 107 15 72 75 91 154 191 190 177 122 197 36 196 126 150 108 6 117 81 58 51 55 181 135 106 181 149 165 150 38 5 63 194 84 89 4 135 175 63 78 74 32 47 106 10 16 161 88 50 95 4 82 58 181 156 197 194 21 138 91 105 106 109 159 51 76 86...

output:

300601705 553401883 553401883 553401883 553401883 553401883 553401883 553401883 553401883 18494655 553401883 553401883 553401883 553401883 553401883 553401883 553401883 553401883 553401883 553401883 553401883 553401883 553401883 553401883 553401883 553401883 553401883 553401883 553401883 553401883 5...

result:

ok 200000 tokens

Test #23:

score: 0
Accepted
time: 331ms
memory: 14660kb

input:

200000
52 30 8 75 150 80 87 129 133 108 88 182 41 198 109 56 92 42 42 125 198 86 140 131 17 184 31 81 195 150 39 66 12 95 168 49 55 142 5 72 43 191 179 152 65 77 175 168 126 77 193 58 124 43 154 38 2 52 22 153 190 143 109 19 92 116 27 59 174 24 184 24 142 80 130 151 61 34 101 71 54 50 125 40 54 101 ...

output:

576237374 566996520 566996520 566996520 566996520 566996520 566996520 566996520 566996520 566996520 566996520 566996520 566996520 566996520 566996520 566996520 566996520 566996520 566996520 566996520 566996520 566996520 566996520 566996520 566996520 566996520 566996520 566996520 566996520 566996520 ...

result:

ok 200000 tokens

Test #24:

score: 0
Accepted
time: 299ms
memory: 14744kb

input:

200000
1 1 1 113 1 1 1 1 1 1 1 1 1 24 1 109 1 1 1 1 1 160 1 1 1 1 1 1 1 1 133 1 1 89 1 1 1 1 33 1 1 1 1 164 1 1 1 1 1 186 1 1 1 1 1 1 115 1 1 1 1 1 1 1 1 30 1 1 1 1 170 55 1 1 1 76 1 1 1 1 1 1 1 190 1 1 1 1 1 1 1 162 1 1 1 1 6 1 1 1 1 1 1 1 1 182 186 1 1 50 1 1 1 1 67 1 1 1 1 1 1 165 1 1 1 1 1 1 1 1...

output:

725226252 725226252 725226252 750600882 725226252 725226252 725226252 725226252 725226252 725226252 725226252 725226252 725226252 725226252 725226252 725226252 725226252 725226252 725226252 725226252 725226252 725226252 725226252 725226252 725226252 725226252 725226252 725226252 725226252 725226252 ...

result:

ok 200000 tokens

Test #25:

score: 0
Accepted
time: 302ms
memory: 14636kb

input:

200000
1 1 1 1 1 1 1 1 1 17 1 1 1 1 126 1 1 1 1 1 1 1 1 95 1 1 169 1 1 1 1 1 1 1 197 1 1 1 1 143 1 1 1 1 1 1 117 1 1 1 1 1 117 1 73 1 1 183 1 153 1 1 1 1 1 1 1 130 1 1 1 1 1 94 1 1 1 1 1 75 1 1 1 1 88 62 1 1 1 1 1 1 1 70 1 1 1 1 1 1 1 1 13 1 1 1 39 1 1 1 1 1 1 1 45 191 1 1 157 1 1 1 1 1 1 1 1 1 152 ...

output:

183224204 183224204 183224204 183224204 183224204 183224204 183224204 183224204 183224204 262661924 183224204 183224204 183224204 183224204 592152678 183224204 183224204 183224204 183224204 183224204 183224204 183224204 183224204 183224204 183224204 183224204 183224204 183224204 183224204 183224204 ...

result:

ok 200000 tokens

Test #26:

score: 0
Accepted
time: 225ms
memory: 14676kb

input:

200000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 73 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 156 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

827635970 827635970 827635970 827635970 827635970 827635970 827635970 827635970 827635970 827635970 827635970 827635970 827635970 827635970 827635970 827635970 827635970 827635970 827635970 827635970 827635970 827635970 827635970 827635970 827635970 827635970 827635970 827635970 827635970 827635970 ...

result:

ok 200000 tokens

Test #27:

score: 0
Accepted
time: 224ms
memory: 15208kb

input:

200000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 73 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 20 1 1 1 1 1 1 1 173 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

582217512 582217512 582217512 582217512 582217512 582217512 582217512 582217512 582217512 582217512 582217512 582217512 582217512 582217512 582217512 582217512 582217512 582217512 582217512 582217512 582217512 582217512 582217512 582217512 582217512 582217512 582217512 582217512 582217512 478963203 ...

result:

ok 200000 tokens

Test #28:

score: 0
Accepted
time: 183ms
memory: 14616kb

input:

200000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

700746312 700746312 700746312 700746312 700746312 700746312 700746312 700746312 700746312 700746312 700746312 700746312 700746312 700746312 700746312 700746312 700746312 700746312 700746312 700746312 700746312 700746312 700746312 700746312 700746312 700746312 700746312 700746312 700746312 700746312 ...

result:

ok 200000 tokens

Test #29:

score: 0
Accepted
time: 181ms
memory: 14860kb

input:

200000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

433215183 433215183 433215183 433215183 433215183 433215183 433215183 433215183 433215183 433215183 433215183 433215183 433215183 433215183 433215183 433215183 433215183 433215183 433215183 433215183 433215183 433215183 433215183 433215183 433215183 433215183 433215183 433215183 433215183 433215183 ...

result:

ok 200000 tokens

Test #30:

score: 0
Accepted
time: 194ms
memory: 14624kb

input:

200000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

961570465 961570465 961570465 961570465 961570465 961570465 961570465 961570465 961570465 961570465 961570465 961570465 961570465 961570465 961570465 961570465 961570465 961570465 961570465 961570465 961570465 961570465 961570465 961570465 961570465 961570465 961570465 961570465 961570465 961570465 ...

result:

ok 200000 tokens

Test #31:

score: 0
Accepted
time: 182ms
memory: 14516kb

input:

200000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

92548611 92548611 92548611 92548611 92548611 92548611 92548611 92548611 92548611 92548611 92548611 92548611 92548611 92548611 92548611 92548611 92548611 92548611 92548611 92548611 92548611 92548611 92548611 92548611 92548611 92548611 92548611 92548611 92548611 92548611 92548611 92548611 92548611 925...

result:

ok 200000 tokens

Test #32:

score: 0
Accepted
time: 1ms
memory: 3932kb

input:

100
7 5 9 7 2 1 7 2 1 9 1 8 8 1 2 8 6 5 6 6 5 6 2 3 8 10 4 8 10 7 1 9 8 3 2 9 5 10 1 9 5 4 2 4 2 5 4 7 7 10 1 7 3 6 4 8 5 5 9 3 9 3 1 7 4 1 6 3 3 5 5 10 3 1 7 1 6 2 6 3 1 9 2 3 2 5 2 3 9 3 9 1 1 8 1 9 3 9 5 9

output:

80012380 42591007 69231102 42591007 42591007 42591007 42591007 42591007 42591007 57677538 42591007 52642780 54058087 42591007 46599929 59143905 44398018 43705698 44704063 45528542 45084289 48840558 45527037 48481629 50222919 49038124 44681995 44595932 45406740 47724058 42591007 46944631 45429315 459...

result:

ok 100 tokens

Test #33:

score: 0
Accepted
time: 1ms
memory: 3680kb

input:

100
12 1 2 11 1 4 6 15 2 9 12 8 11 2 16 8 10 7 17 10 5 17 4 5 6 16 7 7 17 14 15 7 5 10 10 3 15 1 17 7 10 20 11 12 13 16 5 6 12 13 8 2 8 12 18 12 6 13 13 7 12 17 18 4 20 13 3 11 10 2 6 14 3 15 8 12 13 10 6 19 12 19 8 17 7 14 17 15 20 17 12 10 8 13 2 13 16 20 10 14

output:

24171 5221 5221 5221 5221 5221 5221 7856 5221 5221 5221 5221 5221 5221 5911 5221 5771 5715 5667 5626 5561 5531 5482 5438 5397 5378 5361 5346 5362 5319 5307 5296 5286 5333 5365 5385 5816 5221 5715 5405 5410 6750 5389 5401 5411 5408 5401 5403 5403 5401 5557 5391 5536 5381 5660 5383 5381 5373 5374 5339...

result:

ok 100 tokens

Test #34:

score: 0
Accepted
time: 1ms
memory: 3796kb

input:

300
3 11 20 7 16 12 9 18 7 19 10 18 12 14 20 18 7 10 4 5 3 5 2 19 19 13 11 16 3 18 4 15 9 7 5 1 9 14 11 8 15 3 14 12 13 2 20 5 11 2 20 15 5 14 12 13 5 3 15 11 10 8 20 8 10 1 17 4 5 5 20 14 7 5 14 7 10 2 7 14 17 14 7 15 7 12 9 20 2 3 14 14 12 11 2 9 14 9 16 16 16 10 1 18 18 7 1 12 6 12 13 16 11 16 10...

output:

697699638 421636433 421636433 421636433 421636433 421636433 421636433 421636433 421636433 421636433 421636433 421636433 421636433 421636433 421636433 421636433 421636433 421636433 421636433 421636433 54311805 74687058 666711641 398242955 666711641 448424433 898399680 994443712 466058054 743345614 30...

result:

ok 300 tokens

Test #35:

score: 0
Accepted
time: 248ms
memory: 14664kb

input:

200000
2 2 2 1 1 3 2 1 2 3 3 2 2 3 3 1 1 2 1 1 1 1 2 3 3 1 3 1 3 2 1 2 3 3 2 2 3 1 3 1 2 3 3 1 3 1 2 3 3 2 2 3 3 2 1 1 1 2 1 3 1 1 1 2 3 3 1 3 1 2 3 3 1 2 3 2 2 3 2 2 1 1 3 2 3 3 3 3 2 3 2 1 2 2 1 2 3 1 2 3 2 3 1 3 3 2 1 1 2 2 2 1 2 2 2 3 3 3 3 3 1 1 1 1 2 3 2 2 2 1 3 1 3 3 3 2 1 3 1 1 1 1 3 3 1 3 2...

output:

444398413 665936789 555167601 665936789 665936789 143361571 761070616 665936789 376412429 25202780 376412429 727622078 961761844 610552195 555167601 665936789 665936789 555167601 665936789 665936789 665936789 665936789 483337931 809596129 483337931 665936789 790126370 665936789 626997271 65780304 66...

result:

ok 200000 tokens

Test #36:

score: 0
Accepted
time: 314ms
memory: 14888kb

input:

200000
9 7 6 8 3 4 2 4 2 6 4 6 5 7 2 5 10 4 7 7 3 8 1 4 5 4 9 5 10 10 6 4 5 3 2 6 4 6 5 6 2 5 2 6 9 10 9 9 8 9 7 3 10 4 5 7 10 4 6 1 5 3 3 10 10 2 6 2 3 6 5 10 1 1 4 2 9 6 4 3 9 7 8 5 7 2 6 4 3 5 8 9 3 6 2 1 1 10 10 7 4 2 6 3 3 4 4 2 8 1 6 5 1 8 5 8 5 6 10 7 3 9 10 8 1 6 4 9 10 9 6 4 3 9 3 9 10 9 1 ...

output:

317998635 375262180 375262180 375262180 375262180 375262180 375262180 375262180 375262180 404121322 707747700 615811947 527917555 768028500 708601872 613829643 842252844 993668088 340214511 766253777 651069439 435190184 375262180 729610616 394965425 808180413 235927248 308475028 44493600 983865994 1...

result:

ok 200000 tokens

Test #37:

score: 0
Accepted
time: 335ms
memory: 14640kb

input:

200000
16 29 19 26 5 10 8 12 9 21 28 20 15 15 16 14 1 5 5 16 28 3 13 23 22 15 22 12 1 14 19 24 25 15 8 8 13 3 1 27 28 18 8 7 27 2 18 9 2 13 13 15 18 23 21 23 27 7 7 10 16 5 19 29 20 17 28 20 22 26 9 6 5 13 19 23 2 16 21 9 17 12 21 22 23 15 5 9 30 3 24 11 4 22 22 17 6 22 22 24 21 29 25 17 15 30 16 4 ...

output:

293045010 627024432 402867102 402867102 402867102 402867102 402867102 402867102 402867102 402867102 402867102 402867102 402867102 402867102 402867102 402867102 402867102 402867102 402867102 402867102 402867102 402867102 402867102 402867102 402867102 402867102 402867102 402867102 402867102 793281169 ...

result:

ok 200000 tokens

Test #38:

score: 0
Accepted
time: 349ms
memory: 14736kb

input:

200000
50 59 99 95 33 98 12 85 55 40 37 89 51 7 71 52 85 91 76 34 29 60 95 2 41 36 4 42 91 6 85 4 53 48 15 51 46 10 13 71 68 8 16 84 33 24 98 91 56 58 63 78 7 26 51 55 75 5 6 13 5 37 14 27 36 12 65 63 81 61 52 67 14 60 89 28 43 88 42 22 29 80 36 81 42 15 24 95 78 74 49 80 56 11 93 69 25 64 84 21 77 ...

output:

936814648 597799851 516815561 597799851 597799851 597799851 597799851 597799851 597799851 597799851 597799851 597799851 597799851 597799851 597799851 597799851 597799851 597799851 597799851 597799851 597799851 597799851 597799851 597799851 597799851 597799851 597799851 597799851 597799851 597799851 ...

result:

ok 200000 tokens

Test #39:

score: 0
Accepted
time: 358ms
memory: 14660kb

input:

200000
379 16 236 260 348 139 380 67 302 67 72 159 151 256 214 211 160 257 211 80 166 392 141 169 282 395 279 295 98 181 312 181 54 274 124 244 371 22 241 57 11 263 76 59 291 255 322 149 36 107 15 346 380 110 258 123 138 63 31 243 340 246 155 316 20 163 132 151 279 8 311 121 253 90 184 104 300 243 7...

output:

470409828 31086466 31086466 31086466 31086466 31086466 31086466 31086466 31086466 31086466 31086466 31086466 31086466 31086466 31086466 31086466 31086466 31086466 31086466 31086466 31086466 31086466 31086466 31086466 31086466 31086466 31086466 31086466 31086466 31086466 31086466 31086466 31086466 31...

result:

ok 200000 tokens

Test #40:

score: 0
Accepted
time: 367ms
memory: 14932kb

input:

200000
1430 963 1357 314 1109 864 1348 496 1183 220 719 1261 703 333 1365 198 721 685 1143 1447 1351 367 891 20 768 1169 754 319 1113 1191 974 532 1466 455 241 1176 1019 563 344 655 868 1446 989 1318 624 679 682 802 575 368 1475 127 128 565 828 1077 1236 519 676 1190 1029 457 1479 1498 752 598 445 1...

output:

380199761 69057399 69057399 69057399 69057399 69057399 69057399 69057399 69057399 69057399 69057399 69057399 69057399 69057399 69057399 69057399 69057399 69057399 69057399 69057399 69057399 69057399 69057399 69057399 69057399 69057399 69057399 69057399 69057399 69057399 69057399 69057399 69057399 69...

result:

ok 200000 tokens

Test #41:

score: 0
Accepted
time: 401ms
memory: 14724kb

input:

200000
3162 3453 3258 3108 3715 3752 230 2743 307 1739 2982 2307 3232 2031 217 3242 2581 3886 3381 1091 1744 2648 2274 2006 516 3889 3101 1889 632 3953 2263 2486 2503 1699 468 3226 254 2310 2285 808 1570 2895 302 1324 231 3685 1944 2889 3577 1060 3648 788 2647 2363 398 918 3603 750 1728 2317 3507 13...

output:

321639721 19554262 19554262 19554262 19554262 19554262 19554262 19554262 19554262 19554262 19554262 19554262 19554262 19554262 19554262 19554262 19554262 19554262 19554262 19554262 19554262 19554262 19554262 19554262 19554262 19554262 19554262 19554262 19554262 19554262 19554262 19554262 19554262 19...

result:

ok 200000 tokens

Test #42:

score: 0
Accepted
time: 397ms
memory: 15012kb

input:

200000
3522 6233 4157 6952 6534 9727 5324 7793 4986 8897 7296 5464 4821 2088 5419 6193 6004 5666 9477 770 2985 6416 6695 5064 5175 7272 3762 9586 5432 7299 6758 7413 6951 736 7851 534 198 6592 9611 3283 2970 5416 4885 3691 2538 4370 9660 8785 6899 9004 3414 3821 2679 8471 8686 3994 809 7369 5555 543...

output:

855664730 319694377 319694377 319694377 319694377 319694377 319694377 319694377 319694377 319694377 319694377 319694377 319694377 319694377 319694377 319694377 319694377 319694377 319694377 319694377 319694377 319694377 319694377 319694377 319694377 319694377 319694377 319694377 319694377 319694377 ...

result:

ok 200000 tokens

Test #43:

score: 0
Accepted
time: 411ms
memory: 14668kb

input:

200000
13151 13043 15939 4003 3799 6745 14758 17658 1854 19751 1506 3696 12946 19913 3753 13151 17222 1709 6493 9035 18831 17719 10008 535 2408 8478 4213 21854 9407 15853 11588 555 16502 8019 15482 1472 15202 7603 3534 21219 6640 19349 4766 16653 18795 5827 14424 2265 17783 14797 18593 14379 570 219...

output:

949527696 234505604 234505604 234505604 234505604 234505604 234505604 234505604 234505604 234505604 234505604 234505604 234505604 234505604 234505604 234505604 234505604 234505604 234505604 234505604 234505604 234505604 234505604 234505604 234505604 234505604 234505604 234505604 234505604 234505604 ...

result:

ok 200000 tokens

Test #44:

score: 0
Accepted
time: 418ms
memory: 15428kb

input:

200000
2608 38741 4247 518 21640 5817 16595 36443 19472 32863 36988 2971 35495 3240 33019 1625 33801 38902 33556 7681 28451 713 15817 28438 5368 43525 22990 35934 40926 8274 36531 18945 42825 14619 36390 20013 29776 10864 26118 28797 19899 37340 28137 40485 10635 30471 17623 44560 19922 44365 34196 ...

output:

945517856 572879218 572879218 572879218 572879218 572879218 572879218 572879218 572879218 572879218 572879218 572879218 572879218 572879218 572879218 572879218 572879218 572879218 572879218 572879218 572879218 572879218 572879218 572879218 572879218 572879218 572879218 572879218 572879218 572879218 ...

result:

ok 200000 tokens

Test #45:

score: 0
Accepted
time: 444ms
memory: 17588kb

input:

200000
58086 6368 7844 5558 62993 60348 48332 44365 69279 77503 79143 59809 9658 31300 11652 57084 9843 55079 46805 39534 54462 7370 38702 66250 12019 66578 78668 46374 8399 16616 69004 12255 68209 64953 47855 29843 49373 18166 21789 23589 23164 66197 49630 75068 47514 77454 11682 57924 47207 56158 ...

output:

80009 40005 40005 40005 40005 40005 40005 40005 40005 40005 40005 40005 40005 40005 40005 40005 40005 40005 40005 40005 40005 40005 40005 40005 40005 40005 40005 40005 40005 40005 40005 40005 40005 40005 40005 40005 40005 40005 40005 40005 40005 40005 40005 40005 40005 40005 40005 40005 40005 40005 ...

result:

ok 200000 tokens

Test #46:

score: 0
Accepted
time: 445ms
memory: 16992kb

input:

200000
88473 4347 58303 84402 86559 8600 73964 26571 86439 76241 56293 13504 92885 49248 1793 36750 67732 113186 43932 4052 63055 92059 30739 6550 5049 96943 98890 3197 53446 110762 26217 83925 82032 42745 93787 111182 17843 39791 85198 74236 86352 49025 64245 32727 87758 34826 27017 19324 36853 658...

output:

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 1 1 1 1 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 200000 tokens

Extra Test:

score: 0
Extra Test Passed