QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#870459#8621. Knapsackucup-team087#AC ✓2251ms401468kbC++2319.3kb2025-01-25 16:27:172025-01-25 16:27:19

Judging History

This is the latest submission verdict.

  • [2025-01-25 16:27:19]
  • Judged
  • Verdict: AC
  • Time: 2251ms
  • Memory: 401468kb
  • [2025-01-25 16:27:17]
  • Submitted

answer

#line 1 "library/my_template.hpp"
#if defined(LOCAL)
#include <my_template_compiled.hpp>
#else

// https://codeforces.com/blog/entry/96344
#pragma GCC optimize("Ofast,unroll-loops")
// いまの CF だとこれ入れると動かない?
// #pragma GCC target("avx2,popcnt")

#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i128 = __int128;
using u128 = unsigned __int128;
using f128 = __float128;

template <class T>
constexpr T infty = 0;
template <>
constexpr int infty<int> = 1'010'000'000;
template <>
constexpr ll infty<ll> = 2'020'000'000'000'000'000;
template <>
constexpr u32 infty<u32> = infty<int>;
template <>
constexpr u64 infty<u64> = infty<ll>;
template <>
constexpr i128 infty<i128> = i128(infty<ll>) * 2'000'000'000'000'000'000;
template <>
constexpr double infty<double> = infty<ll>;
template <>
constexpr long double infty<long double> = infty<ll>;

using pi = pair<ll, ll>;
using vi = vector<ll>;
template <class T>
using vc = vector<T>;
template <class T>
using vvc = vector<vc<T>>;
template <class T>
using vvvc = vector<vvc<T>>;
template <class T>
using vvvvc = vector<vvvc<T>>;
template <class T>
using vvvvvc = vector<vvvvc<T>>;
template <class T>
using pq = priority_queue<T>;
template <class T>
using pqg = priority_queue<T, vector<T>, greater<T>>;

#define vv(type, name, h, ...) vector<vector<type>> name(h, vector<type>(__VA_ARGS__))
#define vvv(type, name, h, w, ...) vector<vector<vector<type>>> name(h, vector<vector<type>>(w, vector<type>(__VA_ARGS__)))
#define vvvv(type, name, a, b, c, ...) \
  vector<vector<vector<vector<type>>>> name(a, vector<vector<vector<type>>>(b, vector<vector<type>>(c, vector<type>(__VA_ARGS__))))

// https://trap.jp/post/1224/
#define FOR1(a) for (ll _ = 0; _ < ll(a); ++_)
#define FOR2(i, a) for (ll i = 0; i < ll(a); ++i)
#define FOR3(i, a, b) for (ll i = a; i < ll(b); ++i)
#define FOR4(i, a, b, c) for (ll i = a; i < ll(b); i += (c))
#define FOR1_R(a) for (ll i = (a)-1; i >= ll(0); --i)
#define FOR2_R(i, a) for (ll i = (a)-1; i >= ll(0); --i)
#define FOR3_R(i, a, b) for (ll i = (b)-1; i >= ll(a); --i)
#define overload4(a, b, c, d, e, ...) e
#define overload3(a, b, c, d, ...) d
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FOR_R(...) overload3(__VA_ARGS__, FOR3_R, FOR2_R, FOR1_R)(__VA_ARGS__)

#define 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(unsigned(x)) & 1 ? -1 : 1); }
int popcnt_sgn(u32 x) { return (__builtin_parity(x) & 1 ? -1 : 1); }
int popcnt_sgn(ll x) { return (__builtin_parityll(x) & 1 ? -1 : 1); }
int popcnt_sgn(u64 x) { return (__builtin_parityll(x) & 1 ? -1 : 1); }
// (0, 1, 2, 3, 4) -> (-1, 0, 1, 1, 2)
int topbit(int x) { return (x == 0 ? -1 : 31 - __builtin_clz(x)); }
int topbit(u32 x) { return (x == 0 ? -1 : 31 - __builtin_clz(x)); }
int topbit(ll x) { return (x == 0 ? -1 : 63 - __builtin_clzll(x)); }
int topbit(u64 x) { return (x == 0 ? -1 : 63 - __builtin_clzll(x)); }
// (0, 1, 2, 3, 4) -> (-1, 0, 1, 0, 2)
int lowbit(int x) { return (x == 0 ? -1 : __builtin_ctz(x)); }
int lowbit(u32 x) { return (x == 0 ? -1 : __builtin_ctz(x)); }
int lowbit(ll x) { return (x == 0 ? -1 : __builtin_ctzll(x)); }
int lowbit(u64 x) { return (x == 0 ? -1 : __builtin_ctzll(x)); }

template <typename T>
T kth_bit(int k) {
  return T(1) << k;
}
template <typename T>
bool has_kth_bit(T x, int k) {
  return x >> k & 1;
}

template <typename UINT>
struct all_bit {
  struct iter {
    UINT s;
    iter(UINT s) : s(s) {}
    int operator*() const { return lowbit(s); }
    iter &operator++() {
      s &= s - 1;
      return *this;
    }
    bool operator!=(const iter) const { return s != 0; }
  };
  UINT s;
  all_bit(UINT s) : s(s) {}
  iter begin() const { return iter(s); }
  iter end() const { return iter(0); }
};

template <typename UINT>
struct all_subset {
  static_assert(is_unsigned<UINT>::value);
  struct iter {
    UINT s, t;
    bool ed;
    iter(UINT s) : s(s), t(s), ed(0) {}
    int operator*() const { return s ^ t; }
    iter &operator++() {
      (t == 0 ? ed = 1 : t = (t - 1) & s);
      return *this;
    }
    bool operator!=(const iter) const { return !ed; }
  };
  UINT s;
  all_subset(UINT s) : s(s) {}
  iter begin() const { return iter(s); }
  iter end() const { return iter(0); }
};

template <typename T>
T floor(T a, T b) {
  return a / b - (a % b && (a ^ b) < 0);
}
template <typename T>
T ceil(T x, T y) {
  return floor(x + y - 1, y);
}
template <typename T>
T bmod(T x, T y) {
  return x - y * floor(x, y);
}
template <typename T>
pair<T, T> divmod(T x, T y) {
  T q = floor(x, y);
  return {q, x - q * y};
}

template <typename T, typename U>
T SUM(const vector<U> &A) {
  T sm = 0;
  for (auto &&a: A) sm += a;
  return sm;
}

#define MIN(v) *min_element(all(v))
#define MAX(v) *max_element(all(v))
#define LB(c, x) distance((c).begin(), lower_bound(all(c), (x)))
#define UB(c, x) distance((c).begin(), upper_bound(all(c), (x)))
#define UNIQUE(x) sort(all(x)), x.erase(unique(all(x)), x.end()), x.shrink_to_fit()

template <typename T>
T POP(deque<T> &que) {
  T a = que.front();
  que.pop_front();
  return a;
}
template <typename T>
T POP(pq<T> &que) {
  T a = que.top();
  que.pop();
  return a;
}
template <typename T>
T POP(pqg<T> &que) {
  T a = que.top();
  que.pop();
  return a;
}
template <typename T>
T POP(vc<T> &que) {
  T a = que.back();
  que.pop_back();
  return a;
}

template <typename F>
ll binary_search(F check, ll ok, ll ng, bool check_ok = true) {
  if (check_ok) assert(check(ok));
  while (abs(ok - ng) > 1) {
    auto x = (ng + ok) / 2;
    (check(x) ? ok : ng) = x;
  }
  return ok;
}
template <typename F>
double binary_search_real(F check, double ok, double ng, int iter = 100) {
  FOR(iter) {
    double x = (ok + ng) / 2;
    (check(x) ? ok : ng) = x;
  }
  return (ok + ng) / 2;
}

