QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#734484#6451. Maximum Color CliquemaspyAC ✓47ms4508kbC++2320.2kb2024-11-11 11:19:552024-11-11 11:19:56

Judging History

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

  • [2024-11-11 11:19:56]
  • 评测
  • 测评结果:AC
  • 用时:47ms
  • 内存:4508kb
  • [2024-11-11 11:19:55]
  • 提交

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_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 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 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 4 "main.cpp"

using mint = modint107;

void solve() {
  LL(N);
  VV(int, A, N, N);
  vc<int> vs;
  vc<int> color;
  vc<int> rest(N, 1);
  FOR(N) {
    auto [v, c] = [&]() -> pair<int, int> {
      FOR(v, N) {
        if (!rest[v]) continue;
        vc<int> S;
        FOR(w, N) if (rest[w] && v != w) S.eb(A[v][w]);
        if (S.empty()) return {v, 0};
        if (MIN(S) == MAX(S)) return {v, MIN(S)};
      }
      assert(0);
      return {0, 0};
    }();
    vs.eb(v);
    color.eb(c);
    rest[v] = 0;
  }
  reverse(all(color));

  vc<mint> ANS(N + 1);
  FOR(k, len(color)) {
    map<int, int> MP;
    FOR(i, k + 1, N) MP[color[i]]++;
    vc<int> S;
    for (auto& [a, b]: MP) S.eb(b);
    SHOW(S);
    // F[k] どれも k 回以下です
    vc<mint> F(N + 1);
    vc<mint> A(len(S));
    FOR(k, N + 1) {
      FOR(j, len(S)) A[j] += C<mint>(S[j], k);
      mint ans = 1;
      for (auto& x: A) ans *= x;
      F[k] = ans;
    }
    // 最頻値が k です
    FOR_R(k, 1, N + 1) F[k] -= F[k - 1];
    FOR(k, N) ANS[k + 1] += F[k];
  }
  mint ans = 0;
  FOR(k, N + 1) ans += ANS[k] * k;
  print(ans);
}

signed main() { solve(); }

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3992kb

input:

4
0 1 1 1
1 0 2 2
1 2 0 3
1 2 3 0

output:

26

result:

ok single line: '26'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3548kb

input:

5
0 300 300 300 300
300 0 300 300 300
300 300 0 300 300
300 300 300 0 300
300 300 300 300 0

output:

80

result:

ok single line: '80'

Test #3:

score: 0
Accepted
time: 6ms
memory: 4300kb

input:

299
0 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 10...

output:

224065094

result:

ok single line: '224065094'

Test #4:

score: 0
Accepted
time: 16ms
memory: 4252kb

input:

295
0 106 106 106 106 106 106 106 278 106 218 106 106 106 106 93 106 197 106 93 218 106 106 106 106 93 93 106 222 218 106 106 106 106 220 62 106 106 106 278 106 106 106 106 106 106 106 197 106 106 278 106 106 106 218 106 106 278 106 106 106 106 106 106 93 5 106 106 106 106 106 66 106 106 227 106 93 ...

output:

137501046

result:

ok single line: '137501046'

Test #5:

score: 0
Accepted
time: 2ms
memory: 4184kb

input:

300
0 228 228 228 228 228 228 228 228 228 228 228 228 228 228 228 228 228 228 228 228 228 228 228 228 228 228 228 228 228 228 228 228 228 228 228 228 228 228 228 228 228 228 228 228 228 228 228 228 228 228 228 228 228 228 228 228 228 228 228 228 228 228 228 228 228 228 228 228 228 228 228 228 228 22...

output:

799949831

result:

ok single line: '799949831'

Test #6:

score: 0
Accepted
time: 19ms
memory: 4424kb

input:

300
0 129 129 129 129 129 129 129 215 129 215 129 129 129 129 129 129 129 215 129 215 215 129 271 129 215 129 129 129 129 129 90 129 90 90 90 129 129 129 129 215 129 90 129 129 215 129 129 215 215 215 129 129 215 129 13 129 129 129 177 90 215 129 129 129 215 129 129 177 129 90 129 215 129 129 129 21...

output:

197646554

result:

ok single line: '197646554'

Test #7:

score: 0
Accepted
time: 39ms
memory: 4192kb

input:

