QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#740196#8518. Roars IIImaspyAC ✓399ms533376kbC++2333.4kb2024-11-13 03:25:122024-11-13 03:25:12

Judging History

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

  • [2024-11-13 03:25:12]
  • 评测
  • 测评结果:AC
  • 用时:399ms
  • 内存:533376kb
  • [2024-11-13 03:25:12]
  • 提交

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

#line 2 "/home/maspy/compro/library/graph/tree.hpp"

#line 2 "/home/maspy/compro/library/graph/base.hpp"

template <typename T>
struct Edge {
  int frm, to;
  T cost;
  int id;
};

template <typename T = int, bool directed = false>
struct Graph {
  static constexpr bool is_directed = directed;
  int N, M;
  using cost_type = T;
  using edge_type = Edge<T>;
  vector<edge_type> edges;
  vector<int> indptr;
  vector<edge_type> csr_edges;
  vc<int> vc_deg, vc_indeg, vc_outdeg;
  bool prepared;

  class OutgoingEdges {
  public:
    OutgoingEdges(const Graph* G, int l, int r) : G(G), l(l), r(r) {}

    const edge_type* begin() const {
      if (l == r) { return 0; }
      return &G->csr_edges[l];
    }

    const edge_type* end() const {
      if (l == r) { return 0; }
      return &G->csr_edges[r];
    }

  private:
    const Graph* G;
    int l, r;
  };

  bool is_prepared() { return prepared; }

  Graph() : N(0), M(0), prepared(0) {}
  Graph(int N) : N(N), M(0), prepared(0) {}

  void build(int n) {
    N = n, M = 0;
    prepared = 0;
    edges.clear();
    indptr.clear();
    csr_edges.clear();
    vc_deg.clear();
    vc_indeg.clear();
    vc_outdeg.clear();
  }

  void add(int frm, int to, T cost = 1, int i = -1) {
    assert(!prepared);
    assert(0 <= frm && 0 <= to && to < N);
    if (i == -1) i = M;
    auto e = edge_type({frm, to, cost, i});
    edges.eb(e);
    ++M;
  }

#ifdef FASTIO
  // wt, off
  void read_tree(bool wt = false, int off = 1) { read_graph(N - 1, wt, off); }

  void read_graph(int M, bool wt = false, int off = 1) {
    for (int m = 0; m < M; ++m) {
      INT(a, b);
      a -= off, b -= off;
      if (!wt) {
        add(a, b);
      } else {
        T c;
        read(c);
        add(a, b, c);
      }
    }
    build();
  }
#endif

  void build() {
    assert(!prepared);
    prepared = true;
    indptr.assign(N + 1, 0);
    for (auto&& e: edges) {
      indptr[e.frm + 1]++;
      if (!directed) indptr[e.to + 1]++;
    }
    for (int v = 0; v < N; ++v) { indptr[v + 1] += indptr[v]; }
    auto counter = indptr;
    csr_edges.resize(indptr.back() + 1);
    for (auto&& e: edges) {
      csr_edges[counter[e.frm]++] = e;
      if (!directed)
        csr_edges[counter[e.to]++] = edge_type({e.to, e.frm, e.cost, e.id});
    }
  }

  OutgoingEdges operator[](int v) const {
    assert(prepared);
    return {this, indptr[v], indptr[v + 1]};
  }

  vc<int> deg_array() {
    if (vc_deg.empty()) calc_deg();
    return vc_deg;
  }

  pair<vc<int>, vc<int>> deg_array_inout() {
    if (vc_indeg.empty()) calc_deg_inout();
    return {vc_indeg, vc_outdeg};
  }

  int deg(int v) {
    if (vc_deg.empty()) calc_deg();
    return vc_deg[v];
  }

  int in_deg(int v) {
    if (vc_indeg.empty()) calc_deg_inout();
    return vc_indeg[v];
  }

  int out_deg(int v) {
    if (vc_outdeg.empty()) calc_deg_inout();
    return vc_outdeg[v];
  }

#ifdef FASTIO
  void debug() {
    print("Graph");
    if (!prepared) {
      print("frm to cost id");
      for (auto&& e: edges) print(e.frm, e.to, e.cost, e.id);
    } else {
      print("indptr", indptr);
      print("frm to cost id");
      FOR(v, N) for (auto&& e: (*this)[v]) print(e.frm, e.to, e.cost, e.id);
    }
  }
#endif

  vc<int> new_idx;
  vc<bool> used_e;

  // G における頂点 V[i] が、新しいグラフで i になるようにする
  // {G, es}
  // sum(deg(v)) の計算量になっていて、
  // 新しいグラフの n+m より大きい可能性があるので注意
  Graph<T, directed> rearrange(vc<int> V, bool keep_eid = 0) {
    if (len(new_idx) != N) new_idx.assign(N, -1);
    int n = len(V);
    FOR(i, n) new_idx[V[i]] = i;
    Graph<T, directed> G(n);
    vc<int> history;
    FOR(i, n) {
      for (auto&& e: (*this)[V[i]]) {
        if (len(used_e) <= e.id) used_e.resize(e.id + 1);
        if (used_e[e.id]) continue;
        int a = e.frm, b = e.to;
        if (new_idx[a] != -1 && new_idx[b] != -1) {
          history.eb(e.id);
          used_e[e.id] = 1;
          int eid = (keep_eid ? e.id : -1);
          G.add(new_idx[a], new_idx[b], e.cost, eid);
        }
      }
    }
    FOR(i, n) new_idx[V[i]] = -1;
    for (auto&& eid: history) used_e[eid] = 0;
    G.build();
    return G;
  }

  Graph<T, true> to_directed_tree(int root = -1) {
    if (root == -1) root = 0;
    assert(!is_directed && prepared && M == N - 1);
    Graph<T, true> G1(N);
    vc<int> par(N, -1);
    auto dfs = [&](auto& dfs, int v) -> void {
      for (auto& e: (*this)[v]) {
        if (e.to == par[v]) continue;
        par[e.to] = v, dfs(dfs, e.to);
      }
    };
    dfs(dfs, root);
    for (auto& e: edges) {
      int a = e.frm, b = e.to;
      if (par[a] == b) swap(a, b);
      assert(par[b] == a);
      G1.add(a, b, e.cost);
    }
    G1.build();
    return G1;
  }

private:
  void calc_deg() {
    assert(vc_deg.empty());
    vc_deg.resize(N);
    for (auto&& e: edges) vc_deg[e.frm]++, vc_deg[e.to]++;
  }

  void calc_deg_inout() {
    assert(vc_indeg.empty());
    vc_indeg.resize(N);
    vc_outdeg.resize(N);
    for (auto&& e: edges) { vc_indeg[e.to]++, vc_outdeg[e.frm]++; }
  }
};
#line 4 "/home/maspy/compro/library/graph/tree.hpp"