template <class T, class S>
inline bool chmax(T &a, const S &b) {
  return (a < b ? a = b, 1 : 0);
}
template <class T, class S>
inline bool chmin(T &a, const S &b) {
  return (a > b ? a = b, 1 : 0);
}

// ? は -1
vc<int> s_to_vi(const string &S, char first_char) {
  vc<int> A(S.size());
  FOR(i, S.size()) { A[i] = (S[i] != '?' ? S[i] - first_char : -1); }
  return A;
}

template <typename T, typename U>
vector<T> cumsum(vector<U> &A, int off = 1) {
  int N = A.size();
  vector<T> B(N + 1);
  FOR(i, N) { B[i + 1] = B[i] + A[i]; }
  if (off == 0) B.erase(B.begin());
  return B;
}

// stable sort
template <typename T>
vector<int> argsort(const vector<T> &A) {
  vector<int> ids(len(A));
  iota(all(ids), 0);
  sort(all(ids), [&](int i, int j) { return (A[i] == A[j] ? i < j : A[i] < A[j]); });
  return ids;
}

// A[I[0]], A[I[1]], ...
template <typename T>
vc<T> rearrange(const vc<T> &A, const vc<int> &I) {
  vc<T> B(len(I));
  FOR(i, len(I)) B[i] = A[I[i]];
  return B;
}

template <typename T, typename... Vectors>
void concat(vc<T> &first, const Vectors &... others) {
  vc<T> &res = first;
  (res.insert(res.end(), others.begin(), others.end()), ...);
}
#endif
#line 1 "library/other/io.hpp"
#define FASTIO
#include <unistd.h>

// https://judge.yosupo.jp/submission/21623
namespace fastio {
static constexpr uint32_t SZ = 1 << 17;
char ibuf[SZ];
char obuf[SZ];
char out[100];
// pointer of ibuf, obuf
uint32_t pil = 0, pir = 0, por = 0;

struct Pre {
  char num[10000][4];
  constexpr Pre() : num() {
    for (int i = 0; i < 10000; i++) {
      int n = i;
      for (int j = 3; j >= 0; j--) {
        num[i][j] = n % 10 | '0';
        n /= 10;
      }
    }
  }
} constexpr pre;

inline void load() {
  memcpy(ibuf, ibuf + pil, pir - pil);
  pir = pir - pil + fread(ibuf + pir - pil, 1, SZ - pir + pil, stdin);
  pil = 0;
  if (pir < SZ) ibuf[pir++] = '\n';
}

inline void flush() {
  fwrite(obuf, 1, por, stdout);
  por = 0;
}

void rd(char &c) {
  do {
    if (pil + 1 > pir) load();
    c = ibuf[pil++];
  } while (isspace(c));
}

void rd(string &x) {
  x.clear();
  char c;
  do {
    if (pil + 1 > pir) load();
    c = ibuf[pil++];
  } while (isspace(c));
  do {
    x += c;
    if (pil == pir) load();
    c = ibuf[pil++];
  } while (!isspace(c));
}

template <typename T>
void rd_real(T &x) {
  string s;
  rd(s);
  x = stod(s);
}

template <typename T>
void rd_integer(T &x) {
  if (pil + 100 > pir) load();
  char c;
  do
    c = ibuf[pil++];
  while (c < '-');
  bool minus = 0;
  if constexpr (is_signed<T>::value || is_same_v<T, i128>) {
    if (c == '-') { minus = 1, c = ibuf[pil++]; }
  }
  x = 0;
  while ('0' <= c) { x = x * 10 + (c & 15), c = ibuf[pil++]; }
  if constexpr (is_signed<T>::value || is_same_v<T, i128>) {
    if (minus) x = -x;
  }
}

void rd(int &x) { rd_integer(x); }
void rd(ll &x) { rd_integer(x); }
void rd(i128 &x) { rd_integer(x); }
void rd(u32 &x) { rd_integer(x); }
void rd(u64 &x) { rd_integer(x); }
void rd(u128 &x) { rd_integer(x); }
void rd(double &x) { rd_real(x); }
void rd(long double &x) { rd_real(x); }
void rd(f128 &x) { rd_real(x); }

template <class T, class U>
void rd(pair<T, U> &p) {
  return rd(p.first), rd(p.second);
}
template <size_t N = 0, typename T>
void rd_tuple(T &t) {
  if constexpr (N < std::tuple_size<T>::value) {
    auto &x = std::get<N>(t);
    rd(x);
    rd_tuple<N + 1>(t);
  }
}
template <class... T>
void rd(tuple<T...> &tpl) {
  rd_tuple(tpl);
}

template <size_t N = 0, typename T>
void rd(array<T, N> &x) {
  for (auto &d: x) rd(d);
}
template <class T>
void rd(vc<T> &x) {
  for (auto &d: x) rd(d);
}

void read() {}
template <class H, class... T>
void read(H &h, T &... t) {
  rd(h), read(t...);
}

void wt(const char c) {
  if (por == SZ) flush();
  obuf[por++] = c;
}
void wt(const string s) {
  for (char c: s) wt(c);
}
void wt(const char *s) {
  size_t len = strlen(s);
  for (size_t i = 0; i < len; i++) wt(s[i]);
}

template <typename T>
void wt_integer(T x) {
  if (por > SZ - 100) flush();
  if (x < 0) { obuf[por++] = '-', x = -x; }
  int outi;
  for (outi = 96; x >= 10000; outi -= 4) {
    memcpy(out + outi, pre.num[x % 10000], 4);
    x /= 10000;
  }
  if (x >= 1000) {
    memcpy(obuf + por, pre.num[x], 4);
    por += 4;
  } else if (x >= 100) {
    memcpy(obuf + por, pre.num[x] + 1, 3);
    por += 3;
  } else if (x >= 10) {
    int q = (x * 103) >> 10;
    obuf[por] = q | '0';
    obuf[por + 1] = (x - q * 10) | '0';
    por += 2;
  } else
    obuf[por++] = x | '0';
  memcpy(obuf + por, out + outi + 4, 96 - outi);
  por += 96 - outi;
}

template <typename T>
void wt_real(T x) {
  ostringstream oss;
  oss << fixed << setprecision(15) << double(x);
  string s = oss.str();
  wt(s);
}

void wt(int x) { wt_integer(x); }
void wt(ll x) { wt_integer(x); }
void wt(i128 x) { wt_integer(x); }
void wt(u32 x) { wt_integer(x); }
void wt(u64 x) { wt_integer(x); }
void wt(u128 x) { wt_integer(x); }
void wt(double x) { wt_real(x); }
void wt(long double x) { wt_real(x); }
void wt(f128 x) { wt_real(x); }

template <class T, class U>
void wt(const pair<T, U> val) {
  wt(val.first);
  wt(' ');
  wt(val.second);
}
template <size_t N = 0, typename T>
void wt_tuple(const T t) {
  if constexpr (N < std::tuple_size<T>::value) {
    if constexpr (N > 0) { wt(' '); }
    const auto x = std::get<N>(t);
    wt(x);
    wt_tuple<N + 1>(t);
  }
}
template <class... T>
void wt(tuple<T...> tpl) {
  wt_tuple(tpl);
}
template <class T, size_t S>
void wt(const array<T, S> val) {
  auto n = val.size();
  for (size_t i = 0; i < n; i++) {
    if (i) wt(' ');
    wt(val[i]);
  }
}
template <class T>
void wt(const vector<T> val) {
  auto n = val.size();
  for (size_t i = 0; i < n; i++) {
    if (i) wt(' ');
    wt(val[i]);
  }
}

void print() { wt('\n'); }
template <class Head, class... Tail>
void print(Head &&head, Tail &&... tail) {
  wt(head);
  if (sizeof...(Tail)) wt(' ');
  print(forward<Tail>(tail)...);
}

// gcc expansion. called automaticall after main.
void __attribute__((destructor)) _d() { flush(); }
} // namespace fastio
using fastio::read;
using fastio::print;
using fastio::flush;