300
0 117 117 117 117 117 255 117 117 117 117 117 117 117 117 117 271 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 257 117 117 117 16...

output:

178274746

result:

ok single line: '178274746'

Test #8:

score: 0
Accepted
time: 35ms
memory: 4200kb

input:

296
0 86 86 86 86 86 86 86 86 86 86 86 86 86 86 86 86 86 86 86 86 86 86 86 86 86 86 86 86 113 86 86 86 86 86 86 86 86 86 86 86 189 86 86 86 86 86 86 86 86 86 86 86 86 86 86 86 86 86 86 86 86 86 86 86 77 86 86 86 86 86 86 86 86 86 86 86 86 86 86 86 86 86 86 86 86 86 86 86 86 86 86 86 86 86 86 86 86 8...

output:

603115574

result:

ok single line: '603115574'

Test #9:

score: 0
Accepted
time: 45ms
memory: 4184kb

input:

297
0 300 81 187 187 187 84 267 261 187 43 187 187 233 136 123 284 254 187 248 187 187 185 84 84 155 187 187 187 274 187 75 187 118 296 187 187 187 187 148 187 197 187 53 172 187 114 26 187 285 158 187 95 187 187 186 187 24 285 187 187 129 187 33 187 197 2 187 187 187 274 187 187 187 187 166 187 187...

output:

832699692

result:

ok single line: '832699692'

Test #10:

score: 0
Accepted
time: 9ms
memory: 4184kb

input:

298
0 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 19 98 98 98 98 98 98 19 98 19 98 98 98 98 19 98 98 98 98 98 98 98 98 98 19 98 98 98 98 19 98 98 19 98 98 98 98 19 98 98 19 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 19 19 98 98 98 98 ...

output:

414162421

result:

ok single line: '414162421'

Test #11:

score: 0
Accepted
time: 4ms
memory: 4200kb

input:

295
0 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 10...

output:

85514344

result:

ok single line: '85514344'

Test #12:

score: 0
Accepted
time: 2ms
memory: 3988kb

input:

235
0 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 ...

output:

895535980

result:

ok single line: '895535980'

Test #13:

score: 0
Accepted
time: 34ms
memory: 4180kb

input:

294
0 138 138 106 138 166 166 166 166 239 166 166 166 166 37 166 144 166 166 166 166 166 170 166 97 166 166 151 7 166 166 166 166 166 166 166 166 166 166 166 166 97 166 166 166 166 233 293 166 293 166 166 154 166 166 166 166 166 200 166 166 149 243 216 166 144 166 166 166 166 166 166 166 166 300 166...

output:

490436597

result:

ok single line: '490436597'

Test #14:

score: 0
Accepted
time: 6ms
memory: 4300kb

input:

300
0 176 44 176 176 176 44 44 176 176 176 176 176 44 176 176 176 176 176 176 176 176 176 176 176 176 176 176 176 44 176 176 176 176 176 176 176 176 44 176 44 176 176 176 44 176 176 176 176 176 176 176 176 44 176 176 44 44 176 176 44 44 176 176 176 176 176 44 44 176 176 176 176 176 176 176 176 176 1...

output:

746382416

result:

ok single line: '746382416'

Test #15:

score: 0
Accepted
time: 14ms
memory: 4232kb

input:

300
0 58 245 196 98 245 78 245 190 196 190 196 196 190 196 58 245 245 58 196 196 78 196 196 78 190 196 190 196 196 196 245 196 196 190 245 245 245 196 58 245 98 196 190 196 190 58 190 245 190 190 245 58 196 58 190 78 245 190 190 245 190 245 245 58 196 190 58 196 58 196 196 190 190 190 196 190 58 58 ...

output:

905678311

result:

ok single line: '905678311'

Test #16:

score: 0
Accepted
time: 34ms
memory: 4464kb

input:

300
0 172 46 259 156 39 262 61 177 177 30 172 151 60 256 288 151 224 157 288 93 62 136 159 247 77 177 92 224 247 210 224 288 39 92 72 151 40 50 253 263 158 233 38 112 262 158 256 216 261 172 288 75 22 256 292 163 19 220 263 166 132 295 279 210 39 67 263 92 222 92 253 253 18 253 282 32 36 282 157 177...

output:

899220466

result:

ok single line: '899220466'

Test #17:

score: 0
Accepted
time: 15ms
memory: 4300kb