// HLD euler tour をとっていろいろ。
template <typename GT>
struct Tree {
  using Graph_type = GT;
  GT &G;
  using WT = typename GT::cost_type;
  int N;
  vector<int> LID, RID, head, V, parent, VtoE;
  vc<int> depth;
  vc<WT> depth_weighted;

  Tree(GT &G, int r = 0, bool hld = 1) : G(G) { build(r, hld); }

  void build(int r = 0, bool hld = 1) {
    if (r == -1) return; // build を遅延したいとき
    N = G.N;
    LID.assign(N, -1), RID.assign(N, -1), head.assign(N, r);
    V.assign(N, -1), parent.assign(N, -1), VtoE.assign(N, -1);
    depth.assign(N, -1), depth_weighted.assign(N, 0);
    assert(G.is_prepared());
    int t1 = 0;
    dfs_sz(r, -1, hld);
    dfs_hld(r, t1);
  }

  void dfs_sz(int v, int p, bool hld) {
    auto &sz = RID;
    parent[v] = p;
    depth[v] = (p == -1 ? 0 : depth[p] + 1);
    sz[v] = 1;
    int l = G.indptr[v], r = G.indptr[v + 1];
    auto &csr = G.csr_edges;
    // 使う辺があれば先頭にする
    for (int i = r - 2; i >= l; --i) {
      if (hld && depth[csr[i + 1].to] == -1) swap(csr[i], csr[i + 1]);
    }
    int hld_sz = 0;
    for (int i = l; i < r; ++i) {
      auto e = csr[i];
      if (depth[e.to] != -1) continue;
      depth_weighted[e.to] = depth_weighted[v] + e.cost;
      VtoE[e.to] = e.id;
      dfs_sz(e.to, v, hld);
      sz[v] += sz[e.to];
      if (hld && chmax(hld_sz, sz[e.to]) && l < i) { swap(csr[l], csr[i]); }
    }
  }

  void dfs_hld(int v, int &times) {
    LID[v] = times++;
    RID[v] += LID[v];
    V[LID[v]] = v;
    bool heavy = true;
    for (auto &&e: G[v]) {
      if (depth[e.to] <= depth[v]) continue;
      head[e.to] = (heavy ? head[v] : e.to);
      heavy = false;
      dfs_hld(e.to, times);
    }
  }

  vc<int> heavy_path_at(int v) {
    vc<int> P = {v};
    while (1) {
      int a = P.back();
      for (auto &&e: G[a]) {
        if (e.to != parent[a] && head[e.to] == v) {
          P.eb(e.to);
          break;
        }
      }
      if (P.back() == a) break;
    }
    return P;
  }

  int heavy_child(int v) {
    int k = LID[v] + 1;
    if (k == N) return -1;
    int w = V[k];
    return (parent[w] == v ? w : -1);
  }

  int e_to_v(int eid) {
    auto e = G.edges[eid];
    return (parent[e.frm] == e.to ? e.frm : e.to);
  }
  int v_to_e(int v) { return VtoE[v]; }
  int get_eid(int u, int v) {
    if (parent[u] != v) swap(u, v);
    assert(parent[u] == v);
    return VtoE[u];
  }

  int ELID(int v) { return 2 * LID[v] - depth[v]; }
  int ERID(int v) { return 2 * RID[v] - depth[v] - 1; }

  // 目標地点へ進む個数が k
  int LA(int v, int k) {
    assert(k <= depth[v]);
    while (1) {
      int u = head[v];
      if (LID[v] - k >= LID[u]) return V[LID[v] - k];
      k -= LID[v] - LID[u] + 1;
      v = parent[u];
    }
  }
  int la(int u, int v) { return LA(u, v); }

  int LCA(int u, int v) {
    for (;; v = parent[head[v]]) {
      if (LID[u] > LID[v]) swap(u, v);
      if (head[u] == head[v]) return u;
    }
  }

  int meet(int a, int b, int c) { return LCA(a, b) ^ LCA(a, c) ^ LCA(b, c); }
  int lca(int u, int v) { return LCA(u, v); }

  int subtree_size(int v, int root = -1) {
    if (root == -1) return RID[v] - LID[v];
    if (v == root) return N;
    int x = jump(v, root, 1);
    if (in_subtree(v, x)) return RID[v] - LID[v];
    return N - RID[x] + LID[x];
  }

  int dist(int a, int b) {
    int c = LCA(a, b);
    return depth[a] + depth[b] - 2 * depth[c];
  }

  WT dist_weighted(int a, int b) {
    int c = LCA(a, b);
    return depth_weighted[a] + depth_weighted[b] - WT(2) * depth_weighted[c];
  }

  // a is in b
  bool in_subtree(int a, int b) { return LID[b] <= LID[a] && LID[a] < RID[b]; }

  int jump(int a, int b, ll k) {
    if (k == 1) {
      if (a == b) return -1;
      return (in_subtree(b, a) ? LA(b, depth[b] - depth[a] - 1) : parent[a]);
    }
    int c = LCA(a, b);
    int d_ac = depth[a] - depth[c];
    int d_bc = depth[b] - depth[c];
    if (k > d_ac + d_bc) return -1;
    if (k <= d_ac) return LA(a, k);
    return LA(b, d_ac + d_bc - k);
  }

  vc<int> collect_child(int v) {
    vc<int> res;
    for (auto &&e: G[v])
      if (e.to != parent[v]) res.eb(e.to);
    return res;
  }

  vc<int> collect_light(int v) {
    vc<int> res;
    bool skip = true;
    for (auto &&e: G[v])
      if (e.to != parent[v]) {
        if (!skip) res.eb(e.to);
        skip = false;
      }
    return res;
  }

  vc<pair<int, int>> get_path_decomposition(int u, int v, bool edge) {
    // [始点, 終点] の"閉"区間列。
    vc<pair<int, int>> up, down;
    while (1) {
      if (head[u] == head[v]) break;
      if (LID[u] < LID[v]) {
        down.eb(LID[head[v]], LID[v]);
        v = parent[head[v]];
      } else {
        up.eb(LID[u], LID[head[u]]);
        u = parent[head[u]];
      }
    }
    if (LID[u] < LID[v]) down.eb(LID[u] + edge, LID[v]);
    elif (LID[v] + edge <= LID[u]) up.eb(LID[u], LID[v] + edge);
    reverse(all(down));
    up.insert(up.end(), all(down));
    return up;
  }