#if defined(LOCAL)
#define SHOW(...) SHOW_IMPL(__VA_ARGS__, SHOW6, SHOW5, SHOW4, SHOW3, SHOW2, SHOW1)(__VA_ARGS__)
#define SHOW_IMPL(_1, _2, _3, _4, _5, _6, NAME, ...) NAME
#define SHOW1(x) print(#x, "=", (x)), flush()
#define SHOW2(x, y) print(#x, "=", (x), #y, "=", (y)), flush()
#define SHOW3(x, y, z) print(#x, "=", (x), #y, "=", (y), #z, "=", (z)), flush()
#define SHOW4(x, y, z, w) print(#x, "=", (x), #y, "=", (y), #z, "=", (z), #w, "=", (w)), flush()
#define SHOW5(x, y, z, w, v) print(#x, "=", (x), #y, "=", (y), #z, "=", (z), #w, "=", (w), #v, "=", (v)), flush()
#define SHOW6(x, y, z, w, v, u) print(#x, "=", (x), #y, "=", (y), #z, "=", (z), #w, "=", (w), #v, "=", (v), #u, "=", (u)), flush()
#else
#define SHOW(...)
#endif

#define INT(...)   \
  int __VA_ARGS__; \
  read(__VA_ARGS__)
#define LL(...)   \
  ll __VA_ARGS__; \
  read(__VA_ARGS__)
#define U32(...)   \
  u32 __VA_ARGS__; \
  read(__VA_ARGS__)
#define U64(...)   \
  u64 __VA_ARGS__; \
  read(__VA_ARGS__)
#define STR(...)      \
  string __VA_ARGS__; \
  read(__VA_ARGS__)
#define CHAR(...)   \
  char __VA_ARGS__; \
  read(__VA_ARGS__)
#define DBL(...)      \
  double __VA_ARGS__; \
  read(__VA_ARGS__)

#define VEC(type, name, size) \
  vector<type> name(size);    \
  read(name)
#define VV(type, name, h, w)                     \
  vector<vector<type>> name(h, vector<type>(w)); \
  read(name)

void YES(bool t = 1) { print(t ? "YES" : "NO"); }
void NO(bool t = 1) { YES(!t); }
void Yes(bool t = 1) { print(t ? "Yes" : "No"); }
void No(bool t = 1) { Yes(!t); }
void yes(bool t = 1) { print(t ? "yes" : "no"); }
void no(bool t = 1) { yes(!t); }
void YA(bool t = 1) { print(t ? "YA" : "TIDAK"); }
void TIDAK(bool t = 1) { YES(!t); }
#line 3 "main.cpp"

#line 2 "library/random/base.hpp"

u64 RNG_64() {
  static u64 x_ = u64(chrono::duration_cast<chrono::nanoseconds>(chrono::high_resolution_clock::now().time_since_epoch()).count()) * 10150724397891781847ULL;
  x_ ^= x_ << 7;
  return x_ ^= x_ >> 9;
}

u64 RNG(u64 lim) { return RNG_64() % lim; }

ll RNG(ll l, ll r) { return l + RNG_64() % (r - l); }
#line 2 "library/ds/hashmap.hpp"

// u64 -> Val
template <typename Val>
struct HashMap {
  // n は入れたいものの個数で ok
  HashMap(u32 n = 0) { build(n); }
  void build(u32 n) {
    u32 k = 8;
    while (k < n * 2) k *= 2;
    cap = k / 2, mask = k - 1;
    key.resize(k), val.resize(k), used.assign(k, 0);
  }

  // size を保ったまま. size=0 にするときは build すること.
  void clear() {
    used.assign(len(used), 0);
    cap = (mask + 1) / 2;
  }
  int size() { return len(used) / 2 - cap; }

  int index(const u64& k) {
    int i = 0;
    for (i = hash(k); used[i] && key[i] != k; i = (i + 1) & mask) {}
    return i;
  }

  Val& operator[](const u64& k) {
    if (cap == 0) extend();
    int i = index(k);
    if (!used[i]) { used[i] = 1, key[i] = k, val[i] = Val{}, --cap; }
    return val[i];
  }

  Val get(const u64& k, Val default_value) {
    int i = index(k);
    return (used[i] ? val[i] : default_value);
  }

  bool count(const u64& k) {
    int i = index(k);
    return used[i] && key[i] == k;
  }

  // f(key, val)
  template <typename F>
  void enumerate_all(F f) {
    FOR(i, len(used)) if (used[i]) f(key[i], val[i]);
  }

private:
  u32 cap, mask;
  vc<u64> key;
  vc<Val> val;
  vc<bool> used;

  u64 hash(u64 x) {
    static const u64 FIXED_RANDOM = std::chrono::steady_clock::now().time_since_epoch().count();
    x += FIXED_RANDOM;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return (x ^ (x >> 31)) & mask;
  }

  void extend() {
    vc<pair<u64, Val>> dat;
    dat.reserve(len(used) / 2 - cap);
    FOR(i, len(used)) {
      if (used[i]) dat.eb(key[i], val[i]);
    }
    build(2 * len(dat));
    for (auto& [a, b]: dat) (*this)[a] = b;
  }
};
#line 6 "main.cpp"

pair<vc<int>, vc<int>> find(vc<ll> S) {
  auto I = argsort(S);
  vi nxt;
  FOR(i, len(S)) {
    if (2 * i + 1 >= len(S)) break;
    int p = I[2 * i];
    int q = I[2 * i + 1];
    if (S[p] == S[q]) return {{p}, {q}};
    nxt.eb(S[q] - S[p]);
  }
  auto [ADD, SUB] = find(nxt);
  vc<int> L, R;
  for (auto& i: ADD) {
    L.eb(I[2 * i + 0]);
    R.eb(I[2 * i + 1]);
  }
  for (auto& i: SUB) {
    R.eb(I[2 * i + 0]);
    L.eb(I[2 * i + 1]);
  }
  ll check = 0;
  for (auto& i: L) check += S[i];
  for (auto& i: R) check -= S[i];
  return {L, R};
}

struct T {
  ll x;
  vc<int> B, C;
};