input:

300
0 269 166 166 269 269 260 269 269 184 184 269 166 269 166 260 260 166 218 218 260 269 269 166 218 166 166 218 218 269 269 260 166 166 206 218 218 260 218 184 166 269 260 184 83 218 184 83 218 260 166 184 184 260 218 83 83 260 72 166 83 72 166 218 166 83 206 166 166 184 206 72 184 206 184 218 166...

output:

706796123

result:

ok single line: '706796123'

Test #18:

score: 0
Accepted
time: 10ms
memory: 4196kb

input:

300
0 186 186 44 186 186 186 186 44 44 44 44 186 44 186 186 186 44 67 44 44 186 44 186 186 186 186 186 44 44 44 44 44 186 186 44 67 186 186 44 186 186 44 186 186 44 44 67 186 44 186 44 44 44 186 186 186 44 186 44 186 186 186 44 44 186 186 186 186 67 186 44 44 44 186 186 186 186 186 186 186 186 44 44...

output:

205173206

result:

ok single line: '205173206'

Test #19:

score: 0
Accepted
time: 24ms
memory: 4492kb

input:

300
0 28 28 28 134 22 168 28 28 296 79 296 28 168 282 296 79 79 28 28 296 257 28 28 137 28 296 79 142 79 79 28 296 22 79 1 257 28 296 28 28 168 28 28 28 282 28 28 79 28 28 28 28 296 28 22 94 28 28 22 28 79 137 134 28 28 134 28 28 108 28 28 79 108 28 28 28 28 28 257 296 296 28 296 202 28 28 28 79 142...

output:

815908627

result:

ok single line: '815908627'

Test #20:

score: 0
Accepted
time: 9ms
memory: 4192kb

input:

299
0 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 ...

output:

926962184

result:

ok single line: '926962184'

Test #21:

score: 0
Accepted
time: 8ms
memory: 4460kb

input:

288
0 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 240 24...

output:

387297380

result:

ok single line: '387297380'

Test #22:

score: 0
Accepted
time: 47ms
memory: 4264kb

input:

297
0 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 78 232 232 232 232 232 232 232 232 232 232 232 50 232 266 232 232 157 203 232 232 232 232 232 232 232 232 278 232 232 242 232 232 232 232 232 232 232 232 278 232 232 232 232 232 232 232 232 232 232 157 232 232 232 232 ...

output:

394002233

result:

ok single line: '394002233'

Test #23:

score: 0
Accepted
time: 23ms
memory: 4288kb

input:

295
0 76 290 220 165 95 3 290 290 78 200 142 104 165 290 165 104 95 45 220 45 104 158 45 290 165 165 290 95 165 95 290 217 110 104 45 165 100 290 45 95 110 95 104 290 45 95 290 45 290 45 104 95 290 194 290 104 200 45 95 3 220 218 200 220 45 140 3 40 163 95 110 95 165 158 142 290 218 290 95 217 36 29...

output:

768048031

result:

ok single line: '768048031'

Test #24:

score: 0
Accepted
time: 25ms
memory: 4300kb

input:

299
0 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 ...

output:

74210755

result:

ok single line: '74210755'

Test #25:

score: 0
Accepted
time: 16ms
memory: 4420kb

input:

300
0 176 101 262 176 176 176 262 176 101 176 262 176 176 262 176 176 176 262 176 176 176 176 117 262 176 176 101 101 262 101 176 176 176 176 262 101 176 117 176 176 176 262 176 262 176 262 176 262 262 117 262 262 176 176 101 176 101 176 176 101 176 117 262 101 176 262 176 176 176 262 176 176 176 26...

output:

701023481

result:

ok single line: '701023481'

Test #26:

score: 0
Accepted
time: 41ms
memory: 4508kb

input:

299
0 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 291 8 8 8 8 8 8 8 8 8 8 249 8 8 8 8 8 8 8 8 8 8 8 66 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 249 8 8 8 8 8 8 221 8 8 8 8 153 262 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 177 8 8 8 8 8 8 8 8 8 8 8...

output:

328030166

result:

ok single line: '328030166'

Test #27:

score: 0
Accepted
time: 8ms
memory: 4136kb

input:

300
0 202 202 202 202 202 202 202 202 202 202 202 202 202 202 202 202 202 202 202 202 202 202 202 202 202 202 202 202 202 202 202 202 202 202 202 202 202 202 202 202 202 202 202 202 202 202 202 202 202 202 202 202 202 202 202 202 202 202 202 202 202 202 202 202 202 202 202 202 202 202 202 202 202 20...

output:

328214720

result:

ok single line: '328214720'

Test #28:

score: 0
Accepted
time: 3ms
memory: 4244kb

input:

300
0 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 20...

output:

605941905

result:

ok single line: '605941905'

Test #29:

score: 0
Accepted
time: 36ms
memory: 4436kb

input:

297
0 95 197 6 109 230 230 48 48 140 48 48 291 207 48 48 124 57 291 149 289 48 197 83 272 125 48 225 65 48 48 48 48 48 48 149 48 214 48 160 206 281 291 230 48 48 48 125 48 48 149 269 48 58 95 48 203 140 48 234 138 48 149 160 149 69 48 234 132 247 300 48 95 44 197 48 58 192 234 48 48 197 48 48 137 28...

output:

816411611

result:

ok single line: '816411611'

Test #30:

score: 0
Accepted
time: 31ms
memory: 4140kb

input:

300
0 53 258 258 31 262 246 258 258 263 286 49 258 44 53 258 258 258 258 258 258 258 170 90 258 118 214 258 132 258 258 258 271 258 258 258 258 214 258 258 286 258 258 258 258 258 279 258 1 214 258 53 213 258 258 239 258 271 206 258 258 258 258 258 258 22 258 258 258 206 258 258 20 214 213 258 258 2...

output:

613931266

result:

ok single line: '613931266'

Test #31:

score: 0
Accepted
time: 39ms
memory: 4200kb

input:

298
0 243 243 200 40 280 77 243 259 243 160 58 218 61 77 14 243 243 218 243 113 14 160 243 138 262 14 24 14 101 120 243 192 243 26 170 243 243 243 243 243 243 243 77 243 26 227 160 243 14 243 270 243 243 118 24 243 243 243 243 173 174 243 243 243 91 274 243 243 89 89 14 89 243 243 243 243 203 243 24...

output:

937956902

result:

ok single line: '937956902'

Test #32:

score: 0
Accepted
time: 6ms
memory: 4424kb

input:

299
0 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 166 16...

output:

61767795

result:

ok single line: '61767795'

Test #33:

score: 0
Accepted
time: 11ms
memory: 4476kb

input:

292
0 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 ...

output:

286888018

result:

ok single line: '286888018'

Test #34:

score: 0
Accepted
time: 4ms
memory: 4088kb

input:

300
0 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 18...

output:

606253694

result:

ok single line: '606253694'

Test #35:

score: 0
Accepted
time: 3ms
memory: 4284kb

input:

300
0 162 162 162 162 162 162 162 162 162 162 162 162 162 162 162 162 162 162 162 162 162 162 162 162 162 162 162 162 162 162 162 162 162 162 162 162 162 162 162 162 162 162 162 162 162 162 162 162 162 162 162 162 162 162 162 162 162 162 162 162 162 162 162 162 162 162 162 162 162 162 162 162 162 16...

output:

350268997

result:

ok single line: '350268997'

Test #36:

score: 0
Accepted
time: 11ms
memory: 4136kb

input:

280
0 48 48 64 268 48 107 48 64 243 243 243 48 201 243 243 107 243 243 213 64 243 243 48 48 268 107 243 53 53 107 243 243 48 243 107 243 48 243 243 243 64 48 213 243 243 243 64 48 243 243 48 48 243 243 48 48 243 243 243 48 48 243 48 268 48 48 243 64 64 268 64 243 48 243 243 243 48 48 48 64 213 213 2...

output:

797216242

result:

ok single line: '797216242'

Test #37:

score: 0
Accepted
time: 10ms
memory: 4148kb

input:

298
0 291 291 291 291 291 291 291 291 291 291 291 291 291 291 291 291 291 291 291 291 291 291 291 291 291 291 291 291 291 291 291 291 291 291 291 291 291 291 291 291 291 291 291 291 291 291 291 291 291 291 291 291 291 291 291 291 291 291 291 291 291 291 291 291 291 291 291 291 291 291 291 291 291 29...

output:

288980221

result:

ok single line: '288980221'

Test #38:

score: 0
Accepted
time: 9ms
memory: 4428kb

input:

300
0 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 117 11...

output:

389446582

result:

ok single line: '389446582'

Test #39:

score: 0
Accepted
time: 12ms
memory: 4156kb

input:

282
0 143 61 94 143 192 143 143 192 143 192 143 61 94 143 143 61 61 113 192 94 143 94 26 61 143 143 94 143 143 61 143 143 143 61 143 192 94 143 143 143 143 143 272 94 143 143 143 94 94 143 143 143 143 143 143 143 192 143 143 143 143 94 113 143 143 113 143 192 94 143 143 143 143 143 143 61 143 143 20...

output:

230538141

result:

ok single line: '230538141'

Test #40:

score: 0
Accepted
time: 12ms
memory: 4152kb

input:

277
0 191 191 215 15 280 118 69 81 215 215 41 41 81 287 292 215 191 81 191 215 215 191 191 69 118 191 191 215 81 15 191 15 215 191 191 191 264 69 191 191 160 191 81 15 280 81 191 215 280 215 15 191 160 215 81 81 215 15 191 81 79 81 280 69 215 15 160 81 191 191 15 191 81 268 81 81 15 215 215 215 191 ...

output:

918281717

result:

ok single line: '918281717'

Test #41:

score: 0
Accepted
time: 16ms
memory: 4264kb

input:

300
0 82 176 176 176 268 176 176 176 268 268 176 268 268 268 268 268 176 268 268 268 268 268 197 176 82 176 268 82 176 268 176 98 176 268 176 82 268 268 176 176 268 268 176 176 176 176 176 268 82 176 176 268 268 197 268 176 176 268 176 176 176 268 176 268 176 176 268 176 268 176 176 176 176 268 176 ...

output:

26534708

result:

ok single line: '26534708'

Test #42:

score: 0
Accepted
time: 27ms
memory: 4208kb

input:

300
0 165 271 97 165 165 271 200 261 165 165 165 165 165 165 253 165 212 165 165 165 200 165 216 165 165 165 165 165 165 261 165 165 165 165 165 165 165 165 165 165 165 130 165 165 271 165 197 165 271 165 165 165 165 165 165 165 165 165 165 165 165 200 29 212 271 165 165 165 165 165 165 165 165 165 ...

output:

586273615

result:

ok single line: '586273615'

Test #43:

score: 0
Accepted
time: 18ms
memory: 4188kb

input:

294
0 161 82 161 161 243 209 138 161 161 161 209 247 209 293 209 209 161 158 161 201 216 161 39 126 209 238 161 161 209 70 206 209 161 209 209 138 161 161 161 149 92 161 244 158 250 138 105 244 256 138 13 43 161 97 161 161 209 70 209 161 158 161 161 209 256 161 104 116 13 161 161 209 117 209 161 209...

output:

534816934

result:

ok single line: '534816934'

Test #44:

score: 0
Accepted
time: 6ms
memory: 4476kb

input:

300
0 115 115 115 115 115 115 115 115 115 115 115 115 115 115 115 115 115 115 115 115 115 115 115 115 115 115 115 115 115 115 115 115 115 115 115 115 115 115 115 115 115 115 115 115 115 115 115 115 115 115 115 115 115 115 115 115 115 115 115 115 115 115 115 115 115 115 115 115 115 115 115 115 115 11...

output:

860758290

result:

ok single line: '860758290'

Test #45:

score: 0
Accepted
time: 18ms
memory: 4292kb

input:

295
0 82 82 298 9 82 298 82 82 82 12 178 82 12 298 87 87 82 82 298 82 82 12 67 298 182 182 174 298 298 87 9 82 101 82 82 82 298 82 12 87 174 9 9 82 251 114 82 82 87 82 9 82 298 82 82 82 298 87 9 146 298 87 146 12 82 82 87 298 82 298 82 82 298 82 82 298 82 82 82 12 9 298 174 9 77 51 82 298 82 82 82 2...

output:

998278320

result:

ok single line: '998278320'

Test #46:

score: 0
Accepted
time: 9ms
memory: 4184kb

input:

298
0 211 211 211 211 211 211 211 211 211 211 211 211 211 72 278 211 211 211 211 211 211 211 211 211 278 72 72 211 211 211 211 72 278 278 211 278 72 211 211 211 211 211 211 211 211 278 211 211 211 211 211 211 211 211 72 211 211 211 211 211 211 278 211 278 211 72 211 211 211 211 211 211 278 211 211 2...