  // 辺の列の情報 (frm,to,str)
  // str = "heavy_up", "heavy_down", "light_up", "light_down"
  vc<tuple<int, int, string>> get_path_decomposition_detail(int u, int v) {
    vc<tuple<int, int, string>> up, down;
    while (1) {
      if (head[u] == head[v]) break;
      if (LID[u] < LID[v]) {
        if (v != head[v]) down.eb(head[v], v, "heavy_down"), v = head[v];
        down.eb(parent[v], v, "light_down"), v = parent[v];
      } else {
        if (u != head[u]) up.eb(u, head[u], "heavy_up"), u = head[u];
        up.eb(u, parent[u], "light_up"), u = parent[u];
      }
    }
    if (LID[u] < LID[v]) down.eb(u, v, "heavy_down");
    elif (LID[v] < LID[u]) up.eb(u, v, "heavy_up");
    reverse(all(down));
    concat(up, down);
    return up;
  }

  vc<int> restore_path(int u, int v) {
    vc<int> P;
    for (auto &&[a, b]: get_path_decomposition(u, v, 0)) {
      if (a <= b) {
        FOR(i, a, b + 1) P.eb(V[i]);
      } else {
        FOR_R(i, b, a + 1) P.eb(V[i]);
      }
    }
    return P;
  }

  // path [a,b] と [c,d] の交わり. 空ならば {-1,-1}.
  // https://codeforces.com/problemset/problem/500/G
  pair<int, int> path_intersection(int a, int b, int c, int d) {
    int ab = lca(a, b), ac = lca(a, c), ad = lca(a, d);
    int bc = lca(b, c), bd = lca(b, d), cd = lca(c, d);
    int x = ab ^ ac ^ bc, y = ab ^ ad ^ bd; // meet(a,b,c), meet(a,b,d)
    if (x != y) return {x, y};
    int z = ac ^ ad ^ cd;
    if (x != z) x = -1;
    return {x, x};
  }

  // uv path 上で check(v) を満たす最後の v
  // なければ (つまり check(v) が ng )-1
  template <class F>
  int max_path(F check, int u, int v) {
    if (!check(u)) return -1;
    auto pd = get_path_decomposition(u, v, false);
    for (auto [a, b]: pd) {
      if (!check(V[a])) return u;
      if (check(V[b])) {
        u = V[b];
        continue;
      }
      int c = binary_search([&](int c) -> bool { return check(V[c]); }, a, b, 0);
      return V[c];
    }
    return u;
  }
};
#line 4 "/home/maspy/compro/library/graph/tree_dp/rerooting_dp.hpp"

template <typename TREE, typename Data>
struct Rerooting_dp {
  static_assert(!TREE::Graph_type::is_directed);
  TREE& tree;
  vc<Data> dp_1; // 辺 pv に対して、部分木 v
  vc<Data> dp_2; // 辺 pv に対して、部分木 p
  vc<Data> dp;   // full tree

  template <typename F1, typename F2, typename F3>
  Rerooting_dp(TREE& tree, F1 f_ee, F2 f_ev, F3 f_ve, const Data unit)
      : tree(tree) {
    build(f_ee, f_ev, f_ve, unit);
  }

  // v を根としたときの full tree
  Data operator[](int v) { return dp[v]; }

  // root を根としたときの部分木 v
  Data get(int v, int root) {
    if (root == v) return dp[v];
    if (!tree.in_subtree(root, v)) { return dp_1[v]; }
    int w = tree.jump(v, root, 1);
    return dp_2[w];
  }

  template <typename F1, typename F2, typename F3>
  void build(F1 f_ee, F2 f_ev, F3 f_ve, const Data unit) {
    int N = tree.N;
    // dp1: subtree
    dp_1.assign(N, unit);
    FOR_R(i, N) {
      int v = tree.V[i];
      for (auto&& e: tree.G[v]) {
        if (e.to == tree.parent[v]) continue;
        dp_1[v] = f_ee(dp_1[v], f_ve(dp_1[e.to], e));
      }
      dp_1[v] = f_ev(dp_1[v], v);
    }

    // dp2[v]: subtree of p, rooted at v
    dp_2.assign(N, unit);
    // dp[v]: fulltree, rooted at v
    dp.assign(N, unit);
    FOR(i, N) {
      int p = tree.V[i];
      vc<int> ch;
      vc<Data> ch_data;
      Data x = unit;
      for (auto&& e: tree.G[p]) {
        if (e.to == tree.parent[p]) {
          x = f_ve(dp_2[p], e);
        } else {
          ch.eb(e.to);
          ch_data.eb(f_ve(dp_1[e.to], e));
        }
      }
      int n = len(ch);
      if (!n) {
        dp[p] = f_ev(x, p);
        continue;
      }
      vc<Data> prod_left(n, x);
      FOR(i, n - 1) prod_left[i + 1] = f_ee(prod_left[i], ch_data[i]);
      Data prod_right = unit;
      FOR_R(i, n) {
        dp_2[ch[i]] = f_ev(f_ee(prod_left[i], prod_right), p);
        prod_right = f_ee(prod_right, ch_data[i]);
      }
      dp[p] = f_ev(f_ee(x, prod_right), p);
    }
  }
};
#line 1 "/home/maspy/compro/library/ds/meldable_heap.hpp"

template <typename VAL, bool PERSISTENT, bool TOP_IS_MIN>
struct Meldable_Heap {
  struct Node {
    Node *l, *r;
    VAL x;
    u32 size, dist; // dist: leaf までの距離
  };
  Node *pool;
  const int NODES;
  int pid;
  using np = Node *;

  Meldable_Heap(int NODES) : NODES(NODES), pid(0) { pool = new Node[NODES]; }
  ~Meldable_Heap() { delete[] pool; }
  np new_root() { return nullptr; }
  np new_node(const VAL &x) {
    pool[pid].l = pool[pid].r = nullptr;
    pool[pid].x = x, pool[pid].size = 1, pool[pid].dist = 1;
    return &(pool[pid++]);
  }
  np copy_node(np a) {
    if (!a || !PERSISTENT) return a;
    np b = new_node(a->x);
    b->l = a->l, b->r = a->r;
    b->size = a->size, b->dist = a->dist;
    return b;
  }
  np meld(np a, np b) {
    if (!a) return b;
    if (!b) return a;
    a = copy_node(a);
    b = copy_node(b);
    if constexpr (TOP_IS_MIN) {
      if ((a->x) > (b->x)) swap(a, b);
    } else {
      if ((a->x) < (b->x)) swap(a, b);
    }
    a->r = meld(a->r, b);
    if (!(a->l) || (a->l->dist < a->r->dist)) swap(a->l, a->r);
    a->dist = (a->r ? a->r->dist : 0) + 1;
    a->size = 1;
    if (a->l) a->size += a->l->size;
    if (a->r) a->size += a->r->size;
    return a;
  }
  np push(np a, VAL x) { return meld(a, new_node(x)); }
  np pop(np a) { return meld(a->l, a->r); }
  VAL top(np a) { return a->x; }
  vc<VAL> get_all(np a) {
    vc<VAL> A;
    auto dfs = [&](auto &dfs, np a) -> void {
      if (!a) return;
      A.eb(a->x), dfs(dfs, a->l), dfs(dfs, a->r);
    };
    dfs(dfs, a);
    sort(all(A));
    if (!TOP_IS_MIN) reverse(all(A));
    return A;
  }
};