void solve(ll N, vi A) {
  vc<int> rest(N);
  FOR(i, N) rest[i] = 1;
  FOR(i, 128) rest[i] = 0;
  vc<T> dat;
  FOR(64) {
    vc<int> rest_idx;
    FOR(i, N) if (rest[i]) rest_idx.eb(i);
    vi B = rearrange(A, rest_idx);
    auto [L, R] = find(B);
    L = rearrange(rest_idx, L);
    R = rearrange(rest_idx, R);
    T t;
    t.B = L;
    t.C = R;
    ll b = 0, c = 0;
    for (auto& i: L) b += A[i];
    for (auto& i: R) c += A[i];
    assert(b == c);
    t.x = b;
    dat.eb(t);
    for (auto& i: L) rest[i] = 0;
    for (auto& i: R) rest[i] = 0;
  }
  FOR(i, 64) rest[i] = 1;

  int LIM = 1 << 24;
  // dat から使うもの -> sum
  HashMap<u32> MP(LIM);
  {
    u32 use = 0;
    u64 sm = 0;
    FOR(iter, LIM) {
      // int i = RNG(0, 64);
      int i = RNG(0, 32);
      if (has_kth_bit<u32>(use, i)) {
        sm -= dat[i].x;
      } else {
        sm += dat[i].x;
      }
      use ^= u64(1) << i;
      if (use != 0) MP[sm] = use;
    }
  }

  {
    vc<bool> use(128);
    u64 sm = 0;
    int iter = 0;
    while (1) {
      int i = RNG(0, 128);
      if (use[i]) {
        sm -= A[i], use[i] = false;
      } else {
        sm += A[i], use[i] = true;
      }
      if (MP.count(sm)) {
        string S(N, '.');
        FOR(i, 128) {
          if (use[i]) S[i] = 'A';
        }
        u64 x = MP[sm];
        FOR(i, 64) {
          if (has_kth_bit<u64>(x, i)) {
            for (auto& j: dat[i].B) S[j] = 'B';
            for (auto& j: dat[i].C) S[j] = 'C';
          }
        }

        // check sm
        ll a = 0, b = 0, c = 0;
        FOR(i, N) if (S[i] == 'A') a += A[i];
        FOR(i, N) if (S[i] == 'B') b += A[i];
        FOR(i, N) if (S[i] == 'C') c += A[i];
        print(S);
        return;
      }
    }
  }
}

void solve() {
  LL(N);
  if (N == 6) { return print("ABC.BA"); }
  VEC(ll, A, N);
  solve(N, A);
}