output:

798338349

result:

ok single line: '798338349'

Test #47:

score: 0
Accepted
time: 40ms
memory: 4204kb

input:

298
0 267 35 118 100 35 55 35 35 27 35 35 6 35 99 35 185 139 260 35 185 35 146 94 214 160 35 35 35 185 250 185 27 214 18 276 118 46 111 188 20 39 170 82 35 247 96 35 185 120 177 94 197 98 35 35 185 289 214 260 82 82 35 170 60 35 99 35 185 35 35 170 173 35 35 120 35 35 35 35 35 55 30 35 35 188 214 35...

output:

974473747

result:

ok single line: '974473747'

Test #48:

score: 0
Accepted
time: 15ms
memory: 4292kb

input:

300
0 33 33 33 189 76 76 189 189 33 76 29 33 189 33 189 33 33 189 29 199 76 29 199 76 76 203 199 199 33 33 189 33 33 199 189 189 76 29 189 33 76 76 203 76 76 29 33 189 33 203 189 247 189 189 189 33 189 76 76 33 76 189 189 189 189 76 76 189 33 189 76 199 189 189 189 189 189 33 199 29 33 199 199 33 29...

output:

105198796

result:

ok single line: '105198796'

Test #49:

score: 0
Accepted
time: 25ms
memory: 4260kb

input:

300
0 247 247 247 38 247 247 247 247 276 247 247 243 247 276 247 247 247 247 121 277 271 247 38 243 245 38 237 243 279 247 276 121 247 245 243 247 247 247 247 233 247 181 276 89 213 247 247 289 89 95 247 277 247 247 245 247 233 247 243 181 247 276 271 247 276 247 247 247 247 247 247 247 247 89 247 2...

output:

665594214

result:

ok single line: '665594214'

Test #50:

score: 0
Accepted
time: 26ms
memory: 4136kb

input:

264
0 295 295 295 295 295 295 295 295 295 295 133 175 295 124 66 295 295 295 175 295 295 295 295 168 295 295 295 295 295 175 295 295 295 295 295 295 295 295 295 295 295 175 295 295 195 295 295 295 295 295 295 295 142 295 66 295 295 103 295 295 295 168 295 295 175 295 124 66 295 124 295 295 295 241 2...

output:

39096045

result:

ok single line: '39096045'

Test #51:

score: 0
Accepted
time: 9ms
memory: 4460kb

input:

300
0 37 212 37 37 37 37 37 68 37 212 37 37 212 212 37 37 37 68 37 37 68 37 68 68 37 37 212 37 212 37 37 37 37 37 212 37 37 37 37 37 37 37 212 212 37 68 37 212 68 37 37 37 68 37 37 212 212 212 37 68 37 68 37 68 212 37 37 37 37 37 37 37 37 37 37 37 37 37 212 37 37 212 37 37 37 37 68 37 68 37 37 68 37...

output:

205210439

result:

ok single line: '205210439'

Test #52:

score: 0
Accepted
time: 8ms
memory: 4200kb

input:

299
0 10 77 10 77 10 77 77 77 77 77 77 77 77 10 77 10 10 77 77 77 77 10 10 77 10 77 77 77 10 77 10 77 77 10 77 10 77 77 10 77 77 77 77 10 10 10 10 77 77 77 77 77 77 77 77 10 77 77 77 77 77 77 10 77 77 77 77 77 77 77 10 10 77 77 77 77 10 77 10 10 10 77 10 77 77 77 77 77 77 77 10 77 77 77 77 77 77 77 ...

output:

502954576

result:

ok single line: '502954576'

Test #53:

score: 0
Accepted
time: 34ms
memory: 4432kb

input:

274
0 143 216 143 187 88 143 143 143 240 181 143 143 184 248 248 66 166 189 68 141 143 143 163 143 237 143 96 240 74 143 143 143 237 134 67 143 143 202 143 143 134 104 143 1 143 25 77 242 1 143 203 237 42 112 143 195 252 143 240 143 140 203 242 143 143 96 108 130 143 60 143 143 237 93 66 133 128 256...

output:

94418405

result:

ok single line: '94418405'