// 全体加算ができるようにする
// path sum が実際の値となるようにすれば追加フィールドなしに実現できる
// https://qoj.ac/contest/1699/problem/8518
template <typename VAL, bool PERSISTENT, bool TOP_IS_MIN>
struct Lazy_Meldable_Heap {
  struct Node {
    Node *l, *r;
    VAL x;
    u32 size;
  };
  Node *pool;
  const int NODES;
  int pid;
  using np = Node *;

  Lazy_Meldable_Heap(int NODES) : NODES(NODES), pid(0) { pool = new Node[NODES]; }
  ~Lazy_Meldable_Heap() { delete[] pool; }
  np new_root() { return nullptr; }
  np new_node(const VAL &x) {
    pool[pid].l = pool[pid].r = nullptr;
    pool[pid].x = x, pool[pid].size = 1;
    return &(pool[pid++]);
  }
  np copy_node(np a) {
    if (!a || !PERSISTENT) return a;
    np b = new_node(a->x);
    b->l = a->l, b->r = a->r;
    b->size = a->size;
    return b;
  }
  np apply(np a, VAL x) {
    if (!a) return a;
    a = copy_node(a);
    a->x += x;
    return a;
  }
  np meld(np a, np b, VAL add_a = 0, VAL add_b = 0) {
    if (!a) { return (add_b == 0 ? b : apply(b, add_b)); }
    if (!b) { return (add_a == 0 ? a : apply(a, add_a)); }
    if constexpr (TOP_IS_MIN) {
      if ((a->x + add_a) > (b->x + add_b)) swap(a, b), swap(add_a, add_b);
    } else {
      if ((a->x + add_a) < (b->x + add_b)) swap(a, b), swap(add_a, add_b);
    }
    a = copy_node(a);
    a->x += add_a;
    a->r = meld(a->r, b, 0, -a->x + add_b);
    if (!(a->l) || (a->l->size < a->r->size)) swap(a->l, a->r);
    a->size = 1;
    if (a->l) a->size += a->l->size;
    if (a->r) a->size += a->r->size;
    return a;
  }

  np push(np a, VAL x) { return meld(a, new_node(x)); }
  np pop(np a) { return meld(a->l, a->r, a->x, a->x); }
  VAL top(np a) { return a->x; }
  vc<VAL> get_all(np a) {
    vc<VAL> A;
    auto dfs = [&](auto &dfs, np a, VAL lazy) -> void {
      if (!a) return;
      A.eb(a->x + lazy);
      lazy += a->x;
      dfs(dfs, a->l, lazy), dfs(dfs, a->r, lazy);
    };
    dfs(dfs, a, 0);
    sort(all(A));
    if (!TOP_IS_MIN) reverse(all(A));
    return A;
  }
};
#line 7 "main.cpp"

void solve() {
  LL(N);
  STR(S);
  Graph<int, 0> G(N);
  G.read_tree();
  Tree<decltype(G)> tree(G);

  vi B(N);
  {
    Lazy_Meldable_Heap<int, true, false> X(140 * N);
    using np = decltype(X)::np;

    using Data = pair<ll, np>;
    Data unit = {0, X.new_root()};
    auto fee = [&](Data x, Data y) -> Data {
      np z = X.meld(x.se, y.se);
      SHOW(X.get_all(x.se));
      SHOW(X.get_all(y.se));
      SHOW(X.get_all(z));
      return {x.fi + y.fi, z};
    };
    auto fev = [&](Data x, int v) -> Data {
      if (S[v] == '0') {
        if (!x.se) return {0, x.se};
        SHOW(__LINE__, X.get_all(x.se));
        x.fi -= X.top(x.se);
        x.se = X.pop(x.se);
        SHOW(__LINE__, X.get_all(x.se));
        x.se = X.push(x.se, 0);
        SHOW(__LINE__, X.get_all(x.se));
        return x;
      }
      x.se = X.push(x.se, 0);
      return x;
    };
    // e は v に入る有向辺
    auto fve = [&](Data x, auto &e) -> Data {
      x.fi += (x.se ? x.se->size : 0);
      SHOW("before apply", X.get_all(x.se));
      x.se = X.apply(x.se, 1);
      SHOW("after apply", X.get_all(x.se));
      return x;
    };
    Rerooting_dp<decltype(tree), Data> dp(tree, fee, fev, fve, unit);
    FOR(v, N) {
      auto [sm, x] = dp.get(v, v);
      SHOW(sm, X.get_all(x));
      B[v] = sm;
    }
  }

  vi A(N);
  {
    using Data = pi;
    Data unit = {0, 0};
    auto fee = [&](Data x, Data y) -> Data { return {x.fi + y.fi, x.se + y.se}; };
    auto fev = [&](Data x, int v) -> Data {
      x.fi += (S[v] == '1');
      return x;
    };
    // e は v に入る有向辺
    auto fve = [&](Data x, auto &e) -> Data { return {x.fi, x.se + x.fi}; };
    Rerooting_dp<decltype(tree), Data> dp(tree, fee, fev, fve, unit);

    FOR(v, N) { A[v] = dp.get(v, v).se; }
  }
  FOR(v, N) A[v] -= B[v];
  print(A);
}

signed main() { solve(); }

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

5
10101
1 2
2 3
2 4
4 5

output:

2 2 2 3 3

result:

ok 5 number(s): "2 2 2 3 3"

Test #2:

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

input:

1
0

output:

0

result:

ok 1 number(s): "0"

Test #3:

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

input:

1
1

output:

0

result:

ok 1 number(s): "0"

Test #4:

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

input:

2
10
1 2

output:

0 1

result:

ok 2 number(s): "0 1"

Test #5:

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

input:

3
100
2 3
2 1

output:

0 1 2

result:

ok 3 number(s): "0 1 2"

Test #6:

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

input:

4
1100
4 1
4 3
4 2

output:

1 1 3 1

result:

ok 4 number(s): "1 1 3 1"

Test #7:

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

input:

5
10100
4 5
1 3
2 1
3 5

output:

0 2 0 4 2

result:

ok 5 number(s): "0 2 0 4 2"

Test #8:

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

input:

8
11001000
4 2
7 2
5 7
6 2
3 1
6 3
7 8

output:

5 3 5 5 4 4 4 6

result:

ok 8 numbers

Test #9:

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

input:

64
1110101001010110011100110000010100011011010001000111010110100101
57 60
58 63
7 43
64 9
19 8
62 17
4 40
41 18
34 56
46 14
41 36
57 26
46 58
16 32
59 1
8 17
17 13
34 29
55 10
43 5
34 8
28 36
6 10
37 21
11 48
2 8
56 55
3 8
56 61
53 52
49 51
20 30
52 39
57 22
9 49
18 16
9 27
50 52
38 40
59 43
2 18
31...