signed main() {
  solve();
  // int N = 10'000;
  // ll AMAX = 1'000'000'000'000LL;
  // // int N = 100;
  // // ll AMAX = 1'000;
  // FOR(1) {
  //   vi A(N);
  //   FOR(i, N) A[i] = RNG(1, AMAX);
  //   // auto [ADD, SUB] = find(A);
  //   // SHOW(len(ADD), len(SUB));
  //   solve(N, A);
  // }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

6
4 3 8 1 5 4

output:

ABC.BA

result:

ok OK

Test #2:

score: 0
Accepted
time: 689ms
memory: 401464kb

input:

10000
997167959139 344481199252 880336470888 152634074578 801642802746 425740396295 408773386884 376579721198 658396628655 317503722503 880971207868 745202647942 998002087506 434268792718 388046761498 176443917727 968016843338 733125908043 536691952768 578717268783 515787375312 454150414369 93569331...

output:

.A...AA...A.....AAAA..AA..AA....A.A.AAAAA.AA.....A.A...A....AAAA.A...AA.A..AA.A..A.A..AAAA.AA.A...AAA.A.A.AA.AAAAAAAA...AAAAA.AA......................................B........................................................................................................................................

result:

ok OK

Test #3:

score: 0
Accepted
time: 1241ms
memory: 401424kb

input:

10000
244641009859 300054748096 592075475634 321804928248 527476927808 615284875072 612503158867 79627937890 24322595515 453786026685 995645468307 935669240390 150939887597 468588586447 937973764525 148521365644 506710156469 456985188306 646860350786 385011308832 488784695957 866770562147 8902084272...

output:

..AAA.AA.....AA.AAAA....AAAAAAA.....A...A....AA.A...AAA...A.AAA..AAA.......A.AAAAA.AA..A.AAAA..AAA.A..A..A...AAAAAA..AAA.A.AA.A..........................................................................B........................B.................B..........................................................

result:

ok OK

Test #4:

score: 0
Accepted
time: 1325ms
memory: 401280kb

input:

10000
483524125987 259923264237 336374288891 523535590429 220751244358 809124321145 816232930851 791266089174 394543529670 585773363571 110319728747 171580543238 299582720391 535468188689 496490702144 120598813561 17138628383 148284660056 752733781508 150155605777 502931759705 316245485733 844723534...

output:

..A.A.AAA...AAAA.....AA.AAAAAAAA.AAAAA.AA.A.....AA.AA.A..A.....A....AAAAA...A.AAA.A.......A...AAA.....AAAAAAAAA.AA.....A.A.AA.AA...........................................................................................................C...................................C..................B............

result:

ok OK

Test #5:

score: 0
Accepted
time: 929ms
memory: 401464kb

input:

10000
726702209411 215496813081 80673102149 729561219907 909730593611 961814024114 978812959730 494314305867 760469496529 726350635050 220699021890 366342102981 456815487777 569787982418 13857896659 51526518374 564421876106 876438907614 862902179526 956449645826 512783856158 728865633510 79923864224...

output:

...A.A...A.AAA...A....A.A..A.A..A.A.AAAA....A...A...AA..AA...AAAA..AAA..A..AA..AAAAA.AAA....A.AA..AA.AAAAA..AA...AA.AA.AA.AA...A...............................................B........................................................C..................................C...................................

result:

ok OK

Test #6:

score: 0
Accepted
time: 852ms
memory: 401464kb

input:

10000
965585325539 175365329221 792412106895 931291882089 635564718673 151358502890 186837699009 201657489855 130690430685 862632939232 335373282330 565398630021 609753287868 636667584659 568079866982 23603966291 74850348020 567738379364 964480642952 721593942770 526930919906 141485781288 7949034928...

output:

AAA..A.A.A.A.A.AA.A..A.AA.AA.AAAA....AAA.A.A.AAAA.A..A..A...A.A..A.A...AA.A.A..AAAA.AAA.AAA...AA.A.A.A.AAA.A..A.AAAAA..AA.AA.AAA......B............B.................................................................................................................................B.........................

result:

ok OK

Test #7:

score: 0
Accepted
time: 677ms
memory: 401464kb

input:

10000
213058376259 126643910770 541005887448 104757703054 324544067926 340902981667 353712695184 913295641139 500911364840 994620276118 486902318577 755865222469 795250896470 670987378388 89742028793 995681414208 622133595743 291597659626 74649040970 491033207011 504223207847 590960704874 7494186003...

output:

.A.A..A..AA..AA.A............AAA.A..A...AAAAAA.AA..AA..A...AAAA.A.AA.AAA.....AAA.....AAAA.AAA...AAAAAA..AAA...A..AA.A..A.A..A.......C..........................................................................................................................................................................

result:

ok OK

Test #8:

score: 0
Accepted
time: 749ms
memory: 401388kb

input:

10000
451941492387 119072235422 248449924898 310783332532 50378192988 493592684636 553147499872 616343857831 866837331700 135197547597 601576579017 991776525316 948188696560 701012204822 639669031820 967758862125 160826908873 982897131377 184817438988 288737312468 518370271596 3580852652 69963874057...

output:

AAA..A.....AA.A.A.A.A.A.AAAA..AAAAAA.A.AA...AA....A.A.AAA..AAA.AA.....AAA.A.A.A.AA...A..A.A...A.A.AA.A..A.AAA.AAAA.AAA..AAA.AA.A.......................................................................................................................................................C.....B.................

result:

ok OK

Test #9:

score: 0
Accepted
time: 612ms
memory: 401460kb

input:

10000
690824608515 78940751563 997043705451 512513994713 743652509537 687432130709 724317463343 323687041819 237058265855 271479851779 716250839457 186538085060 101126496650 772186774359 161331193631 939836310042 671255380788 706756411639 290690869710 58176576709 528222368048 411906033133 6910086238...

output:

.A..A.AAAA.A.A.A.AA.AA..A...A.AAA....AA.AA.AAA.AA...AAAA...AA.AA.AA...AA..AAAA.A.A.AAAA.A.AAAA...A.A...A..AAAAAA.AA.A.A.A.AA..A.............................................................................................................................B..................................................

result:

ok OK

Test #10:

score: 0
Accepted
time: 1239ms
memory: 401464kb

input:

10000
934002691939 34514300407 708782710197 718539624191 432631858791 876976609486 923752268030 31030225807 607279200011 403467188665 826630132600 385594612100 249769329445 797916633496 711258196658 911913757959 218538628510 398055883389 400859267729 827615840950 505514655989 824526180911 6455237314...

output:

A.AA....AAAAAAAA...AAAAAAA....AA..AA..A.A..A.A.AA..A.A.AA.AAAAA.AAA.A.AAA.AAA..AA.A.AAA.A.A...A..A.A...A.AAAA.AA.AA...AA.AA..AA.......................................................................C........................................................................................................

result:

ok OK

Test #11:

score: 0
Accepted
time: 627ms
memory: 401464kb

input:

10000
375802030518 117598196518 669640274071 415983359971 383071550121 462096204862 177799843967 526446173607 553796619138 341402690754 434223219513 93668171337 8312183499 715905549873 581673542337 416566661387 796879397647 243434495917 100631413076 394150918417 253579868000 895224422012 41512619570...

output:

AAA.A.A.A.AA.A..AA.....AAAA.A.A.A.A.A.AA..A..AA..A..A..A..A..AAAA.AA...A.A..AAA.A..A..A.AA....AAAAA.AAAA.A.AAA.AAA....AAAA.A...A................................................................................................C..............................................................................

result:

ok OK

Test #12:

score: 0
Accepted
time: 734ms
memory: 401460kb

input:

10000
614685146646 110026521171 381379278816 622008989449 72050899375 655935650934 381529615950 229494390299 915427618702 481979962232 544602512657 288429731081 165544950885 745930376306 135895512660 388644109304 344162645369 930439000371 206504843798 163590182657 267726931749 312139537086 365346335...

output:

AA..A.A..A..A..AA...AAA.AAA.A....AAAAA.A...AAAA..A.A.A...A...AA..AAA.A...AAAAA..AAA.A.A...AA........A..AA.A..A.AA.AAA.A.A.AA.A.A....................................................................................................B..........................................................................

result:

ok OK

Test #13:

score: 0
Accepted
time: 934ms
memory: 401460kb

input:

10000
857863230070 69895037311 125678092074 828034618927 802179991732 845480129711 548404612126 941132541583 285648552857 613967299118 659276773097 524341033928 318482750975 817104945843 653262707175 360721557221 854591117284 658593247929 316673241816 928734479602 245019219689 724759684863 324156410...

output:

A..AAAA.A....AAAA.A.AA.AAAA.A..A....A..AAAA..A.A.AA.AAAA..A..A.A.AA....AAAAAA..AA.AA.AA..AAAA.A.AAA.A.AA.AA.A.A..A...AAAAA.AAA.................B..................CC................B..........................................................................................................B...............

result:

ok OK

Test #14:

score: 0
Accepted
time: 853ms
memory: 401388kb

input:

10000
101041313494 25468586155 837417096820 997205472596 491159340986 2464799976 747839416813 648475725571 655869487013 750249603301 778246000832 714807626376 467125583769 847129772276 207484677498 332799005138 393284430414 349892719679 426841639834 735028519651 254871316142 174234608449 31552629403...

output:

.AA..A.AA..AA......AA.A...AA..A....A....A..A........A..AA.A...AA...A...AA.A...A.A.AA.AAA...A.A.A..A..A...AAA.AAA..A...AA.A.A.AAA..............................................................B................................................................................................................

result:

ok OK

Test #15:

score: 0
Accepted
time: 855ms
memory: 401468kb

input:

10000
344219396918 976747167704 581715910077 198936134778 180138690239 187714311457 919009380284 351523942263 21795453872 890826874779 888625293976 913864153416 620063383860 914009374518 724851872013 309171420351 940567678137 78046967238 532715070557 500172816596 269018379890 586854756227 2700414015...

output:

..A....A..A.AAAAA..AAA.A..AAAA.A..AAAA.AA.AAA.AAAAAAA.A.A..A...AA....A.AA..A..A.AA.AA.A.A.A...AAA.AA.A...AAAA.AA..A...A.AAAAA.............................B.................................................B..............................................................C...................................

result:

ok OK

Test #16:

score: 0
Accepted
time: 634ms
memory: 401468kb

input:

10000
583102513046 936615683844 293454914823 404961764255 905972815301 377258790234 118444184972 63162093547 392016388028 22814211665 3299554415 108625713159 773001183950 944034200951 279073842336 244394092460 450996150051 801906247500 638588501279 269612080836 283165443639 995179936708 224556509057...

output:

.....A.AAA..AA.A......AA.A....AAAAA.A.AA.....AAAAAA..A.AA....A..AAA.AA..AAAA.A.AA.A...A.A...AA..A.AA.AAAA..AAAAAAAAAAAAA...AAAA........................................................................................................................................................................B.B.....

result:

ok OK

Test #17:

score: 0
Accepted
time: 1316ms
memory: 401464kb

input:

10000
821985629174 892189232688 42048695377 606692426437 594952164554 534243460498 322173956955 766210310239 762237322183 159096515847 113678847559 307682240199 958498792552 15208770488 800736004147 212176573082 998279397774 488910751954 748756899297 71611153589 260457731579 444654860294 17907161656...

output:

AAAA.....A.AA.AAAAAA.AA....A..A..A..AAA.A..A.A..AAA.AA..AA..A.A.....A.A.A..A.AAAA.A.A.AAAA.AAAA......A.A.AA.A.A...AAA.AA.A.A.AA................................................................................................................................................................................

result:

ok OK

Test #18:

score: 0
Accepted
time: 719ms
memory: 401460kb

input:

10000
69458679894 888912524637 786347508634 775863280107 288226481104 723787939275 489048953130 473553494227 132458256339 299673787326 228353107999 539298575751 111436592642 45233596921 354957974470 184254020999 508707869688 217064999512 854630330019 836755450534 270309828032 857275008072 1747364671...

output:

..A.A...A.A.A..AA..A..AAAAAA.A...A.A..A....AAA.AA..AAAA......AAAAA....A.A.AAA.A.......AAAA.AAAAA..AAAAA.A.A...AAA..AA..A.......A...............................................................................................................................................................................

result:

ok OK

Test #19:

score: 0
Accepted
time: 1379ms
memory: 401320kb

input:

10000
308341796022 844486073481 498086513380 977593942288 14060606166 917627385348 692778725113 180896678215 498384223198 431661124212 379882144246 734060135494 264374392733 116408166459 909179944793 156331468916 47401182818 904069503967 964798728037 601899747479 284456891780 269895155850 1292515746...

output:

.AAA..A.AAA...A.A.AAAA...AAA.A.AA.AAA.A.AA..A.A.A..AAAAA.AA.A.A..AAAAA..AAA..A.AAAA.......AA.AAA.AA.A.A.....AAA..AAAA..A...AA.........................................................C..............................................B.................B.......................................................

result:

ok OK

Test #20:

score: 0
Accepted
time: 1275ms
memory: 401416kb

input:

10000
551519879446 795764655030 246680293934 187914539062 698744988123 70317088317 859653721289 888239862203 868605157354 567943428394 490261437390 928821695238 417312192823 146432992892 426547139308 128408916833 557829654733 632223751525 70672158759 408193787527 261749179721 723665046731 7947171490...

output:

A.....AA....AA.A....A.....AAA.....AA..A..AAAAAA..A..AAA.A..AA.AA.AA.AAA..AA.A...AA..AA..A..AA.AA.AA.A.AAA...AAA.AA.A.AA........A.....C.........................................................................................................................................................................

result:

ok OK

Test #21:

score: 0
Accepted
time: 1409ms
memory: 401460kb

input:

10000
179452405440 795586588704 583509061481 257552472140 17016115810 344148658854 266066743034 499628305150 799677780684 782519361360 712208050516 472401554301 240954478790 811346543678 414387546138 220832279893 610641889899 398080960260 267717802881 456588066499 427661699500 209083254572 883759454...

output:

.AAA.A...A...A.A.....A.AAA.AAA...A..AAAAA..AAA....A.AA..A.A..A.AA..A.AA.AA...A.....AA....A.AAAAAA...A.AAAAA.A.AAA....AA.AAAA.A.A................................B....C......................B......................................................................................................B...........

result:

ok OK

Test #22:

score: 0
Accepted
time: 665ms
memory: 401460kb

input:

10000
418335521569 751160137548 327807874739 426723325809 705995465063 533693137631 428646771913 206971489138 165603747543 918801665542 826882310956 667163114045 393892278880 841371370111 927459773357 192909727810 153630170326 121940240523 377886200899 262882106547 404953987440 621703402350 83827456...

output:

AAAAAAA...A..AAAAAA...A.A..AAAA....AA.A.AAA.A..A.AAAAA.AAA.A..A.A....A...AAA..AA.A.AAA..A....A.....AA..AA.AAA.AA.AAA..AAAA........................C.............................B..........................C.......................................B.........................................B.................

result:

ok OK

Test #23:

score: 0
Accepted
time: 750ms
memory: 401464kb

input:

10000
665808572289 706733686393 39546879484 632748955287 394974814317 727532583704 636671511192 914314673126 535824681699 50789002429 937261604100 866219641085 579389887482 908250972352 485976710976 164987175727 664058642240 817534679569 483759631621 28026403492 419101051189 71178325936 792789669437...

output:

.A.AAA..A..A..AAA..A..........AA.A...AA.....AAA..A.A.A...AA....AA...AAAAAA..A.A.AA.A..A..AA..AAA.A.AAAAA..AAA...AAA.AAA.A.A.AA...............................................................................................................................CC................................................

result:

ok OK

Test #24:

score: 0
Accepted
time: 791ms
memory: 401468kb

input:

10000
904691688417 699162011045 783845692742 838774584765 125103906675 880222286673 799251540072 621657857114 906045615854 187071306611 88790640347 97835976636 732327687572 942570766082 999048938195 132769656348 211341889962 541393959831 593928029640 834320443541 433248114937 483798473713 7841595527...

output:

A..A.A..A.A.A.AA..AA...AAAAAA..A..AAA.AAA..A....AAA..AA.AAAA.AAA.AAA.A.AA..AA.AAAAAAAA.A..A.AAA.AAA..A......AA.......A.A..AA.A.A......C..........................C..............C..............................B..............................................................................B............B...

result:

ok OK

Test #25:

score: 0
Accepted
time: 1358ms
memory: 401464kb

input:

10000
147869771841 659030527185 532439473295 40505246946 814083255928 69766765450 2981312055 324706073806 271971582714 327648578089 203464900787 292597536380 885265487663 9450368323 557565875814 104847104265 717475394581 232693431581 667241651850 599464740486 443100211390 896418621491 742969627560 3...

output:

.A..AA..A.AA......AA.AA.AA.A.A.AAAAAAA.AA.A...AA.A..A...A.....AAAAA.A.A....AA.AAA...AAAA...A.AAA...A..A.A.A.AA.A.A...A..A..A.AA...................................................B..........................B............................................................B....................................

result:

ok OK

Test #26:

score: 0
Accepted
time: 1283ms
memory: 401464kb

input:

10000
386752887969 614604076030 244178478041 209676100616 535622413694 263606211522 206711084038 36344225090 642192516869 459635914975 318139161226 487359096124 33908320457 43770162052 74933070329 40069776374 264758642303 956552711844 768820115276 364609037430 420392499330 341598577781 697484735069 ...

output:

A..A.AAA.....A.A..AA.AA..AAAAA.AA.AA.A..A.AAAA.AAAA.AAAAA.AA.AAA....AAAA.A..A..AA.A.AAAAAA.AAA..A....AA..A.AAA..A...AAAAA..AA.A.........B......................................................................................................................................................................

result:

ok OK

Test #27:

score: 0
Accepted
time: 1014ms
memory: 401384kb

input:

10000
629930971393 570177624874 988477291299 415701730093 224601762947 416295914491 373586080214 739392441782 12413451025 595918219158 432813421666 686415623163 186846120547 110649764293 629155040653 12147224291 770892146922 680411992106 878988513294 170903077479 434539563079 754218725559 6519998425...

output:

AAAA.AA..AA.A....A.A...AAAA....AAA.A...AA.AA.A.A..AA.A..AAA..A..AAA..AAAAAAAAAA......AAAAAAAA....A...AAAA.A..A..A.AA.A...A.A..AA.....B.....................................................................................B.................................................................B.................

result:

ok OK

Test #28:

score: 0
Accepted
time: 648ms
memory: 401468kb

input:

10000
873109054817 525751173719 700216296044 617432392275 913581112201 610135360564 573020884901 446735625770 378339417884 736495490636 543192714810 881177182907 339783920637 144969558023 183377010976 984224672208 318175394644 371711463856 989156911312 936047374424 448686626828 171133840632 63907475...

output:

.A..A..AA.A...A.AAA...AA.AAAAA..AA.AAA.AAA.A.AAAAAA.A...A.AAA.AA..A.AA..AAAA.A..AAA..A...A.A......A..AA.AA.....AA.....A.AAAA.AAA.........................C............................................B........................................................................................................

result:

ok OK

Test #29:

score: 0
Accepted
time: 1847ms
memory: 401460kb

input:

10000
111992170945 481324722563 448810076598 823458021753 643710204558 799679839341 744190848372 158373777054 748560352039 868482827522 657866975249 112793518459 529576496536 211849160264 700744205491 956302120125 865458642367 95570744118 95030342034 705486638665 421683947472 583753988410 5935898661...

output:

.A..AA.A.A...A.A..AAA..AA..A..A.AAA.AAAA.AA.A.A.AA.AAA.A.AA.AAAA...A...AAA...A.AAA.....AA..A..A.A..A..AAAA..A.A.....AA..AAAA..A..................................C.............C................................................................C......................................B.C.....................

result:

ok OK

Test #30:

score: 0
Accepted
time: 1444ms
memory: 401400kb

input:

10000
355170254369 478048014511 156254114048 25188683934 332689553812 948074575014 947920620356 824567217938 118781286195 4765131704 768246268393 307555078202 682514296626 241873986697 254966175814 924084600746 371592146985 786870215868 205198740052 507485711417 435831011221 28933944700 552399940915...

output:

...A..AA.A.A.AA.A..AAA.A..AA...A.A...AA.A....A.A....A....A...AA.A.A.A....A.A.A.AA..A..AA.AAAAAAAA.A.A..AAA.AAAA..AAAAA...A..AA.A...............................................................................................................................................................B...............

result:

ok OK

Test #31:

score: 0
Accepted
time: 1208ms
memory: 401284kb

input:

10000
946248004555 469280013594 529937657403 66561775796 646665714203 226201112847 317478866292 435955660885 49853909525 256195840478 27047657327 846839969970 501861615297 906787537483 201656839540 20802931102 420109414855 589582200412 402244384174 560174957684 610333465591 518647119837 356687680431...

output:

AAAAA...A.....AAA.AA.A....A.A...AA.....A.....AA..A.A.AA.A..AA.A.AAAAAAA.AAAA.A..AA..AA.A.AAAAA.AA.AA..AAAA..AA.AAA..AAA.AAA....A...............................................................................................C............B.........................B........................................

result:

ok OK

Test #32:

score: 0
Accepted
time: 2251ms
memory: 401340kb

input:

10000
185131120683 429148529734 278531437957 268292437978 335645063456 420040558920 516913670980 143298844873 415779876385 392478144661 141721917767 45896497009 654799415387 936812363916 760173777159 992880379019 930537886770 276586704866 508117814897 357879063141 583330786236 931267267614 311202787...

output:

A....A..AAA.AA.A.AA.....AAA.A.....AA...A.AAA.....A.AAAAAAAAA.AAAA.AAA.A.A.AA..A.AA..AA.A....A..AA.A.A.AAAA.A.AA....AAA.AA.AA.A....C.............................................................................................................C..............................................................

result:

ok OK

Test #33:

score: 0
Accepted
time: 797ms
memory: 401464kb

input:

10000
432604171403 384722078578 985975475406 474318067455 24624412710 609585037697 683788667155 850642028861 786000810540 528760448843 252101210911 240658056753 807737215477 7986933453 273246004378 964957826936 477821134492 9035919720 618286212915 127318327382 597477849984 380742191200 265717895449 ...

output:

AAAA.A.AA..A...A.A...AA.A........A..AAA.....A..A.AA..AAAA.AA..A.AAA.A.....AAAA.A..A...AAAAAA..A.A.A.AA..AA.AA..A..A..A.A.AA.AA..............................................C................B.................................................................................................................

result:

ok OK

Test #34:

score: 0
Accepted
time: 904ms
memory: 401468kb

input:

10000
671487287531 340295627423 734569255960 639193953829 750458537771 762274740665 887518439138 557985212849 151926777399 665042753025 366775471350 439714583793 956380048271 38011759887 831762941997 937035274854 20809414919 696040424175 724159643637 892462624327 611624913733 793362338978 2202330029...

output:

.AAAAAA.AAAA.A...A..A.AAA........AA...AA.AAAAAA.A.AAAAAAAA.AAAAA..A....A.A.A...AAAA....AAA.A.A..A.....A.AAA...AA..AA.A.AA....AA................................................................................................................................................................................

result:

ok OK

Test #35:

score: 0
Accepted
time: 743ms
memory: 401460kb

input:

10000
914665370955 337018919371 446308260706 849514550603 443732854321 956114186738 91248211122 261033429541 522147711555 801325057207 481449731790 671330919344 146172624170 109186329424 349130136512 909112722771 531237886833 419899704437 834328041655 698756664376 584622234378 201687519459 211602886...

output:

.A..AA..AAAA....A.A..AA..A.AA.AAAA...AA.AA.AA..AA.AAAA.A..A...A..AA..A..A.A.AA...A.A..A...A.AA....A.AAA..AAA.A.A..AA......A.AAAA............................B.............................................................................................................................C....................

result:

ok OK

Test #36:

score: 0
Accepted
time: 1167ms
memory: 401388kb

input:

10000
157843454379 288297500920 194902041259 51245212784 132712203574 141363698219 253828240001 972671580825 892368645710 937607361390 591829024933 866092479088 299110424260 143506123153 903352106835 844335394880 74226167260 111199176187 944496439673 468195928616 598769298126 655457410341 1618230264...

output:

A.A..AAA...A.A..AAAA..AAAAAA.A....A.....A..A.A...AA.A.....AA.AAA.AA..A....A.A.....AA.A.A..A.AAAAA...A..AA...AAAA..A.AA..A..A.A........C........................................................................................................................................................................

result:

ok OK

Test #37:

score: 0
Accepted
time: 695ms
memory: 401464kb

input:

10000
401021537803 248166017060 902346078709 257270842262 858546328636 298348368484 461852979280 675719797517 258294612570 69594698276 710798252669 65149006128 447753257054 206090758098 425014268646 812117875501 584654639174 835058456449 46074903099 270195001369 608621394579 68077558119 120633101295...

output:

...AAA.....A.......A....AA..AA..AA....AAAA.A.A..A.AA.A...AAA.AAAAAA.....AA.AA.AA.AA...AA..AA.A.A....AAA.A..AA.A.AAA..AAAA..AAA.A.........................................................................C.....................................................................................................

result:

ok OK

Test #38:

score: 0
Accepted
time: 850ms
memory: 401464kb

input:

10000
639904653932 203739565904 646644891967 459001504443 547525677890 487892847261 624433008160 383062981505 628515546725 210171969754 858032321621 259910565871 604986024440 240410551828 974941271673 784195323418 131937886896 563212704008 156243301117 39634265610 585913682519 480697705897 751482088...

output:

.AA..AA.AAAA...AAAAAA.AAAA....AAAAAA.A.A...A.A.A..A.A.AAA.A..AAAA.AA..AA.AAAA...AA..A..A.AA..AA.A.A..AAAA....A..A..A.A.AAAA.A..A.........................................................................................B.....................................................................................

result:

ok OK

Test #39:

score: 0
Accepted
time: 1070ms
memory: 401464kb

input:

10000
878787770060 159313114749 395238672520 628172358113 273359802951 677437326037 828162780143 94701132789 998736480881 346454273936 972706582060 458967092911 757923824531 270435378261 533458209292 756272771335 638071391515 250217208462 262116731839 804778562555 600060746268 930172629482 665180921...

output:

AA..AAA..AAAA..AA.A..A..A...A..A.A...AA.AAA....AA.AA..AA..AAAA.A.A.A.A.A..A..AAAA..AA.AA..A..AA....AAA..AAA.AAAAAA.....A..AAAAAA.....C.......................................................................................................B..................................................C..............

result:

ok OK

Test #40:

score: 0
Accepted
time: 900ms
memory: 401464kb

input:

10000
126260820780 119181630889 102682709970 834197987591 966634119501 834421996302 995037776318 797749349481 364662447740 478441610823 87380842500 686288461167 906566657325 341609947798 46530436511 728350219252 185354639237 982666423316 372285129857 611072602603 614207810016 338497809964 2103319963...

output:

.A....A..A.A..A.A..AAAAA....AA..A.AA.A.A..A.AA.A....A....A.AAAAAA..AAAAA..AAAA.AA....AA.A..A.A.AA.A.A.A...AAA...A.A...AAAA.A.A.A.................................C..............................................................C....................B.................B.......................................

result:

ok OK

Test #41:

score: 0
Accepted
time: 837ms
memory: 401428kb

input:

10000
713043603670 147268405779 480661220621 908130887964 276315312595 112548534136 401450798063 409137792429 300030038366 693017543789 305032488330 225573352934 767063719100 969668722776 34370843342 820773582312 238166874404 744228664756 569330773980 655171914278 747560521283 828210985101 788466163...

output:

A..AAA.A.......A..A.A..AAA...AAAAA.AA.AA.AAA.A...AA.AAA..A.AAAA..AAA...A...A.....A.AAA.AA..A.AA..A.A..A..A...A..A.A.AA....A..A....................................................................................BB.....................................................................C.....................

result:

ok OK

Test #42:

score: 0
Accepted
time: 887ms
memory: 401388kb

input:

10000
956221687094 107136921920 188105258071 77301741634 969589629145 297798045616 568325794239 116480976417 665956005226 829299847971 419706748770 424629879974 920001519190 36548325017 551738037857 792851030229 740005411726 472382912314 679499171998 461465954327 761707585032 277685908687 7798360466...

output:

..A.A.A.A.A....A.A.A.AA.AAA..A.AAA...A.AAA..A.AAAA....A.AAAAA..AA....A.AA.A.AAAA.AAAAAAAAA.A.AA....AAA.AA.A.AA....AA...A.....AAA.................................B...............................C.............................................C.......C.........................................B.............

result:

ok OK

Test #43:

score: 0
Accepted
time: 999ms
memory: 401264kb

input:

10000
199399770518 62710470764 936699038625 279032403816 658568978399 450487748585 772055566222 823824160405 31881972085 965582152153 571235785018 619391439717 68644351984 66573151451 105960008180 764928478146 287288659448 159387416768 785372602720 226610251272 775854648780 690306056464 738646121461...

output:

AA.AAA....AA..A..A.A.A.AA.AAA.AAA.....AAAAA.A.A..AAA.AA..AA....AAAA.AA.A.A..A..AA...AAA.AAA.AA.AAA..AA.A..A..A.A.AAAA.AA.AA.A.AA.....................................................................................................C............................................................C.....B......

result:

ok OK

Test #44:

score: 0
Accepted
time: 744ms
memory: 401420kb

input:

10000
438282886646 18284019609 648438043370 485058033293 384403103460 644327194658 934635595101 531167344393 402102906241 101864456335 681615078161 818447966757 221582152074 133452753692 623327202695 732710958767 797717131363 887541664326 895541000738 996049515513 748851969425 102926204242 693161228...

output:

A....A..AA.A.AA.A.A...AAAAA.AA.A.A....AA...AAAAAAA.....A..AA..AA....A.A.AAA...A..AAAAAA..A.AAA.AA..A.A.AA...A.A.A...AAA.AA.AA..A....................................................................................B.........................................................C................................

result:

ok OK

Test #45:

score: 0
Accepted
time: 677ms
memory: 401388kb

input:

10000
681460970070 973857568453 397031823924 686788695475 73382452714 833871673435 142660334380 234215561085 772323840396 238146760518 796289338601 13209526501 374519952165 167772547421 177549173018 704788406684 345000379085 574546168781 1414431460 798048588265 762999033173 515546352020 680236144992...

output:

AA..A.AAAA.A...A..AA.A..AAA..A.A..A.A.AAAAA.AAA.AA.A.A.AA....A.A..A.A.A.AA.AAA...A.A.AA..A...AAA.AAA.AAAAA..A..AA...A...A..AAA...............................................................................................................B....................................C............................

result:

ok OK

Test #46:

score: 0
Accepted
time: 906ms
memory: 401464kb

input:

10000
924639053494 966285893105 141330637182 892814324953 762361801967 990856343700 342095139068 945853712369 138249807256 374429064700 906668631744 244825862052 523162784959 234652149662 699211334829 640011078793 855428851000 302700416339 111582829478 567487852506 777146096922 965021275606 63475125...

output:

.AA.AA.AA.AA....A..A.AA...AA..A...A..A...A.AAAAA...AA..AAA.A.AAA.AA..A.A.AAAA....A...AA.A...AAA.AA.A.AA....AA.A.A..AA..A.A.AA.AA..........................C....................................................................................................................................................

result:

ok OK

Test #47:

score: 0
Accepted
time: 720ms
memory: 401412kb

input:

10000
167817136918 926154409246 848774674631 61985178622 492490894325 180400822476 508970135243 653196896357 508470741411 510711368882 21342892184 439587421796 717250328153 268971943392 249138337856 612088526710 394122164130 989704920793 217456260200 336927116747 754438384862 377641423383 5892663600...

output:

A.AA.AAA.A.A.A..A...AAA..AAAAA.A...A..A.........A.A.A.......AAAAA.A.AAA..A..A.AAA..AA.AAAA..A....AAAAAA.A....A.AA.A.A..AA.A.A..........................................B.....................................C.......B...................................B.....................................................

result:

ok OK

Test #48:

score: 0
Accepted
time: 628ms
memory: 401460kb

input:

10000
406700253046 881727958090 597368455185 268010808100 181470243578 369945301253 712699907226 356245113049 878691675567 646993673065 140312119920 638643948836 870188128243 335851545633 807655275475 584165974628 941405411853 717859168351 323329690922 138926189500 764290481315 790261571161 54807643...

output:

.A.A..A..A...AAA.A.A..AA.AA.A..A...A.A...A.A..AA.AA.....AAAA.AAAAA.AA.AAAA...A..A.A.A..AAA....AAAA....A.AAAA.A.A..AAA.A.A.AAA..................................................................................................................................B...............................................

result:

ok OK

Test #49:

score: 0
Accepted
time: 627ms
memory: 401460kb

input:

10000
645583369174 837301506934 309107459931 469741470281 907304368640 563784747326 879574903402 67883264333 244617642426 783275977247 250691413063 833405508579 18830961038 370171339362 320727502694 556243422545 451833883767 446013415909 433498088940 904070486445 778437545063 235441527451 5394463181...

output:

A..A.AA..A.A...A.A..AAAA.AA..A.AA..A.AAA.AA...A....AA.AAAA..AAAAA.AAA..AA....AA....AAAA.A.A..AAAA..AA.AAAAAAAAAA..A.A..A..AAAAA............................................................................................................................................C...................................

result:

ok OK

Test #50:

score: 0
Accepted
time: 809ms
memory: 401464kb

input:

10000
893056419894 792875055779 53406273188 675767099759 596283717893 716474450295 79009708089 770931481025 614838576582 919558281429 365365673503 32462035619 171768761128 437050941603 879244440313 524025903166 999117131490 137312887660 539371519662 706069559197 792584608812 648061675229 49396142564...

output:

...A.A.AAAA.A..AAA.A..A..AA..AAAA...A.A....AAA...AAA.A....A.A...A....A..AA...AA.AA..AA..A.AA.A.A.AA.AA.AAAA.AAA.A.A..AAA...AA.A......................................................................................................B......................................................B..................

result:

ok OK

Test #51:

score: 0
Accepted
time: 702ms
memory: 401464kb

input:

10000
484134170081 825256797965 390235040736 712845224325 873405102476 990306020832 448567954026 382319923972 513351391400 129839247099 619872095141 571746927386 991116079799 60814749285 825935104039 625039200818 10779623552 940024872203 703857355273 754463838168 921642352783 137774850365 2613943893...

output:

AA.AA...A..AA.AA.AAAAAAAAAA.A.A.A..AAA.AAA.AA..A.A.A.A..AA....A.....AAA..AAAAAA....A..A.A.A..A..A..A.AAA.AA.A..AA..AAA.AAAAA.AA........C....C.............................................................................................................................B....................................

result:

ok OK

Extra Test:

score: 0
Extra Test Passed