output:

34 29 29 33 34 37 34 29 31 30 49 31 41 33 27 36 34 29 29 27 30 36 30 27 34 36 38 46 29 27 38 36 50 27 33 36 30 33 30 27 36 40 34 34 31 33 38 40 36 30 36 30 37 36 30 27 29 33 34 36 32 34 40 27

result:

ok 64 numbers

Test #10:

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

input:

512
11100000100000011111111011010110001001101100011110001001111001011011000001010000100011011101001001101100010000011100000110101010100001001110000011010000111001000110010011000100000010010000100100000000100001001011100010100100101101010000111100110010001010010011101010001000111001001010111111111101...

output:

229 209 213 228 257 224 211 243 208 238 231 211 246 231 235 206 211 208 220 225 226 206 220 251 215 220 238 234 230 208 215 235 230 220 220 235 233 217 243 250 206 220 221 253 230 206 240 209 208 220 215 251 228 221 228 219 208 208 219 256 221 206 222 208 228 230 208 230 235 241 228 223 231 221 229 ...

result:

ok 512 numbers

Test #11:

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

input:

4096
0011111001111111001000100000001010100111001000010100110000110111011111111001001101101010011010001010111100111110001111000000000111001110100110100011011101110011101111001010011011110101111110000101111111100101101001001000000110100111100010110110011001111111011111100111001101111110110111000010101...

output:

1579 1639 1528 1542 1551 1523 1522 1553 1553 1532 1533 1551 1562 1534 1564 1568 1583 1559 1553 1537 1533 1568 1541 1566 1563 1557 1546 1537 1551 1586 1570 1548 1576 1587 1523 1541 1539 1522 1538 1565 1554 1589 1548 1614 1570 1570 1549 1527 1578 1520 1569 1581 1540 1540 1551 1579 1594 1550 1551 1550 ...

result:

ok 4096 numbers

Test #12:

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

input:

32768
010000100111010011101111111011001000100100101001100000110010100111111101110011000110001011001001100110111010010111000001110101000011101010010101111101001100100011101101010000001011001010100011011011001001111101011000001101101110101010001001011011101001010101010000011111100011110100011000001110...

output:

12964 12950 12999 13070 12980 12974 12927 12949 12952 12953 12999 12962 12972 12972 12951 12989 12948 12971 12930 12954 13012 12972 12946 12985 12946 12926 12996 13037 12915 12915 13011 13017 12939 13055 13044 12986 12986 12984 12968 12958 12960 12973 12981 12976 12992 13011 12991 12930 13001 13018 ...

result:

ok 32768 numbers

Test #13:

score: 0
Accepted
time: 198ms
memory: 258828kb

input:

200000
10010111111100101000010111101000010111110101100011001101010001010011111001000101111110000010001000011111011011100111001110101011010011111001010100110100100100110110100101010111011010010110111000000100100010100010111001011111011010111010111001000101010111010011010000111011001110000100010110001...

output:

76960 76970 77040 76999 77019 77042 77011 76949 77007 76939 76942 77018 77042 77033 76979 77033 77016 77097 77044 77026 76989 77001 77003 76921 77029 76965 77014 76997 76929 77043 77060 76994 76991 76969 76981 76999 77003 76962 76973 76973 77028 76951 77110 77007 76973 77026 76967 77063 76985 76927 ...

result:

ok 200000 numbers

Test #14:

score: 0
Accepted
time: 102ms
memory: 48840kb

input:

200000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

result:

ok 200000 numbers

Test #15:

score: 0
Accepted
time: 101ms
memory: 62684kb

input:

200000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

161492 137521 86353 91682 179554 32952 199999 187698 194579 146953 46676 121254 116117 100440 87715 189200 152989 51997 85956 198765 184369 83564 17495 17817 160444 175764 63191 96898 77717 148773 180625 179211 40055 96933 184676 88548 118706 197000 174795 135984 22745 90516 89377 146233 177451 1998...

result:

ok 200000 numbers

Test #16:

score: 0
Accepted
time: 123ms
memory: 96780kb

input:

200000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

199998 199998 199998 199998 199998 199998 199998 199998 199998 199998 199998 199998 199998 199998 199998 199998 199998 199998 199998 199998 199998 199998 199998 199998 199998 199998 199998 199998 199998 199998 199998 199998 199998 199998 199998 199998 199998 199998 199998 199998 199998 199998 199998...

result:

ok 200000 numbers

Test #17:

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

input:

199997
10001001111101000110010000100011101000000101001010011000001001000000000011011000010100110010000000011000010000101000000001000110011011010000100111101000101110100001000110001100101011000111000001010010010100110000000111000101101100001000100000100001101100100000110110000011000000000010000010000...

output:

3374373051 4189970859 3184123733 3450268583 2277945377 3696454439 3061951659 3949712041 4220671753 3323963325 2190820273 2815791721 3038430245 2442474205 2679717347 2445099211 4234389437 2761141455 2243098995 3312035333 2354016045 3302499627 3219965331 2883371715 3480709045 2516738855 3524451139 272...

result:

ok 199997 numbers

Test #18:

score: 0
Accepted
time: 365ms
memory: 391080kb

input:

200000
11110001010101111010101000111010011101011110111101111111111111000111110110110001100111011111110111111000111101011101000110111111101101011101111001011011111101110110011110110010110111100111101101110111101111101101110110110111101100010111111011011111111011111101001000111010111111110001011101111...

output:

3725613546 2828499752 2737429131 2045154129 2029946119 3165261139 2911119762 2515530064 2165720641 2144045544 2040045369 2228309145 2901494750 2024811935 3169167665 3707239399 2070360489 2087404270 2988622806 3134475317 2781740246 2029884243 2121709189 2075106780 2130071393 2029683930 2058685522 211...

result:

ok 200000 numbers

Test #19:

score: 0
Accepted
time: 361ms
memory: 407088kb

input:

200000
10110000001010000100000001101000110111100100011000110110011000000110101001000100100100100011100100000000011010000000000010011000000001001010000110001000011101001100010011001000000101011000001000000011100000111111101101000001111001111101011110100101000000010100100010101001000101101010100100001...

output:

1308385941 1497995208 1266404072 1289062935 858619709 1566912729 1017422986 1091038784 1038086490 1223278595 1006222526 1394298647 854966615 885696155 852709442 987838292 955819388 1507851132 1386310224 1364736704 854420649 1482911174 848349724 1408402251 978706570 970316455 849763624 883633108 1681...

result:

ok 200000 numbers

Test #20:

score: 0
Accepted
time: 308ms
memory: 362892kb

input:

199996
11101111111011011110010011111110101110010001101001111111110110110101010111101111011101010110111100010010010001111111111110111110101011111111010001011010110111010111111111111110100111111101001010111110111111011110101101101111010010111111101101101101011111100110111100111110100100101111111011011...

output:

615343737 1203579448 598359583 989298818 812092194 821754366 1141393729 686841808 616557077 603000404 1142668228 970815777 660125467 640379064 704861495 664954666 606549248 830243786 729188396 1010616317 861920504 675376469 958545234 968450580 625221001 928121241 838868630 599726030 976820859 118197...

result:

ok 199996 numbers

Test #21:

score: 0
Accepted
time: 289ms
memory: 314852kb

input:

199996
10111100000001000101001100100001000000010101000100001010011011110011111010000110011000000111100001110100100100110100011000100000001101111001000110101000000011001101000100010001000001001000000000000011010000110011000001000011100100001010011000100000110100000000011011000110001000100011110011011...

output:

132684038 85297098 96153257 84911449 89602811 116755678 119526132 114225882 96352259 127315227 93853753 86267926 84358040 130446546 151042003 91223806 129944661 92092641 144651576 97913533 89929641 100891962 131855104 86215388 97026302 155386765 83682781 86907874 91877668 143176539 137571245 1624191...

result:

ok 199996 numbers

Test #22:

score: 0
Accepted
time: 242ms
memory: 289768kb

input:

200000
10111001011100111111011111011111010111011011111111001101100011110111011110110110001011110110111111011110111111100111011010101011010100110110111000110100111111011111111101101111100111111100001011010101010011110111111010111111100010111100101101101111111110111011111100010111101101011110110111101...

output:

52241949 45612057 66758763 46380544 44818472 46921700 44638963 52621704 64880290 68645356 42929365 43239914 44794025 63440953 56513938 42971337 43490789 47706884 71222729 43527037 45018123 65336871 68797798 61131057 55098211 56130482 84190188 46085989 43795154 44371015 47983026 46447839 67602886 736...

result:

ok 200000 numbers

Test #23:

score: 0
Accepted
time: 247ms
memory: 265816kb

input:

199996
01000011110111000010010010110111000000010001100000110000010001001000111000000101010100100100110001100010100011111100000010100001000100010011011000000001010110010000001111010010100011100010100010100011010000100100010100100000100000000000001110000000011110111111001000110010010011101001110001000...

output:

1590445 1505764 1934106 1502259 1578933 1823018 1843632 2075482 1617726 1639629 1570766 1494660 2025807 1778933 2174614 1550729 1493833 1892533 1549027 1616458 1543018 1678579 1675190 1530761 1975361 1638171 1525275 1623049 1743072 1571282 1795641 2173817 1667816 2044865 1660072 1696001 1584213 1697...

result:

ok 199996 numbers

Test #24:

score: 0
Accepted
time: 228ms
memory: 262304kb

input:

199999
11110111101111011111111010011110111100101101011111111011011110100011111001010101110110111100100100001111000000110100010111100010100110011001111011110011100100111111011111111010011110000011100011010011011111100111010000110111110111111011110111001011111011101001011111011011000000110110001011101...

output:

1335936 1149455 1257202 1246972 1337971 1065686 1055691 1032393 1162844 1297813 1148423 1031473 1039382 1366080 1082199 1014749 1260822 1041626 1229873 1019083 1152778 1048402 1282455 1304657 1124282 1021655 1018792 1200226 1485285 1327574 1040357 1131751 1144021 1027292 1210300 1022144 1165012 1188...

result:

ok 199999 numbers

Test #25:

score: 0
Accepted
time: 230ms
memory: 250024kb

input:

199995
00000110100111110000000011000001001001011111000011111011110101011011000010000000100000010101011000001010001010000011010111001000001001001000000100100100000100011100010110000001000101100001001000010000010010100000100100101010100010001000101000100010001101100101000110001000000000100011100000110...

output:

437571 434834 435183 436905 435323 434308 435305 434615 434876 435191 435242 434328 434035 434293 434268 437461 434921 434916 436581 434092 436788 435056 434432 436655 434461 437129 434268 436386 434099 436808 437038 436161 435446 438614 436574 437395 435020 438421 435350 438378 435912 435705 435919...

result:

ok 199995 numbers

Test #26:

score: 0
Accepted
time: 210ms
memory: 247792kb

input:

199999
11011000011111010011101110011111101011011101000011010011001010001101111110011001110111110111111011100110011110001100110011101111111101111110011110010010110010111110111111110111111110011011011100011011101011111101111111011011100000111110110110111111101101011111100000111111111111100011111110000...

output:

291439 291742 291442 292022 291998 292608 295175 293609 292799 293559 291204 292299 292807 291753 291592 291681 291789 291113 292605 291236 293687 292590 292121 291962 292701 291346 291450 291272 292838 292499 291828 292336 293447 291229 291197 293260 291994 292390 293090 292506 291904 293782 291937...

result:

ok 199999 numbers

Test #27:

score: 0
Accepted
time: 374ms
memory: 423056kb

input:

200000
00000011000000000100000000001000000001100000100100001000010001000000010000000011000000000000000010000000100000000100100000000000000000000000100000000000110001000011000000000010010000010000010000000000001100001000000010001000010101001011000000010000000010000110000000100100000011000100000000011...

output:

681455358 468197043 1070325733 948325724 469434574 681973264 622901817 465605711 527822442 536927474 465350493 965440987 1005777116 698587050 482170094 504375550 465714755 979934888 649132898 465535341 712528930 1068718453 466037967 551607704 997167874 491875920 559610578 466568379 537773929 4938158...

result:

ok 200000 numbers

Test #28:

score: 0
Accepted
time: 354ms
memory: 382360kb

input:

199998
11110000010110111000110111010001111011001101110000000010111101001001010101010101101010111010111001100000011111010111011001111111111111111110111111111111111101110110100100011100100100010001001011111001100111001110011110000110111101110010001100111011101100110011010011011010001011111011100101010...

output:

681719313 680943177 794903414 792840382 680920833 832084801 899229379 723681761 713907202 704143835 687194174 694486074 1102992021 1083116949 1131396698 885039246 708236132 1099042193 920218538 906795724 682479540 1023939873 812277257 994058145 681015878 745399876 680860371 800987705 1110259446 9583...

result:

ok 199998 numbers

Test #29:

score: 0
Accepted
time: 205ms
memory: 250540kb

input:

200000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

2060440 3004958 2251474 1637770 3515602 1490120 1261691 1517553 2898401 2596730 2080370 2491818 3198944 1149625 2931206 3685996 2670340 3221923 1932086 3668434 3630758 2161071 3451542 1430975 2767398 3198704 1144369 1387995 1137842 2955268 3281142 1909946 1285220 2466416 2154556 2102368 1932708 3159...

result:

ok 200000 numbers

Test #30:

score: 0
Accepted
time: 279ms
memory: 323420kb

input:

200000
01011010111111110111111111101111111111111111101101111111010111111111111110011101111111101111111111111111111111111011111110011111110110111111111111111111101111110111111111111110111111010111000011111101111111111111111101111111111111111110111111011111111111111111111111111111111111101111111110110...

output:

52769133 48827146 53366676 50519006 52424681 51787529 51920218 49059738 48794052 49070894 49259262 54031420 48684749 48785250 50070530 49574576 49414777 53514393 52738876 49147473 52569747 52936197 48796751 48572123 49173174 51788740 50517257 48582318 48568687 54529196 54795681 50932575 54817910 487...

result:

ok 200000 numbers

Test #31:

score: 0
Accepted
time: 319ms
memory: 355076kb

input:

199999
00001100010011010111110001000110110010000111110001110101001010000110011111001001100101110000011011000010101010001110011111110001101010100110000000010011000011110110010110001110011000001110010011101011010001110000000110100011100011000110100010001111000101000111001011000000011010110101001100011...

output:

47502957 47814769 48163322 46144105 45818641 45833999 46166717 48045900 46306696 45831258 47572851 45815816 47372109 47146916 47147608 47227904 46290694 46024693 45852748 47185762 48073486 46062217 47205680 46303101 45885562 46807872 46574971 48191288 46212253 46367014 47576148 46224770 48470277 469...

result:

ok 199999 numbers

Test #32:

score: 0
Accepted
time: 287ms
memory: 321336kb

input:

200000
11011001111111101111011011100111110111111101110111101111111111101110111100101111011110111111011111111110111110111011111111111010110101011101010110011110111101110101111110011011101111111111111111100011111111111111101011111111111011111110110001111111111111011111011111011011101110111011111101100...

output:

31515386 30801555 31082283 30801729 30794895 31263078 31433396 30860627 31414887 30797012 31128928 30850998 30966045 32100918 31475454 31223366 31025437 31684173 31584925 30917301 30919195 30793597 32175969 31271148 30795629 31079002 31344142 31458594 30842506 31808736 30949936 30815710 30818457 311...

result:

ok 200000 numbers

Test #33:

score: 0
Accepted
time: 261ms
memory: 311400kb

input:

200000
00000000000000000010000000000000000000000000000000000010000000000000000000000010000000000000000000000000000000000000000000000000000000000100000000000000001000000000000000000001000000000000000001000000000000000000000010000000000000000000000000000000000000000000000000100000010000010000000000000...

output:

1287859 1278710 1282256 1282660 1277644 1278063 1277768 1300070 1287876 1313288 1277552 1279407 1307067 1286140 1301451 1277789 1288478 1277993 1309631 1277717 1300626 1291718 1286010 1282351 1278741 1277474 1277964 1283193 1277702 1290000 1283696 1277520 1298581 1281070 1281157 1289063 1277565 1277...

result:

ok 200000 numbers

Test #34:

score: 0
Accepted
time: 269ms
memory: 323664kb

input:

200000
00001000110111001001011110111010001011000101011110101101111111010111011100011111000000110010110000010111110111111001110001010111100111000010000101110011110110000010001111100000100000101100101000001010110100111101000100011111001110011011011100010100011110101100110100010100111010011010110011110...

output:

4518403 4516821 4522737 4532732 4517570 4516679 4519567 4518266 4518951 4516705 4517645 4521426 4520926 4516496 4528280 4516534 4526112 4536472 4538716 4516947 4534679 4527791 4521201 4519319 4522799 4519063 4517109 4533127 4520978 4526661 4521806 4517414 4521381 4520317 4518667 4537712 4517043 4516...

result:

ok 200000 numbers

Test #35:

score: 0
Accepted
time: 238ms
memory: 326360kb

input:

200000
00001110101100111000000001111001010000010000110100100001001001101110001001000000001111000010111000000010100100010101101010101110110101111100000110001001101110011100100001011000001100111100111110110110010100001110001001111110101101001110101010010011011111001110010000001001000101010111011100111...

output:

240868 240876 240858 241049 240902 240842 240842 240881 240933 240944 241093 240854 240873 240907 240998 240880 240894 240914 240872 240971 240880 240990 240919 240941 240978 240857 240896 240860 240931 240906 240885 240942 240850 240942 240917 240987 240949 240877 240921 240853 240908 241002 240883...

result:

ok 200000 numbers

Test #36:

score: 0
Accepted
time: 250ms
memory: 266040kb

input:

199999
11111101111111111111111111111111111111111011111111111111111111111111111111111111111111111111111111111111111111111111111111110111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

output:

18803 18803 18803 18803 18803 18803 18846 18803 18803 18826 18803 18803 18803 18803 18803 18803 18803 18803 18803 18803 18803 18803 18803 18803 18803 18803 18836 18803 18839 18803 18803 18803 18803 18803 18803 18803 18803 18803 18831 18803 18803 18851 18803 18803 18803 18803 18803 18803 18803 18827 ...

result:

ok 199999 numbers

Test #37:

score: 0
Accepted
time: 32ms
memory: 43940kb

input:

200000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

result:

ok 200000 numbers

Test #38:

score: 0
Accepted
time: 63ms
memory: 51072kb

input:

200000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 ...

result:

ok 200000 numbers

Test #39:

score: 0
Accepted
time: 384ms
memory: 533376kb

input:

200000
11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

output:

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

result:

ok 200000 numbers

Test #40:

score: 0
Accepted
time: 288ms
memory: 471168kb

input:

200000
01101101011101001110101111100111101100100000000000001011101010111001001000000101101111001100111010100100111000001010100010011011101001010001011100001011110100000011000010010100011101101000001000011110111101110000101110010100110110000000000011000000000100110111000101010100101011100100001110100...

output:

3 1 1 3 1 1 3 1 3 1 1 1 3 1 3 3 1 1 1 3 1 3 1 1 1 1 1 3 3 1 1 1 1 3 1 1 3 3 1 3 3 3 3 3 3 3 3 3 3 3 3 3 1 3 1 1 1 3 1 3 1 3 1 1 1 3 3 1 3 3 1 3 3 3 3 3 3 1 3 1 1 3 1 1 1 1 3 3 1 1 3 3 1 1 1 3 1 3 1 3 3 1 3 3 1 1 1 3 3 3 3 3 1 3 1 3 1 3 3 3 1 3 3 1 1 3 1 1 1 3 1 3 3 1 3 1 3 3 3 1 3 1 1 1 3 3 3 3 1 3 ...

result:

ok 200000 numbers

Test #41:

score: 0
Accepted
time: 375ms
memory: 409552kb

input:

200000
10011000011001010001101000011100000101001101010110001111111001011110001011101000101000000110110000010110110001100101110100101100000101001011100110110111001111110010111110001100111011110111111011100111100000011110010001110010100110011000110101000010000110010110000100000101010111101011101100110...

output:

1641305406 2268611581 1224289755 1526756396 1797114739 1213760195 1906781059 1805506554 1686932768 1291176943 2024050022 2431148844 1357165318 1954650057 1879386096 1226540705 1976802657 2156028318 1845586674 1301681014 1316321771 2461112751 1788118540 1832791607 1846761913 1210964029 1361699375 219...

result:

ok 200000 numbers

Test #42:

score: 0
Accepted
time: 305ms
memory: 329796kb

input:

199997
10001001111100111011110001010111111110011111011110111100111010001000100010100111000110001111010011010101101111101100010100001100100100111011011000110001110111011010000101001011110011001010011100111101101000111111100000111011011110111011001010011110011010001001001111110001111100011111111011001...

output:

180264672 137429617 195527871 153074740 235352063 177053100 125472621 184394825 128321724 128918742 174811632 125870817 144894712 173383075 187160361 199139982 140057029 137436902 175519586 177577277 126517305 151725397 157910303 134791282 179289222 137953907 129024879 126778109 165196461 191433008 ...

result:

ok 199997 numbers

Test #43:

score: 0
Accepted
time: 228ms
memory: 270312kb

input:

200000
11101110111010000000011010110001100101101011100100000010010111101001011001001100100100010101001001011000101111111101001001100100011110000011000101010101110000010000010110111000111111110010110100111011101101100001000010110000011110101000100110100011101110101101110100101100100100001011011000010...

output:

4142223 4668287 4196808 4563175 3540569 4288502 4311799 3184511 3167896 3417637 4660834 3184563 4387352 3221506 4150800 4296015 3844133 3884510 3499640 4512781 5181416 3205517 4458993 4164491 3255078 3807371 3854352 4707220 4392960 4849794 3159900 4049316 4408933 3516532 4886905 3919076 3898209 4650...

result:

ok 200000 numbers

Test #44:

score: 0
Accepted
time: 321ms
memory: 383676kb

input:

200000
10111000101101100111100110010010000100101110010000000100000111111011111110001010110110000111111001000011000000000000101001101010101010001100101110100111000011001000011001010011000011111010110000011110111010111010011100101000001111100111111010011111000100001000001010101011011011010000001111010...

output:

485799975 718428751 474756882 710741507 479020542 491824787 604570827 529943255 500679508 592013358 732558904 476402543 536913819 679152659 570064219 476130975 534138031 506477657 513492119 483046808 498847603 752218744 498364241 646292547 491935411 541916711 804517539 793749577 653721240 489059693 ...

result:

ok 200000 numbers

Test #45:

score: 0
Accepted
time: 288ms
memory: 315752kb

input:

200000
01011111000111110110111100110000100000110000111110101101011010010101100011010010001110011011011000010101000000001100010001111100010111101000111110111010100000111011010110110101000111110110100000110010000000100000001111011001001111001010101001011011000100101001100011011101000110101101111000101...

output:

86403528 79148090 57100017 70915688 74703189 70085696 103962042 70479936 57736923 82752293 84704548 70803969 62356069 66075064 74727854 89401789 88023270 57984358 85225903 68282481 79590183 61412787 76421742 69294738 64788363 64746666 82541824 71411502 72187605 75324104 59585977 71453749 59585977 82...

result:

ok 200000 numbers

Test #46:

score: 0
Accepted
time: 220ms
memory: 269328kb

input:

199997
11001111000100111011010010101111010011111100111000100001010000110101000000000001010100101010000110010110111000000000100111100111011010100101111110011100111011010100111001101110100111010110010010000110101011000101011010110101110011101100011110100100000111001001001011010101100100010101011001011...

output:

1951862 2060339 2130581 2260839 1879062 1691253 2044833 2048134 1662230 2065437 2099023 2058403 2046234 1820284 2047900 2000260 1954515 1668642 2152934 2172217 2144778 1938346 2130323 1952407 2022639 2046499 2103470 2077435 1652573 2318842 1711062 2055501 1862427 2309727 1719703 1781155 1988705 1729...

result:

ok 199997 numbers

Test #47:

score: 0
Accepted
time: 342ms
memory: 359296kb

input:

200000
10011010101001101001110110110101001010101001101111100001110011101010101111101101101011110110011110100111111111011111001111011100111111001110100000101001110111011011101111011000101111100111010000100001101110111010111100010110110100010101000011000110000001100101100101101101101001001010001101000...

output:

287714553 356098078 340325369 263383250 267717772 269291658 291200403 240173932 263719565 342244607 247830092 290753804 266019975 248415867 251380931 273413726 280424411 288645573 287498873 242558579 277313200 274419642 302884782 240323519 265158800 234655732 221491581 231990183 357387430 283905263 ...

result:

ok 200000 numbers

Test #48:

score: 0
Accepted
time: 277ms
memory: 302896kb

input:

200000
00111101010111110101001111010111111010101111011101110011000011110110111010000101011111100111110101101001100011111001101101010101101100011110001100011001010000010001010110001010111110100101110100001000001001000110100100110000110011010000100101111000110000001110000101111100000101011000100010111...

output:

21246183 21847626 20447783 24114862 22462172 19138429 22115587 20060869 23103219 21611727 21892292 22614646 22824168 19573518 21677347 24498485 20854417 21979847 18775596 19717391 23546043 18795928 21157050 19210812 21323119 20646256 21986596 21029617 20674464 21409450 19696809 21616006 23993343 272...

result:

ok 200000 numbers

Test #49:

score: 0
Accepted
time: 221ms
memory: 261972kb

input:

199999
11011110001011000111010011011011101000001111111010100111000101011010011001011011110001111101010110101000110001001010010011101110100110010100011011101010101110001111001011101010101011100111110100010000000010110000110000001101101111101101011001011100100011110011010010010010100011100111110101011...

output:

870095 932693 881848 855528 912276 863512 847934 853026 881669 1031469 873397 1075454 848101 914949 893495 879265 880296 858763 868580 832422 915972 842575 890236 855175 849606 875182 857253 921944 853146 857275 845800 867683 903819 926271 865632 875148 998536 843586 906913 826422 869969 1032844 882...

result:

ok 199999 numbers

Test #50:

score: 0
Accepted
time: 399ms
memory: 435900kb

input:

200000
00101001111100010010001100111101111101010101100000110101000110001001111101001010011000100010011111111100000011010110101101000100111110000101111101111110111001110001000010011000110001110111101001000001100110010101100100110000011000101010101010110110000111110100110001100011101101101001001001000...

output:

3579466212 2846716232 3565307166 4540661536 3679948300 4745701220 4254719412 3153674624 4864606674 2500617812 5001574330 2928871852 4403815062 2500202240 2602057876 4513896678 4354398732 3620105470 3038401698 2576594020 2707730554 3101562736 4818229362 2500334488 4807579794 2504872026 2777931746 251...

result:

ok 200000 numbers

Extra Test:

score: 0
Extra Test Passed