QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#553172 | #9245. Bracket Sequence | maspy | AC ✓ | 1799ms | 287316kb | C++20 | 25.8kb | 2024-09-08 10:09:32 | 2024-09-08 10:09:32 |
Judging History
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 u32 = unsigned int;
using u64 = unsigned long long;
using i128 = __int128;
using u128 = unsigned __int128;
using f128 = __float128;
template <class T>
constexpr T infty = 0;
template <>
constexpr int infty<int> = 1'010'000'000;
template <>
constexpr ll infty<ll> = 2'020'000'000'000'000'000;
template <>
constexpr u32 infty<u32> = infty<int>;
template <>
constexpr u64 infty<u64> = infty<ll>;
template <>
constexpr i128 infty<i128> = i128(infty<ll>) * 2'000'000'000'000'000'000;
template <>
constexpr double infty<double> = infty<ll>;
template <>
constexpr long double infty<long double> = infty<ll>;
using pi = pair<ll, ll>;
using vi = vector<ll>;
template <class T>
using vc = vector<T>;
template <class T>
using vvc = vector<vc<T>>;
template <class T>
using vvvc = vector<vvc<T>>;
template <class T>
using vvvvc = vector<vvvc<T>>;
template <class T>
using vvvvvc = vector<vvvvc<T>>;
template <class T>
using pq = priority_queue<T>;
template <class T>
using pqg = priority_queue<T, vector<T>, greater<T>>;
#define vv(type, name, h, ...) vector<vector<type>> name(h, vector<type>(__VA_ARGS__))
#define vvv(type, name, h, w, ...) vector<vector<vector<type>>> name(h, vector<vector<type>>(w, vector<type>(__VA_ARGS__)))
#define vvvv(type, name, a, b, c, ...) \
vector<vector<vector<vector<type>>>> name(a, vector<vector<vector<type>>>(b, vector<vector<type>>(c, vector<type>(__VA_ARGS__))))
// https://trap.jp/post/1224/
#define FOR1(a) for (ll _ = 0; _ < ll(a); ++_)
#define FOR2(i, a) for (ll i = 0; i < ll(a); ++i)
#define FOR3(i, a, b) for (ll i = a; i < ll(b); ++i)
#define FOR4(i, a, b, c) for (ll i = a; i < ll(b); i += (c))
#define FOR1_R(a) for (ll i = (a)-1; i >= ll(0); --i)
#define FOR2_R(i, a) for (ll i = (a)-1; i >= ll(0); --i)
#define FOR3_R(i, a, b) for (ll i = (b)-1; i >= ll(a); --i)
#define overload4(a, b, c, d, e, ...) e
#define overload3(a, b, c, d, ...) d
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FOR_R(...) overload3(__VA_ARGS__, FOR3_R, FOR2_R, FOR1_R)(__VA_ARGS__)
#define FOR_subset(t, s) for (ll t = (s); t >= 0; t = (t == 0 ? -1 : (t - 1) & (s)))
#define all(x) x.begin(), x.end()
#define len(x) ll(x.size())
#define elif else if
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define stoi stoll
int popcnt(int x) { return __builtin_popcount(x); }
int popcnt(u32 x) { return __builtin_popcount(x); }
int popcnt(ll x) { return __builtin_popcountll(x); }
int popcnt(u64 x) { return __builtin_popcountll(x); }
int popcnt_mod_2(int x) { return __builtin_parity(x); }
int popcnt_mod_2(u32 x) { return __builtin_parity(x); }
int popcnt_mod_2(ll x) { return __builtin_parityll(x); }
int popcnt_mod_2(u64 x) { return __builtin_parityll(x); }
// (0, 1, 2, 3, 4) -> (-1, 0, 1, 1, 2)
int topbit(int x) { return (x == 0 ? -1 : 31 - __builtin_clz(x)); }
int topbit(u32 x) { return (x == 0 ? -1 : 31 - __builtin_clz(x)); }
int topbit(ll x) { return (x == 0 ? -1 : 63 - __builtin_clzll(x)); }
int topbit(u64 x) { return (x == 0 ? -1 : 63 - __builtin_clzll(x)); }
// (0, 1, 2, 3, 4) -> (-1, 0, 1, 0, 2)
int lowbit(int x) { return (x == 0 ? -1 : __builtin_ctz(x)); }
int lowbit(u32 x) { return (x == 0 ? -1 : __builtin_ctz(x)); }
int lowbit(ll x) { return (x == 0 ? -1 : __builtin_ctzll(x)); }
int lowbit(u64 x) { return (x == 0 ? -1 : __builtin_ctzll(x)); }
template <typename T>
T floor(T a, T b) {
return a / b - (a % b && (a ^ b) < 0);
}
template <typename T>
T ceil(T x, T y) {
return floor(x + y - 1, y);
}
template <typename T>
T bmod(T x, T y) {
return x - y * floor(x, y);
}
template <typename T>
pair<T, T> divmod(T x, T y) {
T q = floor(x, y);
return {q, x - q * y};
}
template <typename T, typename U>
T SUM(const vector<U> &A) {
T sm = 0;
for (auto &&a: A) sm += a;
return sm;
}
#define MIN(v) *min_element(all(v))
#define MAX(v) *max_element(all(v))
#define LB(c, x) distance((c).begin(), lower_bound(all(c), (x)))
#define UB(c, x) distance((c).begin(), upper_bound(all(c), (x)))
#define UNIQUE(x) sort(all(x)), x.erase(unique(all(x)), x.end()), x.shrink_to_fit()
template <typename T>
T POP(deque<T> &que) {
T a = que.front();
que.pop_front();
return a;
}
template <typename T>
T POP(pq<T> &que) {
T a = que.top();
que.pop();
return a;
}
template <typename T>
T POP(pqg<T> &que) {
T a = que.top();
que.pop();
return a;
}
template <typename T>
T POP(vc<T> &que) {
T a = que.back();
que.pop_back();
return a;
}
template <typename F>
ll binary_search(F check, ll ok, ll ng, bool check_ok = true) {
if (check_ok) assert(check(ok));
while (abs(ok - ng) > 1) {
auto x = (ng + ok) / 2;
(check(x) ? ok : ng) = x;
}
return ok;
}
template <typename F>
double binary_search_real(F check, double ok, double ng, int iter = 100) {
FOR(iter) {
double x = (ok + ng) / 2;
(check(x) ? ok : ng) = x;
}
return (ok + ng) / 2;
}
template <class T, class S>
inline bool chmax(T &a, const S &b) {
return (a < b ? a = b, 1 : 0);
}
template <class T, class S>
inline bool chmin(T &a, const S &b) {
return (a > b ? a = b, 1 : 0);
}
// ? は -1
vc<int> s_to_vi(const string &S, char first_char) {
vc<int> A(S.size());
FOR(i, S.size()) { A[i] = (S[i] != '?' ? S[i] - first_char : -1); }
return A;
}
template <typename T, typename U>
vector<T> cumsum(vector<U> &A, int off = 1) {
int N = A.size();
vector<T> B(N + 1);
FOR(i, N) { B[i + 1] = B[i] + A[i]; }
if (off == 0) B.erase(B.begin());
return B;
}
// stable sort
template <typename T>
vector<int> argsort(const vector<T> &A) {
vector<int> ids(len(A));
iota(all(ids), 0);
sort(all(ids), [&](int i, int j) { return (A[i] == A[j] ? i < j : A[i] < A[j]); });
return ids;
}
// A[I[0]], A[I[1]], ...
template <typename T>
vc<T> rearrange(const vc<T> &A, const vc<int> &I) {
vc<T> B(len(I));
FOR(i, len(I)) B[i] = A[I[i]];
return B;
}
template <typename T, typename... Vectors>
void concat(vc<T> &first, const Vectors &... others) {
vc<T> &res = first;
(res.insert(res.end(), others.begin(), others.end()), ...);
}
#endif
#line 1 "library/other/io.hpp"
#define FASTIO
#include <unistd.h>
// https://judge.yosupo.jp/submission/21623
namespace fastio {
static constexpr uint32_t SZ = 1 << 17;
char ibuf[SZ];
char obuf[SZ];
char out[100];
// pointer of ibuf, obuf
uint32_t pil = 0, pir = 0, por = 0;
struct Pre {
char num[10000][4];
constexpr Pre() : num() {
for (int i = 0; i < 10000; i++) {
int n = i;
for (int j = 3; j >= 0; j--) {
num[i][j] = n % 10 | '0';
n /= 10;
}
}
}
} constexpr pre;
inline void load() {
memcpy(ibuf, ibuf + pil, pir - pil);
pir = pir - pil + fread(ibuf + pir - pil, 1, SZ - pir + pil, stdin);
pil = 0;
if (pir < SZ) ibuf[pir++] = '\n';
}
inline void flush() {
fwrite(obuf, 1, por, stdout);
por = 0;
}
void rd(char &c) {
do {
if (pil + 1 > pir) load();
c = ibuf[pil++];
} while (isspace(c));
}
void rd(string &x) {
x.clear();
char c;
do {
if (pil + 1 > pir) load();
c = ibuf[pil++];
} while (isspace(c));
do {
x += c;
if (pil == pir) load();
c = ibuf[pil++];
} while (!isspace(c));
}
template <typename T>
void rd_real(T &x) {
string s;
rd(s);
x = stod(s);
}
template <typename T>
void rd_integer(T &x) {
if (pil + 100 > pir) load();
char c;
do
c = ibuf[pil++];
while (c < '-');
bool minus = 0;
if constexpr (is_signed<T>::value || is_same_v<T, i128>) {
if (c == '-') { minus = 1, c = ibuf[pil++]; }
}
x = 0;
while ('0' <= c) { x = x * 10 + (c & 15), c = ibuf[pil++]; }
if constexpr (is_signed<T>::value || is_same_v<T, i128>) {
if (minus) x = -x;
}
}
void rd(int &x) { rd_integer(x); }
void rd(ll &x) { rd_integer(x); }
void rd(i128 &x) { rd_integer(x); }
void rd(u32 &x) { rd_integer(x); }
void rd(u64 &x) { rd_integer(x); }
void rd(u128 &x) { rd_integer(x); }
void rd(double &x) { rd_real(x); }
void rd(long double &x) { rd_real(x); }
void rd(f128 &x) { rd_real(x); }
template <class T, class U>
void rd(pair<T, U> &p) {
return rd(p.first), rd(p.second);
}
template <size_t N = 0, typename T>
void rd_tuple(T &t) {
if constexpr (N < std::tuple_size<T>::value) {
auto &x = std::get<N>(t);
rd(x);
rd_tuple<N + 1>(t);
}
}
template <class... T>
void rd(tuple<T...> &tpl) {
rd_tuple(tpl);
}
template <size_t N = 0, typename T>
void rd(array<T, N> &x) {
for (auto &d: x) rd(d);
}
template <class T>
void rd(vc<T> &x) {
for (auto &d: x) rd(d);
}
void read() {}
template <class H, class... T>
void read(H &h, T &... t) {
rd(h), read(t...);
}
void wt(const char c) {
if (por == SZ) flush();
obuf[por++] = c;
}
void wt(const string s) {
for (char c: s) wt(c);
}
void wt(const char *s) {
size_t len = strlen(s);
for (size_t i = 0; i < len; i++) wt(s[i]);
}
template <typename T>
void wt_integer(T x) {
if (por > SZ - 100) flush();
if (x < 0) { obuf[por++] = '-', x = -x; }
int outi;
for (outi = 96; x >= 10000; outi -= 4) {
memcpy(out + outi, pre.num[x % 10000], 4);
x /= 10000;
}
if (x >= 1000) {
memcpy(obuf + por, pre.num[x], 4);
por += 4;
} else if (x >= 100) {
memcpy(obuf + por, pre.num[x] + 1, 3);
por += 3;
} else if (x >= 10) {
int q = (x * 103) >> 10;
obuf[por] = q | '0';
obuf[por + 1] = (x - q * 10) | '0';
por += 2;
} else
obuf[por++] = x | '0';
memcpy(obuf + por, out + outi + 4, 96 - outi);
por += 96 - outi;
}
template <typename T>
void wt_real(T x) {
ostringstream oss;
oss << fixed << setprecision(15) << double(x);
string s = oss.str();
wt(s);
}
void wt(int x) { wt_integer(x); }
void wt(ll x) { wt_integer(x); }
void wt(i128 x) { wt_integer(x); }
void wt(u32 x) { wt_integer(x); }
void wt(u64 x) { wt_integer(x); }
void wt(u128 x) { wt_integer(x); }
void wt(double x) { wt_real(x); }
void wt(long double x) { wt_real(x); }
void wt(f128 x) { wt_real(x); }
template <class T, class U>
void wt(const pair<T, U> val) {
wt(val.first);
wt(' ');
wt(val.second);
}
template <size_t N = 0, typename T>
void wt_tuple(const T t) {
if constexpr (N < std::tuple_size<T>::value) {
if constexpr (N > 0) { wt(' '); }
const auto x = std::get<N>(t);
wt(x);
wt_tuple<N + 1>(t);
}
}
template <class... T>
void wt(tuple<T...> tpl) {
wt_tuple(tpl);
}
template <class T, size_t S>
void wt(const array<T, S> val) {
auto n = val.size();
for (size_t i = 0; i < n; i++) {
if (i) wt(' ');
wt(val[i]);
}
}
template <class T>
void wt(const vector<T> val) {
auto n = val.size();
for (size_t i = 0; i < n; i++) {
if (i) wt(' ');
wt(val[i]);
}
}
void print() { wt('\n'); }
template <class Head, class... Tail>
void print(Head &&head, Tail &&... tail) {
wt(head);
if (sizeof...(Tail)) wt(' ');
print(forward<Tail>(tail)...);
}
// gcc expansion. called automaticall after main.
void __attribute__((destructor)) _d() { flush(); }
} // namespace fastio
using fastio::read;
using fastio::print;
using fastio::flush;
#if defined(LOCAL)
#define SHOW(...) SHOW_IMPL(__VA_ARGS__, SHOW6, SHOW5, SHOW4, SHOW3, SHOW2, SHOW1)(__VA_ARGS__)
#define SHOW_IMPL(_1, _2, _3, _4, _5, _6, NAME, ...) NAME
#define SHOW1(x) print(#x, "=", (x)), flush()
#define SHOW2(x, y) print(#x, "=", (x), #y, "=", (y)), flush()
#define SHOW3(x, y, z) print(#x, "=", (x), #y, "=", (y), #z, "=", (z)), flush()
#define SHOW4(x, y, z, w) print(#x, "=", (x), #y, "=", (y), #z, "=", (z), #w, "=", (w)), flush()
#define SHOW5(x, y, z, w, v) print(#x, "=", (x), #y, "=", (y), #z, "=", (z), #w, "=", (w), #v, "=", (v)), flush()
#define SHOW6(x, y, z, w, v, u) print(#x, "=", (x), #y, "=", (y), #z, "=", (z), #w, "=", (w), #v, "=", (v), #u, "=", (u)), flush()
#else
#define SHOW(...)
#endif
#define INT(...) \
int __VA_ARGS__; \
read(__VA_ARGS__)
#define LL(...) \
ll __VA_ARGS__; \
read(__VA_ARGS__)
#define U32(...) \
u32 __VA_ARGS__; \
read(__VA_ARGS__)
#define U64(...) \
u64 __VA_ARGS__; \
read(__VA_ARGS__)
#define STR(...) \
string __VA_ARGS__; \
read(__VA_ARGS__)
#define CHAR(...) \
char __VA_ARGS__; \
read(__VA_ARGS__)
#define DBL(...) \
double __VA_ARGS__; \
read(__VA_ARGS__)
#define VEC(type, name, size) \
vector<type> name(size); \
read(name)
#define VV(type, name, h, w) \
vector<vector<type>> name(h, vector<type>(w)); \
read(name)
void YES(bool t = 1) { print(t ? "YES" : "NO"); }
void NO(bool t = 1) { YES(!t); }
void Yes(bool t = 1) { print(t ? "Yes" : "No"); }
void No(bool t = 1) { Yes(!t); }
void yes(bool t = 1) { print(t ? "yes" : "no"); }
void no(bool t = 1) { yes(!t); }
#line 3 "main.cpp"
#line 2 "library/mod/modint_common.hpp"
struct has_mod_impl {
template <class T>
static auto check(T &&x) -> decltype(x.get_mod(), std::true_type{});
template <class T>
static auto check(...) -> std::false_type;
};
template <class T>
class has_mod : public decltype(has_mod_impl::check<T>(std::declval<T>())) {};
template <typename mint>
mint inv(int n) {
static const int mod = mint::get_mod();
static vector<mint> dat = {0, 1};
assert(0 <= n);
if (n >= mod) n %= mod;
while (len(dat) <= n) {
int k = len(dat);
int q = (mod + k - 1) / k;
dat.eb(dat[k * q - mod] * mint::raw(q));
}
return dat[n];
}
template <typename mint>
mint fact(int n) {
static const int mod = mint::get_mod();
assert(0 <= n && n < mod);
static vector<mint> dat = {1, 1};
while (len(dat) <= n) dat.eb(dat[len(dat) - 1] * mint::raw(len(dat)));
return dat[n];
}
template <typename mint>
mint fact_inv(int n) {
static vector<mint> dat = {1, 1};
if (n < 0) return mint(0);
while (len(dat) <= n) dat.eb(dat[len(dat) - 1] * inv<mint>(len(dat)));
return dat[n];
}
template <class mint, class... Ts>
mint fact_invs(Ts... xs) {
return (mint(1) * ... * fact_inv<mint>(xs));
}
template <typename mint, class Head, class... Tail>
mint multinomial(Head &&head, Tail &&... tail) {
return fact<mint>(head) * fact_invs<mint>(std::forward<Tail>(tail)...);
}
template <typename mint>
mint C_dense(int n, int k) {
static vvc<mint> C;
static int H = 0, W = 0;
auto calc = [&](int i, int j) -> mint {
if (i == 0) return (j == 0 ? mint(1) : mint(0));
return C[i - 1][j] + (j ? C[i - 1][j - 1] : 0);
};
if (W <= k) {
FOR(i, H) {
C[i].resize(k + 1);
FOR(j, W, k + 1) { C[i][j] = calc(i, j); }
}
W = k + 1;
}
if (H <= n) {
C.resize(n + 1);
FOR(i, H, n + 1) {
C[i].resize(W);
FOR(j, W) { C[i][j] = calc(i, j); }
}
H = n + 1;
}
return C[n][k];
}
template <typename mint, bool large = false, bool dense = false>
mint C(ll n, ll k) {
assert(n >= 0);
if (k < 0 || n < k) return 0;
if constexpr (dense) return C_dense<mint>(n, k);
if constexpr (!large) return multinomial<mint>(n, k, n - k);
k = min(k, n - k);
mint x(1);
FOR(i, k) x *= mint(n - i);
return x * fact_inv<mint>(k);
}
template <typename mint, bool large = false>
mint C_inv(ll n, ll k) {
assert(n >= 0);
assert(0 <= k && k <= n);
if (!large) return fact_inv<mint>(n) * fact<mint>(k) * fact<mint>(n - k);
return mint(1) / C<mint, 1>(n, k);
}
// [x^d](1-x)^{-n}
template <typename mint, bool large = false, bool dense = false>
mint C_negative(ll n, ll d) {
assert(n >= 0);
if (d < 0) return mint(0);
if (n == 0) { return (d == 0 ? mint(1) : mint(0)); }
return C<mint, large, dense>(n + d - 1, d);
}
#line 3 "library/mod/modint.hpp"
template <int mod>
struct modint {
static constexpr u32 umod = u32(mod);
static_assert(umod < u32(1) << 31);
u32 val;
static modint raw(u32 v) {
modint x;
x.val = v;
return x;
}
constexpr modint() : val(0) {}
constexpr modint(u32 x) : val(x % umod) {}
constexpr modint(u64 x) : val(x % umod) {}
constexpr modint(u128 x) : val(x % umod) {}
constexpr modint(int x) : val((x %= mod) < 0 ? x + mod : x){};
constexpr modint(ll x) : val((x %= mod) < 0 ? x + mod : x){};
constexpr modint(i128 x) : val((x %= mod) < 0 ? x + mod : x){};
bool operator<(const modint &other) const { return val < other.val; }
modint &operator+=(const modint &p) {
if ((val += p.val) >= umod) val -= umod;
return *this;
}
modint &operator-=(const modint &p) {
if ((val += umod - p.val) >= umod) val -= umod;
return *this;
}
modint &operator*=(const modint &p) {
val = u64(val) * p.val % umod;
return *this;
}
modint &operator/=(const modint &p) {
*this *= p.inverse();
return *this;
}
modint operator-() const { return modint::raw(val ? mod - val : u32(0)); }
modint operator+(const modint &p) const { return modint(*this) += p; }
modint operator-(const modint &p) const { return modint(*this) -= p; }
modint operator*(const modint &p) const { return modint(*this) *= p; }
modint operator/(const modint &p) const { return modint(*this) /= p; }
bool operator==(const modint &p) const { return val == p.val; }
bool operator!=(const modint &p) const { return val != p.val; }
modint inverse() const {
int a = val, b = mod, u = 1, v = 0, t;
while (b > 0) {
t = a / b;
swap(a -= t * b, b), swap(u -= t * v, v);
}
return modint(u);
}
modint pow(ll n) const {
assert(n >= 0);
modint ret(1), mul(val);
while (n > 0) {
if (n & 1) ret *= mul;
mul *= mul;
n >>= 1;
}
return ret;
}
static constexpr int get_mod() { return mod; }
// (n, r), r は 1 の 2^n 乗根
static constexpr pair<int, int> ntt_info() {
if (mod == 120586241) return {20, 74066978};
if (mod == 167772161) return {25, 17};
if (mod == 469762049) return {26, 30};
if (mod == 754974721) return {24, 362};
if (mod == 880803841) return {23, 211};
if (mod == 943718401) return {22, 663003469};
if (mod == 998244353) return {23, 31};
if (mod == 1004535809) return {21, 836905998};
if (mod == 1045430273) return {20, 363};
if (mod == 1051721729) return {20, 330};
if (mod == 1053818881) return {20, 2789};
return {-1, -1};
}
static constexpr bool can_ntt() { return ntt_info().fi != -1; }
};
#ifdef FASTIO
template <int mod>
void rd(modint<mod> &x) {
fastio::rd(x.val);
x.val %= mod;
// assert(0 <= x.val && x.val < mod);
}
template <int mod>
void wt(modint<mod> x) {
fastio::wt(x.val);
}
#endif
using modint107 = modint<1000000007>;
using modint998 = modint<998244353>;
#line 2 "library/ds/segtree/segtree.hpp"
template <class Monoid>
struct SegTree {
using MX = Monoid;
using X = typename MX::value_type;
using value_type = X;
vc<X> dat;
int n, log, size;
SegTree() {}
SegTree(int n) { build(n); }
template <typename F>
SegTree(int n, F f) {
build(n, f);
}
SegTree(const vc<X>& v) { build(v); }
void build(int m) {
build(m, [](int i) -> X { return MX::unit(); });
}
void build(const vc<X>& v) {
build(len(v), [&](int i) -> X { return v[i]; });
}
template <typename F>
void build(int m, F f) {
n = m, log = 1;
while ((1 << log) < n) ++log;
size = 1 << log;
dat.assign(size << 1, MX::unit());
FOR(i, n) dat[size + i] = f(i);
FOR_R(i, 1, size) update(i);
}
X get(int i) { return dat[size + i]; }
vc<X> get_all() { return {dat.begin() + size, dat.begin() + size + n}; }
void update(int i) { dat[i] = Monoid::op(dat[2 * i], dat[2 * i + 1]); }
void set(int i, const X& x) {
assert(i < n);
dat[i += size] = x;
while (i >>= 1) update(i);
}
void multiply(int i, const X& x) {
assert(i < n);
i += size;
dat[i] = Monoid::op(dat[i], x);
while (i >>= 1) update(i);
}
X prod(int L, int R) {
assert(0 <= L && L <= R && R <= n);
X vl = Monoid::unit(), vr = Monoid::unit();
L += size, R += size;
while (L < R) {
if (L & 1) vl = Monoid::op(vl, dat[L++]);
if (R & 1) vr = Monoid::op(dat[--R], vr);
L >>= 1, R >>= 1;
}
return Monoid::op(vl, vr);
}
X prod_all() { return dat[1]; }
template <class F>
int max_right(F check, int L) {
assert(0 <= L && L <= n && check(Monoid::unit()));
if (L == n) return n;
L += size;
X sm = Monoid::unit();
do {
while (L % 2 == 0) L >>= 1;
if (!check(Monoid::op(sm, dat[L]))) {
while (L < size) {
L = 2 * L;
if (check(Monoid::op(sm, dat[L]))) { sm = Monoid::op(sm, dat[L++]); }
}
return L - size;
}
sm = Monoid::op(sm, dat[L++]);
} while ((L & -L) != L);
return n;
}
template <class F>
int min_left(F check, int R) {
assert(0 <= R && R <= n && check(Monoid::unit()));
if (R == 0) return 0;
R += size;
X sm = Monoid::unit();
do {
--R;
while (R > 1 && (R % 2)) R >>= 1;
if (!check(Monoid::op(dat[R], sm))) {
while (R < size) {
R = 2 * R + 1;
if (check(Monoid::op(dat[R], sm))) { sm = Monoid::op(dat[R--], sm); }
}
return R + 1 - size;
}
sm = Monoid::op(dat[R], sm);
} while ((R & -R) != R);
return 0;
}
// prod_{l<=i<r} A[i xor x]
X xor_prod(int l, int r, int xor_val) {
static_assert(Monoid::commute);
X x = Monoid::unit();
for (int k = 0; k < log + 1; ++k) {
if (l >= r) break;
if (l & 1) { x = Monoid::op(x, dat[(size >> k) + ((l++) ^ xor_val)]); }
if (r & 1) { x = Monoid::op(x, dat[(size >> k) + ((--r) ^ xor_val)]); }
l /= 2, r /= 2, xor_val /= 2;
}
return x;
}
};
#line 6 "main.cpp"
// #include "ds/offline_query/static_monoid_products.hpp"
/*
左端のカッコ : i
右端のカッコ : j
1,i,j,ij の sum が欲しい
左端、文字数 -> 1,i,j,ij の sum
[2][41][2][2]
*/
using mint = modint998;
constexpr int K = 20;
using ARR = array<array<array<array<mint, 2>, 2>, 2 * K + 1>, 2>;
struct T {
int n;
ARR arr;
};
struct Mono {
using value_type = T;
using X = value_type;
static X op(X LL, X RR) {
if (LL.n == 0) return RR;
if (RR.n == 0) return LL;
ARR ANS;
ARR& L = LL.arr;
ARR& R = RR.arr;
int Ln = LL.n;
int Rn = RR.n;
// 左だけ、右だけ
FOR(l, 2) FOR(n, 1, 2 * K + 1) FOR(i, 2) FOR(j, 2) {
ANS[l][n][i][j] += L[l][n][i][j];
ANS[l][n][i][j] += R[l][n][i][j];
}
FOR(l, 2) FOR(n, 1, Ln + 1) {
int l1 = (l + n) & 1;
FOR(n1, 1, min<int>(2 * K - n, Rn) + 1) {
auto& A = ANS[l][n + n1];
auto& B = L[l][n];
auto& C = R[l1][n1];
A[0][0] += B[0][0] * C[0][0];
A[0][1] += B[0][0] * C[0][1];
A[1][0] += B[1][0] * C[0][0];
A[1][1] += B[1][0] * C[0][1];
}
}
int n = min(2 * K, Ln + Rn);
return {n, ANS};
}
static constexpr X unit() { return T{0, ARR{}}; }
static constexpr bool commute = 0;
};
template <typename Mono, typename T, typename F>
void static_monoid_products(vc<T>& A, vc<pair<int, int>>& query, F f) {
int N = len(A), Q = len(query);
vvc<int> IDS(N);
FOR(q, Q) {
auto [L, R] = query[q];
if (R <= L + 4) {
T ans = A[L];
FOR(i, L + 1, R) ans = Mono::op(ans, A[i]);
T t = Mono::unit();
f(q, ans, t);
} else {
--R;
int k = topbit(L ^ R);
int M = R >> k << k;
IDS[M].eb(q);
}
}
vc<T> dp(N + 1);
FOR(M, N) {
auto& I = IDS[M];
if (I.empty()) continue;
int min_a = M, max_b = M;
for (int q: I) {
auto [a, b] = query[q];
min_a = min(min_a, a), max_b = max(max_b, b);
}
// 累積積の計算
dp[M] = Mono::unit();
for (int i = M; i > min_a; --i) dp[i - 1] = Mono::op(A[i - 1], dp[i]);
for (int i = M; i < max_b; ++i) dp[i + 1] = Mono::op(dp[i], A[i]);
// 答の計算
for (int q: I) {
auto [a, b] = query[q];
f(q, dp[a], dp[b]);
// ANS[q] = Mono::op(dp[a], dp[b]);
// T ans = Mono::op(dp[a], dp[b]);
// f(q, ans);
}
}
return;
}
void solve() {
LL(N, Q);
STR(S);
vc<pair<int, int>> query(Q);
vc<pair<int, int>> LR(Q);
FOR(q, Q) {
INT(op, l, r, k);
query[q] = {op, k};
LR[q] = {l - 1, r};
}
vc<mint> ANS(Q);
vc<T> dat(N);
FOR(i, N) {
ARR A{};
if (S[i] == '(') {
A[0][1][0][0] = 1;
A[0][1][1][0] = i;
} else {
A[1][1][0][0] = 1;
A[1][1][0][1] = i;
}
dat[i] = {1, A};
}
auto f = [&](int q, T& LL, T& RR) -> void {
auto [op, k] = query[q];
auto [l, r] = LR[q];
auto& L = LL.arr;
auto& R = RR.arr;
array<array<mint, 2>, 2> f{};
FOR(i, 2) FOR(j, 2) {
f[i][j] += L[0][2 * k][i][j];
f[i][j] += R[0][2 * k][i][j];
}
FOR(n, 2 * k + 1) {
FOR(i, 2) FOR(j, 2) { f[i][j] += L[0][n][i][0] * R[n % 2][2 * k - n][0][j]; }
}
if (op == 1) { ANS[q] = f[0][0]; }
if (op == 2) {
// (i-l+1)(r-j) の sum
mint ans = 0;
ans += mint(1 - l) * mint(r) * f[0][0];
ans += mint(r) * f[1][0];
ans += mint(l - 1) * f[0][1];
ans -= f[1][1];
ANS[q] = ans;
}
};
static_monoid_products<Mono, T>(dat, LR, f);
for (auto& x: ANS) print(x);
}
signed main() {
solve();
return 0;
}
这程序好像有点Bug,我给组数据试试?
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3952kb
input:
5 20 (()() 1 1 2 1 1 1 3 1 1 1 4 1 1 1 5 1 1 2 3 1 1 2 4 1 1 2 5 1 1 3 4 1 1 3 5 1 1 4 5 1 2 1 3 1 2 1 4 1 2 1 5 1 2 2 3 1 2 2 4 1 2 2 5 1 2 3 5 1 2 4 5 1 1 1 5 2 2 1 5 2
output:
0 2 2 5 1 1 3 0 1 1 3 6 16 1 2 7 2 1 2 3
result:
ok 20 lines
Test #2:
score: 0
Accepted
time: 1715ms
memory: 287184kb
input:
100000 1000000 )())))))())()()()(())))()())))()))))())))))()(()()))()()))((()()))()))((())(())())()(()))))()))(()()()()()(())(()((()))()((()(()))()))()))()()))(())))()()(()(()())())((()((()((())()(()()))())(())())())))))))((())(((()(())())))(()(((())())))(((((((((()))()())())(()))(())()()()()((()())...
output:
807252937 333653009 306141773 122104482 597950507 715981381 182568448 487609661 392529556 736028324 426329153 66499770 315566541 444655931 76394527 216715407 398566026 988659878 2314391 302716489 498728925 1522883 142406094 78253278 415123885 851121113 605305965 166689862 340780822 88059318 71955647...
result:
ok 1000000 lines
Test #3:
score: 0
Accepted
time: 1713ms
memory: 287008kb
input:
100000 999999 )())()(()(()((()()((()))(()(()))()()(()()()))(())((())((((((()(()())()()())))())(()))(()()))())()))))()))(()(()))())))()))()()(())())(((((()(()()()))()(()))))))))()()))))((((()(((()))()(()))()))())(()())()((()((())()(()))()()))))((()))()()))(())))(()(((()))()(())((()))((((()()))(((()()...
output:
402892502 214899834 938727581 781653349 160260859 758544879 262745296 720834204 42963048 271586310 748943367 986678723 639328165 134613336 159371260 82874562 394258522 394494705 375828102 322739707 424538145 872892447 823697884 421610557 435534073 183003865 89151 404251848 929670889 472715017 540589...
result:
ok 999999 lines
Test #4:
score: 0
Accepted
time: 1747ms
memory: 286840kb
input:
100000 999998 ())))))())((())(()()())()()((())))))))))()()((()()((()(()))((()(((()))(()))())())())(((()()))((()(()(((((()()((()))))())(())()(((()())))())((((((()((()()()())()())((()))()(()()(((())())()((())()())((())())())(((())(()(()()(((((())(()()()(()(()()(((()))()))()(())()((())()))(()))((((()((...
output:
589229850 378806717 17189272 513276973 388903354 15573206 337379415 614933739 77226868 105381650 334474125 708194095 799793957 996966343 193875984 993256553 385654388 962841214 401988000 545654424 861430641 627803113 970629869 733668058 669372341 833738960 712133526 521177172 620897050 954053422 589...
result:
ok 999998 lines
Test #5:
score: 0
Accepted
time: 1740ms
memory: 287052kb
input:
100000 999997 ())()()(())(((())()))(()((()(()(((())()()))((())(((()((()((()))())))())((((()()))(())()()()(())())())())((()))(()()((())())(()()(()((()))(()()))((())((())(()(())()())(()()))))(()(()()()()()((((())))())())))())))())))()(()))(())())(((())()((()))()()))((()((())((()((()))(()(((()(())(((()...
output:
972103869 52815583 36975538 942807277 779268350 977998879 149474048 840689805 503320767 512029745 505343452 941598898 273344794 105844826 332335082 414924128 145736306 983675151 89768735 596025627 391441398 288920154 960536974 575695663 191946534 580871002 603188776 186595863 165215181 790746245 241...
result:
ok 999997 lines
Test #6:
score: 0
Accepted
time: 1744ms
memory: 287316kb
input:
100000 999996 (((())((())(())()()()()))))()()()(()))(((((())))((())(()()))((()(((())(()()(()(((((()()))))()((()(())((()((((())(())()())))(()()(()(())((())(((()()((((()()()(())((())()))())()()))())())(()())())))())((((()))(()(((((()))(())()()()(()()()(()()(((((()((()((())))()()((()))()()()))()))(()((...
output:
317161983 595949056 93798841 524173880 601024390 669989639 154565155 575792568 818268157 136111605 991333266 847150012 378409369 986282953 421020590 850559979 52073347 114271781 604334659 640229118 422909999 338488062 188413609 249844111 508809849 841591327 736530361 633843714 910519360 93611125 438...
result:
ok 999996 lines
Test #7:
score: 0
Accepted
time: 1757ms
memory: 287296kb
input:
100000 999995 ((()(()()(())(()(())(()(()()))))(()))(()(()(()()()))((())(()))))(()(()))(()((()(()((()))(())))))(((((()))())(()(())(()(()()())()(()(()(())(((())(())(((()()()((((())(()()(((()(()()()()()((())))(((((())()))))(()))((()))(())(()))())(()((()(()()(()())))())()()))(()(()((())((((((())(((()(()...
output:
522986251 569857522 274182299 513438758 717505764 421686834 53987076 568056194 895421903 409740607 384742578 547379600 917225346 226046183 540069158 693176898 872736218 480008750 784434959 565264237 108353532 240021450 192461252 913279468 858826389 644800105 686176588 679893374 125293854 880296601 9...
result:
ok 999995 lines
Test #8:
score: 0
Accepted
time: 1760ms
memory: 287232kb
input:
100000 999994 ((()()(()(())()((()())())))())()))((())())())(()(())))((())))(()))(())()))()()(()))()))((())((()()(()((((((())()((())()((()())(()))))(())())()())((()()(()((()(()(()()(()(((((())))(((())))(((()())((()((()))())))((((()((()(())((()))(())())))))))()()()(((((((())(())((())(()()())))(((())((...
output:
709462644 396817881 137835135 786481501 482648338 170987524 456365562 712191537 239164779 389178600 734780032 479377227 165090710 41756916 321221179 771215898 926413608 569103977 524522976 97615191 405047326 38121098 859499980 26981688 80728061 577378887 433625701 216351140 717326221 733535172 99004...
result:
ok 999994 lines
Test #9:
score: 0
Accepted
time: 1799ms
memory: 287156kb
input:
100000 999993 ()))))((((()))()())()))(()()()()())((()(())))())(())())()(()()))(())()()))()(()()))(())(())())()((((()))(()))((((((()()())(()()())))))((()((())()((((()((()(()(()(())(())))())())))(())())())()()))()()))(((((()())()))()())))()(()())(()(())(()()))))((()()()()())()))((())(())(((((())(())()...
output:
303668929 974632172 451994144 610836867 1984949 719122494 255048439 74974220 628335345 272652880 197468757 742800871 694990784 172726383 699008774 503390330 124089042 998148518 162322523 590959972 980070839 598551221 314696442 127173156 143487394 261157404 855529500 692017893 858244732 690083743 896...
result:
ok 999993 lines
Test #10:
score: 0
Accepted
time: 1552ms
memory: 235076kb
input:
80000 1000000 ((())()))))))())()))))(((()))())(())())(()(()))()((()))()())))()))((((((()())(((())))(((()(())))()())))))))(()()((()(()()))())))))())())(())))(())((()(()))(()((((())((()(()))))(()))()))(()()))(()(()()()))))))()(((()()(()))))())))(())())()()))()()()))((()()((((((((((())()()()()()((())()...
output:
242158424 769842958 166231335 414175913 60222069 71454069 794731041 236021415 574889590 930558392 62517841 914733810 730716408 393954443 557161598 926048299 104871994 315664325 620578684 107913720 168165664 492092460 748240258 399366923 14509070 254712527 343615757 287284529 445684682 867199538 2381...
result:
ok 1000000 lines
Test #11:
score: 0
Accepted
time: 1532ms
memory: 235240kb
input:
80000 999999 ()()()((())))(()()()()()((())())))(())))()()(())())(())()))((())((((()((((()((())()))(()(((()))()))))()()())))(()()()))()((((())())(((())(())))((((())()())))()((()))(((()))(()))(()(()(((()))())((((((())())))()()((()))()())(((((()(())()())(((((()(((()())(()())()(()()((((())(()())()))))))...
output:
88923853 385096733 662143582 819894249 451073552 983649758 244046844 730334262 865952018 680003393 96837936 268466573 156372357 396598440 466557930 493985169 414061112 112940857 778042483 29187063 590044837 924190539 977340920 243895972 934200816 721169551 213927757 488522990 828944132 138669579 830...
result:
ok 999999 lines
Test #12:
score: 0
Accepted
time: 1535ms
memory: 235132kb
input:
80000 999998 ()(()()((()())((()((()(()))()()(()(((((()()())))(()()))()(()))())))()))()(()()))(())(()(()(()()()())((()((((()()))))()()()(((())())(()()()(()(()(())()()(()()()()())((()())(()(()(()()()(())(()(()((((()(((()(()(((((((((((((()()))()(())((()(((())))))))()())(())(((()(()(()())(()(()))()())()...
output:
38218570 142309639 223333620 417179594 707107546 445214235 859777455 156299343 409734786 520071865 16939171 878995903 612338202 204757897 589666236 964340636 780163007 537685182 96100921 24799274 929271438 526867242 365908063 477991147 862718929 794499060 533363805 554006248 629604264 645875233 7842...
result:
ok 999998 lines
Test #13:
score: 0
Accepted
time: 1555ms
memory: 235208kb
input:
80000 999997 (((()))()((())))))(())))()()(()()()(()(()((())()(((()())()))(()))(()()()(()))(()(()))))(()()()(()))))()(((()(()()))((())())((()))()((((()()))()))))(())())(()()()(()()))(((((((())()())((()())(()()))((((()()()))((((()))))))((()((())(())(()))))))((())((())(())))()(()())()((()(()((()()(())(...
output:
28377171 427775956 24130295 68193145 742833230 225727222 646889739 82039456 487507470 789942643 356592513 786270620 403047505 997509337 943240016 972942972 540328021 416806996 509576299 934719563 720010201 286429562 565995753 26909049 696336947 458465377 467540778 93739018 490963206 536139604 643900...
result:
ok 999997 lines
Test #14:
score: 0
Accepted
time: 1555ms
memory: 235288kb
input:
80000 999996 (()()((((((()((()(()((())))(()))(((((())()))((()()(((()))(()()()()))))))))()))))))((())))(())()))))(((())()()))))())())))()((()()()()()))((())((()())))()()())((())()()(()(())))())(((()((()()))))))))()()())(()(()()(((()))(()(()()))((((((())))(()())))((())))(()())()()(()()((((()))())())((...
output:
686242650 891003449 378893279 709771493 567723040 10652832 90367287 796185368 901832677 372097881 933094678 519292858 142323419 643786964 989599895 977576408 885379735 92630918 314230829 552560910 253625040 560141368 573866015 230300191 460241092 313426415 852045144 443870846 477274583 29650470 3556...
result:
ok 999996 lines
Test #15:
score: 0
Accepted
time: 1567ms
memory: 235320kb
input:
80000 999995 (())())(((()()))((((((((()))()())())())())())())(((()())())))())))()()()))())(()()(()))())((()()(()()))()(()((()(()())(()())))(()())))))())()())())((()()))())(())(()(()())))())(()(()))((())()(((()))(())))())((((())(())(())((())))(((()()(((())(((((()()))))()(((())(()(()((()()))))())((()(...
output:
138481795 704868144 51675996 765731428 925578706 123957081 667160555 274707415 656451455 492091860 321894004 762289465 5788363 598870180 732409607 437361746 491450171 620340444 614663780 512063470 993921865 416922367 515680182 179426373 5314167 672651799 286975919 488780276 924956593 1016092 6791024...
result:
ok 999995 lines
Test #16:
score: 0
Accepted
time: 1586ms
memory: 235044kb
input:
80000 999994 ()()(((())))((()(()))()))((())()()())()((()((())()()())()(()(()((())))((())())))()((())()))((())())(()())()(((((())()(((()))))(()(())()()(())((()))((()()(((()(())((()))(())()()())((((()))(((((((()(()))(((()(()()()))))(((())()()))(()(())))((())))(((()(()()))()()(()()))(())(((()(()()()(((...
output:
6533743 989330207 241331094 819548997 17522465 821617709 25848383 59919114 13405516 281796939 960664573 470182299 139485073 537588770 829549661 550666309 784962419 390188790 234639988 268111827 874720826 152655343 977363189 687878975 492289023 511342702 781431769 925267731 343335369 629914768 898184...
result:
ok 999994 lines
Test #17:
score: 0
Accepted
time: 1561ms
memory: 235008kb
input:
80000 999993 ()(()(()))))())((()))((((()))((())())(()((((()()())))))()))(()(()))(())())(()((()))())))(())))()())()))(()))))()(())(()((())))()()()()((())()))(()())((((()(()((())((()((((((((()))(((()))()))))))))(()())))()))((((()(((()()()())(())())))))())(()()))())()())((()(((((()))()())()))())()))(((...
output:
800970710 505182329 29346401 112557992 868132180 792292011 983045434 744617930 359123358 610050421 932162581 535655226 903936665 986865248 829418062 613041729 128943395 47905663 88336118 172522243 413625758 282695633 705813695 740726617 292943226 881811618 948573520 320179160 860397991 233443673 513...
result:
ok 999993 lines
Test #18:
score: 0
Accepted
time: 1295ms
memory: 183832kb
input:
60000 1000000 ())))(())()))))()))))))((((()()()(())())((())((()((()()))(()))()))))))(((()(()(()(()()((()(())))((())((((()((()()())(())()(()())()()(())(()())()((()())()(())(()(()(()()()))()))(((()(((())(((()()()(()))()))(())))()((())(())(((()(()((()(((()((())()((((()()))((()(((()(())(((())))((()))))(...
output:
355025021 953307950 95424051 321294307 888255421 701486250 227697299 797029900 752912937 470346553 846331579 940146170 359816389 484866444 816152996 951762198 422166103 471959360 897070803 989945972 431258497 911211692 328340563 337358064 403824113 766879572 505023892 991640066 5414936 823172974 850...
result:
ok 1000000 lines
Test #19:
score: 0
Accepted
time: 1311ms
memory: 183656kb
input:
60000 999999 )())((()))(()((((()()()()(()()(())))))))))(()))(()(()())())()(()(()((()()((()))(()(()))()()(()()()))(())((())((((((()(()())()()())))())(()))(()()))())()))))()))(()(()))())))()))()()(())())(((((()(()()()))()(()))))))))()()))))((((()(((()))()(()))()))())(()())()((()((())()(()))()()))))(((...
output:
570283995 877785621 721974460 373295838 689241408 494831334 522315782 838570583 899462239 197224108 185385108 267204854 442686416 706046568 486444565 757373429 67742641 859254178 97046842 261817498 329049068 276398094 863472259 566435058 679460179 212048864 499459405 25337123 586897601 478612252 304...
result:
ok 999999 lines
Test #20:
score: 0
Accepted
time: 1308ms
memory: 183868kb
input:
60000 999998 )())())))))())))(())(())(()(((((((())()((()(()((((()(()()(((()))()()(((((()()(((((()())()))()())()))(((()()())))()()()))())())(()(()(()))(((((()((()()()))))(()))((()()((())())()()()()((()())))()())()(()((()((()())((((())()())))())))))())(())))(()))()((()(())())()((())(((())(((()(())(()(...
output:
996394133 489926235 523318773 19701772 319155291 535965250 814949764 868568912 454517007 232744048 162922656 334459955 737735334 788881453 14834141 899723388 523950304 380664969 172075884 139183857 39771269 158806569 267232849 244423672 491356597 123766461 947799257 610565049 750601553 236423679 561...
result:
ok 999998 lines
Test #21:
score: 0
Accepted
time: 1275ms
memory: 183800kb
input:
60000 999997 )((()())())))((()))(()(()(()((()(()))(((((())(((())))))(())()(()))())((()()()))()(()))))())))))()()))(())())()))()((())()()())())(())()))))(()))(((())(()(()(((())))))(())(((()()))())()((((()())(())())(()))())))))(())))()))(((()))))))))))()())()((()))()((()()))()(((())(())()))(()((((((()...
output:
343818130 791287084 160957103 263150051 862732458 682850203 411374111 652082767 929084402 620236206 787077686 992889239 907486883 80786965 74845078 876338573 378539791 246771125 833884812 47824633 837515865 319722508 636899468 94577181 707738818 676504794 294762812 609260590 9209443 135018120 229704...
result:
ok 999997 lines
Test #22:
score: 0
Accepted
time: 1300ms
memory: 183288kb
input:
60000 999996 ))(()(()()))(()))))))))((()()())))(())()))))(()((())())))(()()))(())(())((())((()())()()(())(((()))(())()((()(((((())((()())))()(((())((()()(((()()()))())))((((()))()))))(())(())(()()(((())()(())))()())())(()()()((((()()(()(((())()))())())()(((()((())(((((((()))()((()((()))((()())(()())...
output:
944583689 191858266 104645441 494825628 225017100 466666333 473995372 400320533 536446750 985659258 992452462 161022952 264588504 826680881 754513989 303080715 753224743 897655188 762490499 523161412 876995669 762849001 549797526 343981519 352625685 948447437 245812407 739489907 190501964 991521072 ...
result:
ok 999996 lines
Test #23:
score: 0
Accepted
time: 1278ms
memory: 183788kb
input:
60000 999995 ))((())))(()()(()))))))))))))()(())((()(()()(()((())()))()))()(())(()(()())))))((())))((()(()))()))())()(())))()))(()(((()))))()(((()(())()((())(())())((())()((()())()()()()(()(((()(()(()((()(()))()))))(()())()))())))()()((())())(((()))((()(()))(((((()()(()()))))((())(())())))))))((((()...
output:
236435057 238288870 344769979 237634425 179725009 84494536 50741735 495033060 180221093 663543703 441840805 764851604 308854226 316254197 226035242 580258131 434094013 304394927 344185570 493031167 270680931 242001477 253235181 214869960 587055600 775186744 430913863 772429557 138565618 976694269 35...
result:
ok 999995 lines
Test #24:
score: 0
Accepted
time: 1266ms
memory: 183632kb
input:
60000 999994 )())((())((((())()((()((()(()))()))(())()()()))(())))()))(())(((())((())))))(((()())(((()((((((()()(())(((((())())()))))((()()((()((()()()()()()(((()))(()()))(())))))(())))()))()(())(((()())())(()())()())))(())())))((()(())()()())(((())((()())()()()(((((())())(((((())(((()))()()(((()())...
output:
645485721 889226298 994624067 207798731 995747083 288838471 932090697 776848617 114307403 326029708 403511050 704045947 594576219 639533604 600122059 767669294 891395049 777694068 710475917 194993009 464942024 932836507 781548079 413375593 692547203 372647576 481347067 616353 132824353 691844396 535...
result:
ok 999994 lines
Test #25:
score: 0
Accepted
time: 1298ms
memory: 183768kb
input:
60000 999993 )())))()(()(()((((()(())))))())(((((((()((((()(((((((()())))())()((()(((()()())()(())(())(()()))())())())(()(()))(()())))(()()(())(((()((((((()()())()(((()())(((()(()()))))(())()(()())((()())())()(())((())))(()))))(((((())((())())((()(())()))()))))(())()(((((()(()((())()(()())(((((()(()...
output:
231292099 771892982 588218495 7487080 319869391 266100362 146313822 273461657 432221486 898305687 680062005 318663475 237118313 301120028 391629719 614046196 669051701 520452455 149173202 258715907 834095984 597096445 538018682 35830239 613774579 44612168 924392428 686793911 399727013 669627209 8284...
result:
ok 999993 lines
Test #26:
score: 0
Accepted
time: 1025ms
memory: 131264kb
input:
40000 1000000 (()(()())(()(((())(()()()()())))())(()(((()))())(((((())))()()()(((())(())))()()()()))())()(()))(((())((((((()()))(()))))(((()(()())((()))())()((()(())()(())))()(())((())((()()(((((()()()))()(((())())(())))()))())())((()())())((())))())(()()()(())(())))))()(((()(()(())()))())(((())()((...
output:
123520759 633627186 11352476 870959481 781188247 911329282 650687069 367758195 42570171 305752633 425026203 609800561 84854693 309943806 489328464 463050269 617602625 809963716 520709886 251143792 876747884 720763839 40379079 15464171 254098363 76380199 661835694 234882517 884986455 208648888 0 6802...
result:
ok 1000000 lines
Test #27:
score: 0
Accepted
time: 1004ms
memory: 131276kb
input:
40000 999999 ((((()())(())()))(((()()()()()))(()((())()(()))))())()))(()))()))))))))((())))((()((((((((())()(((()((()))))())))()()()(())(()(((((()(())()((()(()()(()))())))))((()()(()((()(()((())))())))))()((())))(()(())()))((()(()(()(())((((()))(())))()((()(())()())()())(()()()(()()()))()()))(())())...
output:
681629849 38188035 16627600 606391623 367818870 462342400 697853972 33771994 706328418 940527520 891128696 353268445 818723064 25376164 586325911 767559591 969784672 893007945 797667669 66035845 58927003 828275402 802655608 741821160 32496112 257136428 59386114 12306670 52538820 371082043 925231291 ...
result:
ok 999999 lines
Test #28:
score: 0
Accepted
time: 966ms
memory: 131616kb
input:
40000 999998 ))))()))((()))((((()))(())))()())(((())()))(((())()()))()))(()()((()()(()()))))()))()(()))((()()()())()())(()()())))(()()())()(((((())(())()()(())(()(())()))(()()(((()())))()()((())(()))(((()())))))))()))())((()()(()()()))()()()())(()))))(())((()())((()))))))((()))())))))())(((()(()((((...
output:
110521915 151117508 671898241 624307432 12243368 661706383 748308044 416957985 244385843 91572681 699960833 671576686 139706964 437349336 398020609 261651013 38192979 447822595 117189002 730220591 80525214 582123327 84740382 519699169 381116426 619088415 167971470 550775914 330013892 803805536 57260...
result:
ok 999998 lines
Test #29:
score: 0
Accepted
time: 938ms
memory: 131452kb
input:
40000 999997 )))))())(())(())((())())()(())()()))((((((()((()))(((()((((((()))))))))(((((((())))()(()))(()())(((()(()()()((())))(()())(()()((((()))()(((((())())))(((()())(())))()())))))(()())())))()(())((()(())))()(()(((()((()())))))()))))))(()()(())((())))(((((())))))()(())(()(()))(())()(()()((())(...
output:
984671131 2179286 861909683 768972034 266831652 686288501 888988576 46873294 143415113 512172840 813465898 579582391 594994622 846433811 705411412 198581701 9045696 51844874 153422603 957209064 623418943 435032209 56005685 741237527 552079247 860903041 379468324 299801479 776267811 96053805 72487038...
result:
ok 999997 lines
Test #30:
score: 0
Accepted
time: 943ms
memory: 131164kb
input:
40000 999996 )())))())))((((()((((((()()))((())))))()(()))()))((()()()))()(()()((()())()(()))()(((((()(()))()((((())(())(()(()())))()()()()()))())())))))((((()(((((((()))(()()(())(()(((())())()))())())()))((()(()))()((()))()()((((()())())()))()))(((()))(()())(()((()()(((((())()(())))(())(())()(())((...
output:
605039528 19322951 613455982 817733448 968102288 335301588 672478744 579204911 606647803 834623655 851473428 641735170 880164927 53917593 338924630 472709427 888111210 793213421 405783113 476083537 452677602 554814940 947301818 18105285 203245207 735684255 970007929 66665938 778672408 539040900 2704...
result:
ok 999996 lines
Test #31:
score: 0
Accepted
time: 955ms
memory: 131316kb
input:
40000 999995 )((((()))))(()))))()(((((()((((()(())((())((()))))(((())((((())()()()))))))(((()))(()(((()))((()))(())()))())()))))()())()()((()))))())(()()()))))())))(()))))()()(((((())(()(())())(()()()())()))))((((()((((()((((())))(((((()()(())))))((()))((())()())())))))()()()))())))(())()()()(((())(...
output:
152190361 23030052 3657990 122161278 528590485 89934696 15977964 927664339 877692256 90648095 0 753945896 682814671 282551268 669587063 165370501 545529475 257072394 331145110 71379024 146072854 982205322 23407453 64659963 972970926 267837855 437504961 466157503 377822869 239670529 929903025 3063794...
result:
ok 999995 lines
Test #32:
score: 0
Accepted
time: 1001ms
memory: 131388kb
input:
40000 999994 )(((()))()((((((())()()))(()((()(()))))(())(()())))(()))()))(()(()(())))()((()))))()(())(()()))()(((())()))())))())))()))(()(())))))(())(()())()())()))(((()))())())(()))))())()()))())))((((((()())()()(())())))()(()(((((()()((((())))(((((((())(()())())()(()((()(((()(()))))())((())((())((...
output:
411352290 538603263 68745267 412852315 383441464 888505150 58304637 315036530 688771140 693143835 583744904 892495082 570384659 273485452 405503356 217937054 603998865 930002021 835597016 813464563 24128632 407744122 540752246 807019115 456459744 622455552 925093780 563254539 254482714 124734705 804...
result:
ok 999994 lines
Test #33:
score: 0
Accepted
time: 988ms
memory: 131332kb
input:
40000 999993 ))(())()((()))))()))))(((()(((())(()(()))(())(())()))))))(()))(((())()(())))((()(()))())(()((((()())))))(())()(((()(()(())(()()()))(((()))())()(()()())())))()(()(())))()())((()()))(((()(())()(()((()((((((()(((()(()))))))(((()))()()(()(())(())))()()))(())((((()(()))(()()()))())()((((())(...
output:
298464494 1230478 871625630 141689824 333034148 543077536 621660563 103240668 715355209 761398549 493381889 539702645 801587663 597985982 785492535 393582643 882866737 618167454 989317128 63539383 125539080 719699899 515480445 768035246 243851658 412166784 101964803 428356065 49873845 227280101 1035...
result:
ok 999993 lines
Test #34:
score: 0
Accepted
time: 637ms
memory: 79320kb
input:
20000 1000000 ()()))))))((()()))(())(((())())(()(())))((((()))))((()))())(()(()(()()())))(()())()((()))(((((()()(()())(()((()((()())())())()())))))())))())()(())(()())))((())((((()()(()(()()((())(((())()))()())((())()))))()((((())()))))((()()((((()((()))))((())()()()(())(()()((((((((((())(((()((((()...
output:
180985558 775891998 338881436 387611445 475538891 637650615 350197439 148637487 925753877 319975760 810107228 490116328 303621670 975371772 384946739 423080584 994085445 219694024 853700704 740462738 614683284 952695499 56334107 196289623 67491877 680003391 555547600 328920552 602293740 99408434 475...
result:
ok 1000000 lines
Test #35:
score: 0
Accepted
time: 659ms
memory: 79384kb
input:
20000 999999 ()((()()())))(())))()()()((()()))))))(())((((()()((((())()()((()))()((()))))((())())()()(())()(()(()(())()((((()((()()))((()()()(())))))))(()))()())(())))()()()()()))))()(()())(())()()()))(((()(())(())((())())())()(()))))()))())((()(((()()()(()((()))())((())))(()()))))()()(()(()((())))(...
output:
758090546 377316836 399779306 232803199 945526601 877694765 172656250 549795370 660348663 146465646 854025383 812515420 232622199 327628098 572421039 76993332 589004513 818992452 267929242 995428666 913268085 592043623 934238226 244420693 38898320 52628934 515921071 843204318 858576179 930583630 384...
result:
ok 999999 lines
Test #36:
score: 0
Accepted
time: 674ms
memory: 79376kb
input:
20000 999998 ()(((())()((())(())(()))(()))()(()()())(())))((())(()()))())))))(()))()(((()())))(()))()())))()()((()(((()))))((()((((())(())(())()())))(()())(((()()(()(())()()()))))()())())))(()((()(()(()())))()))(())))))))((()()))()))((()))()(())()(())())()(()((())())()()())))()))()((((((((()(())()))...
output:
957037814 531166787 443280446 318052314 436550580 581556681 3151734 958740851 17916269 103929368 585038489 375697989 770630002 403292247 346830866 386982235 618238035 267534448 791962662 341896944 919340195 334091012 4119298 922109212 448589967 733918126 414828261 111950457 621761844 461781575 27504...
result:
ok 999998 lines
Test #37:
score: 0
Accepted
time: 681ms
memory: 79404kb
input:
20000 999997 (((()))))(((((()(())()(()((()))())(((()())()(((()()))))(()((((())((((()()())((()((()())((()(()((()(((()))))()())((((((()()())()()))((()())())()))(()((((((()((()))))(((((())((((())(((()()))()()()))()())()()((())))(((())())())()()()))(((())()())))()())()))((()()()()))(((()))())()())))))()...
output:
634729966 931769016 716123247 104184149 852144781 457297947 962215361 415615007 203563171 754738672 317565282 444659224 387578379 373750898 200483329 312358077 329866419 697807575 822424876 95889010 769946900 771432685 652061810 955193460 844774559 911857468 144192023 322023305 218950232 471887319 3...
result:
ok 999997 lines
Test #38:
score: 0
Accepted
time: 689ms
memory: 79512kb
input:
20000 999996 (()))(()((((())))()())))()))())((()(()()(()(())()())())()()((()(())()((()())())))((()))()((()()(((((()(())()(())((())))(()())()()))(()()(()())(((()(((((()()((()))()()))()()()(()))(())(())))))(((()()(((((()()())(()(()((((()()(()(())()))((()(()(()))())(((()()()))))()))(((()((((()))))())))...
output:
32864463 874805430 846421324 856825954 66101548 50238757 921291639 222963582 747568910 207316248 31792 784593515 710690103 584444480 429485364 672261291 91584452 623314619 310861415 512297957 606441625 478844343 947053051 375572190 224597050 756948449 126956046 809567498 217535452 491897386 69111956...
result:
ok 999996 lines
Test #39:
score: 0
Accepted
time: 719ms
memory: 79460kb
input:
20000 999995 ()))(())(())()(()())))())))(())))((((((((((()))()))))))())(())(()((((())()((((())))(()))))()))()()(())))())(())(()(()))()()()())())(((()((()))))(()))()((())((()(()())))()())()()()((())(((((((())()((()())))(()())()()()()()))))))((()()))(())(((())())(()(())))((((()))))((()))())(()(()(()()...
output:
396634833 171780985 372069024 146579698 639319048 265502672 229013686 46724791 176963205 665014409 448973572 86778066 259621678 753539264 758567811 487186476 87148 434863553 619780968 970444608 65619828 406297319 87315950 790123394 908536728 702078662 669410010 130011372 637160448 940259008 21957713...
result:
ok 999995 lines
Test #40:
score: 0
Accepted
time: 718ms
memory: 79248kb
input:
20000 999994 ()))())))))))())(())((((()()(())(()()))()))((((()(()(())(()((((()()))(()))(((()(())()))))(()(())()()()((()())(()((()(((()))()())()))))(()))()()))((((()())()()())()()((((()())))))((()((((()))()(()()(((()(()))))))())((()()((())((((()))()(()(()))(()())(()(()((((()(()))((((((((((((((()()())...
output:
404206336 611084012 752387675 338995840 698752513 112253554 917722972 245549272 319970112 192258082 510068584 306788693 600868889 155396885 717574898 524146366 920415055 202429903 573814008 206252727 394151496 396968659 253677041 731488955 405916570 589236136 170571622 945509037 431243834 453090787 ...
result:
ok 999994 lines
Test #41:
score: 0
Accepted
time: 707ms
memory: 79360kb
input:
20000 999993 ()(()(()))()))(((((((()))()()(((()(()())()()(((()(()(())))((())(()))(())())())((())()))((((()))))(()))))()(((((()((((()(())((())((()))))(((())((((())()()()))))))(((()))(()(((()))((()))(())()))())()))))()())()()((()))))())(()()()))))())))(()))))()()(((((())(()(())())(()()()())()))))(((((...
output:
792129938 44527136 143828678 490331776 432187138 412442304 658899951 45517972 771915705 117483658 29306839 19077514 399600724 606778360 820899704 155530653 352650510 469533239 343337146 856340379 454851134 234322450 532135944 608088395 812174906 413806333 341876169 715062501 396971697 23704594 27769...
result:
ok 999993 lines
Test #42:
score: 0
Accepted
time: 357ms
memory: 40628kb
input:
5000 1000000 ()))())(((())()(())()()(())()))(())()()(())())))()()()()()(())))()((()(()()((()())))()()(()))(()))()()(())))()))()((())())(()()(()(()(()))()))(((((((()))()()(((()(()())()()(((()(()(())))((())(()))(())())())((())()))((((()))))(()))))()(((((()((((()(())((())((()))))(((())((((())()()()))))...
output:
863866147 0 986743306 448089409 415730302 103415571 583365848 360528068 580477275 116714441 51738 0 208659757 838040866 964622385 24190814 360777188 707791094 991336 248174259 981480284 200666208 549554494 716712752 553374957 23086731 593607965 991180210 435240485 863366430 110592 907574437 83469 84...
result:
ok 1000000 lines
Test #43:
score: 0
Accepted
time: 359ms
memory: 40816kb
input:
5000 999999 ()()()))(((((())())()(((((()))(((((()(()((()()())())()((())))((())()((((())((()((((()()(()()(()(()(()))()))()(()(((()(()((()))()))()(()(())))((())((()()((())))(())))()(((()))()())(())(()((()()()(())((((()(()()))(()()(((((()(()()()())(((()()(((()((((()(((((()())()((()()((()))()((()((()))(...
output:
127335815 244014815 449993532 147050453 203343865 668279116 703226953 386459427 210614975 404908305 5723851 431353583 852228507 390364973 237166848 17429599 99011959 80612093 880537983 194126222 698889339 324705446 186567404 585390949 465280 764638702 901507493 447939780 556764038 872087685 50819152...
result:
ok 999999 lines
Test #44:
score: 0
Accepted
time: 362ms
memory: 40456kb
input:
5000 999998 ()((((()(((())(()())(()))()(()())))(()((()))()()))))))(()(())()((()))()())((()(()(((((()(((())(())(())())))))))(()()))())()))))())()())))((()()())))))()())))))()(()((()()(()((())))()()(((()()()((()(()(())())())((())))))()))()()((((())((()))()()))(()(()()()()()))()(((()()(()())()))()))()(...
output:
732312011 375698302 2 702174723 755977378 296262404 789949096 7206600 929138428 483672674 178087249 473025910 661722381 591487505 109641761 285656379 882276675 875868601 226003899 241890560 374818595 549824397 291538363 308056358 208328224 854900057 264965776 773166009 885209882 473715024 867271569 ...
result:
ok 999998 lines
Test #45:
score: 0
Accepted
time: 359ms
memory: 40460kb
input:
5000 999997 (()((())))(()()))()(()))(())(())())((()())(()))))(((()()()))()))))()((()((()(()()()()(()()(((()()(((())()((((())()()())))))()))()(())))(()))))()())())()((())()()()(()(()))(())()(()(()()())(((()))))(((())(()()())()(((()))()()))(((((()()))()((()((((()()((((())))()()(()((())))(())()())())((...
output:
463035278 607637104 860407258 339150764 261963770 551594368 405890549 598859953 559240225 43140826 887360318 712075276 801040524 246108557 200008145 912691606 695652868 75285632 104947 795191748 907222780 625377588 2419835 36973455 392864599 996583465 872532365 140546250 397937580 89575842 88695448 ...
result:
ok 999997 lines
Test #46:
score: 0
Accepted
time: 370ms
memory: 40252kb
input:
5000 999996 (()())()))))))())())))(())())()())((()))(()((()))((()(()((())(()())))()))())()(((())(((()(()()()))()))()(())))((((((((((())(())((((()((((((()()())()()))((()(()((((()()()()((()()(()()())()())))((()()())(()()))))(()())))()))))((((()()()))))(()())()))()))((()((())()((()(((()()))))((())))(()...
output:
156410336 178454378 201177511 693216538 548307960 95018 155087803 855074502 55949211 596036530 396434546 637062879 565945557 493196728 681810004 895764280 537959879 378003570 559946848 681708788 285651421 832979899 46732773 250423973 240 206191469 561465251 669597327 801346658 896591039 248226006 39...
result:
ok 999996 lines
Test #47:
score: 0
Accepted
time: 361ms
memory: 40472kb
input:
5000 999995 (()))(()())))))((()())))())()()((()((((()(())(()))((((())))(())))((()())(()))()((()))((()()))(()))()())((((())()))()(((()()(()))(((())())()()(()()(())))))))(()))((()()))(()))()))()())()(((()((()()()(()())((()(()()()()(((((()()))()))(())()()))(()())))((()))((()((()(((((())))(()()())))()()...
output:
476338640 59355421 50759977 799217941 260681442 384635798 936968209 540596548 881486283 500734475 423448545 498286178 907802592 229584341 180283383 32978 734524275 814489363 877634970 798632389 225687438 187270489 20242997 787952917 970748066 438941126 418631380 103473118 525835812 48306937 70297204...
result:
ok 999995 lines
Test #48:
score: 0
Accepted
time: 351ms
memory: 40712kb
input:
5000 999994 ()()()))()()((()())(())())())))()(()))(())))))())(((((((((((((())))((((()(()))()))()((())))(()))((()))())(()(())))(()))()()((())(()(((((()()))))(())(()))(((()()))))()(())())(()((()((())(())((())))()))))(((()()(()()()(()()()))()))())()))(())()()))()()))(()()()))(()(()(((((())))(())))(((()...
output:
248294069 787192362 489378052 127631586 865849681 814325916 516178610 952379878 872258662 536050437 177616 776023689 253950095 375830809 237153500 71694556 92016943 267714348 359549086 460638958 850091940 35588645 598344332 96776371 3311019 364372064 105139 623151716 69170283 138889947 619185315 0 6...
result:
ok 999994 lines
Test #49:
score: 0
Accepted
time: 363ms
memory: 40664kb
input:
5000 999993 ()()((())(((())())))((()())(()))((()))))()((())))()())(()))())))(((()()(())()())))()(())(()()(()()()())()()(())()()))))(()(((()))))(())((((()((()((((((())((()()()()(()()()(())((())())()()((())(()))()(()))((((((()())())((((())(())()())()())((()()((((()(())))(()())((()((()())(())()()))()((...
output:
103730368 11833833 0 211275197 870346863 439755757 833895925 793543890 844902637 831010439 108843452 655334727 750515671 806198301 517373799 641421476 374797751 57116871 888218395 950524370 520631449 599402869 394033463 449714437 24732992 926494500 708964126 120597 996710964 640525472 559163818 2852...
result:
ok 999993 lines
Test #50:
score: 0
Accepted
time: 259ms
memory: 28912kb
input:
500 1000000 ())()()))())))())()()()((())(())())()))((((())()(((()(()())(((()))((())())))(()((())))))()))))(())(()())))()))(()))))(())))))((()()))(()(())(()))()(()(((()))(()()(())()()())(((()))))()))()()()(()()))))(()())((())()()())(())()(())))())((())(()()))((((()))((()()))()()()(())())()))))()((()(...
output:
0 503164092 0 929070134 282584425 594549 0 260592003 0 532920449 0 175076785 4809 141647500 472357802 0 994092277 52148717 351698236 97492092 0 75421812 974279727 796465423 3025302 433702300 17615029 62008900 0 6392681 0 275157091 2668 0 345135896 15021636 0 0 2183927 379903562 622249024 0 35435004 ...
result:
ok 1000000 lines
Test #51:
score: 0
Accepted
time: 261ms
memory: 28480kb
input:
500 999999 ()())())((()())))(((()((()(())()())()))()((()()())((()(()(()()))(())))()((((((()())((()(()(((()((((())(()(((()))()))))((())))((())((())))))(()()))((())))()())((())()())))((()))((()))())(())))))(((()(())))(()))(((()(((())(()((()()(()(((((()())))()()()))(()((())))()((()))))(())))())()))()((...
output:
567395003 50951326 9732 242384692 0 970755462 187513425 29406360 17280 99721502 168427441 489888550 250906035 808680865 65790075 0 797022130 7694775 538369191 0 0 101141452 0 0 299 512694279 0 697734202 644245478 1368032 671135595 470581496 116214762 28451107 0 704684271 711141090 0 0 616593685 0 84...
result:
ok 999999 lines
Test #52:
score: 0
Accepted
time: 247ms
memory: 28624kb
input:
500 999998 (((())))()()(((()(((()()))))))(()))()())())(()(()))())((())))()))())())()()(()))))())())((()()()()((())))(())()((()()))(()))))()))(()()(()()())(()))())))))()())((()()())()))(()()())()()(((((())))((((()(((()(((()((())))())(((())())()()(((()(())()(()()((())))(()(()(()))))())((()))((((()))((...
output:
0 853352928 474064366 0 44999610 205240114 664810966 0 783785016 290460338 879605178 0 929169853 316532712 349837298 55318437 829201542 743292093 0 818079199 733691398 300259806 722801959 930249122 46685619 789800316 44 480868684 690601115 573233378 684572315 208789391 36669998 208982055 515210835 0...
result:
ok 999998 lines
Test #53:
score: 0
Accepted
time: 254ms
memory: 28444kb
input:
500 999997 ((((((())))(())(((())))((((((((((((())(())()()(()())()())(((()((()(())(((())((()()())()))(())())(((())(((()())()(())(()))())))()()(()))((()(((()))(())())((()()))(()()(())))))(()(()))())()))()((()((())())(())()((()(((())(()())(()))()((()()()((())))))(()(((()()))()(()())))(((())(((((())()))...
output:
129103197 306301931 0 847170979 722027960 440895174 117908774 30336680 562416852 722264056 239634723 0 652528415 140 0 124352 420943777 311966786 0 337964961 211038004 47715120 958611313 130188791 0 649066348 2017 3931524 7503489 494919392 506322736 0 0 0 21810 0 762756020 573627630 898954061 932655...
result:
ok 999997 lines
Test #54:
score: 0
Accepted
time: 242ms
memory: 28408kb
input:
500 999996 (()(())))))())()()((()())((((((((()()((((()))))())))((()())((()((()(())()(()()))()))(()())((()()((((()))((()()((())(((())())))((()())(()))((()))))()((())))()())(()))())))(((()()(())()())))()(())(()()(()()()())()()(())()()))))(()(((()))))(())((((()((()((((((())((()()()()(()()()(())((())())...
output:
99024 385117599 14007939 13992 0 351574496 0 0 702988936 48097802 760920682 763047422 73780530 253665452 0 522589870 243279163 896359019 498757078 877234287 538386594 0 944985817 688828267 0 738654569 0 117 1529 818480378 116884038 419576385 682433499 703462248 0 965782468 702286278 0 16402248 70051...
result:
ok 999996 lines
Test #55:
score: 0
Accepted
time: 250ms
memory: 28776kb
input:
500 999995 ()))(())()(()()())()(())(())(()))(()()))((()(()()))))((()((())(()((())()))))(((()()))((((((()())))()))(((()((()()())))()()))()((((()()((((()()((())()(()(()())))((()))())(((())())())(()))(())()))(())))(())(())(((()))(((()()()()))(((()))))()())))()((((()()()()())))(()))()))((())))))(())(())...
output:
196437181 711719962 0 914289704 0 10855716 689704506 170690138 975019888 232049059 702479795 146067320 588580913 147276331 0 5056273 679701898 136957629 0 369753122 9597 3695040 642123259 0 2995 406486598 838613190 0 0 92007391 8215641 676932591 258504299 332740711 366403409 0 293890155 53524862 237...
result:
ok 999995 lines
Test #56:
score: 0
Accepted
time: 250ms
memory: 28676kb
input:
500 999994 ()))))()((()))()))(()()()((())))()))())()))((((()(()(((()))(())(()))()))()))())()())()()(())))())()))))))()))))))()))))(()((()(()())()(()))()()))))))())()()()))))((()(()))()(()())))))())))(()((()))))()((((((()()(()(())()(())((((()(()()))))()))((((())(((((())))())(()))()())()())((((()()(((...
output:
133349306 400670814 0 656178924 843261935 841970373 583418313 243395068 0 228381536 466169904 7 309690685 1685 406773337 433276934 0 590537141 838665146 295761890 98640799 0 18796631 684163685 20951682 464995950 544201780 469962380 11372 298645874 10415547 882591569 402207735 246223015 0 657751 1120...
result:
ok 999994 lines
Test #57:
score: 0
Accepted
time: 253ms
memory: 28648kb
input:
500 999993 ((())))))(())()())(()(()())))))())))((((()(())(())()))(((((((((()(()))))))()((((((()))()()))(((())))(((()((((((()))()((()(((())))())(()))(()))(()((((())()))()))())((())))))))()(()))(())))))(((()))(())))()(()(((((()))())))(()))((()()))))(())((()))))())(()(())))((()()()()))((())(((())((((((...
output:
212953715 180413908 213608708 545941476 820810037 52688530 46001526 975337787 2096 20958 525567885 149208815 733700381 0 773986823 599174852 4181765 0 778688047 0 364581011 425076646 681882034 792601590 74259235 277135264 53 465633373 787966130 592071489 0 499433684 824248091 681882539 485209587 0 7...
result:
ok 999993 lines
Test #58:
score: 0
Accepted
time: 261ms
memory: 27372kb
input:
100 1000000 ))()(((()((()(((())))())))))))())((())((((()(()()()())()))()((()(())))(())((())()()())())((()()))(() 1 53 96 4 2 10 33 4 1 83 97 12 1 28 89 12 2 7 85 5 2 54 63 16 1 9 97 8 2 12 28 7 1 46 66 16 2 67 68 4 1 9 47 17 1 44 86 6 1 21 27 14 1 56 94 20 2 14 61 16 1 61 92 17 1 85 92 9 2 89 92 4 2...
output:
789698 2304 0 744518346 505236994 0 416966274 0 0 0 0 10103852 0 0 0 0 0 0 406033108 273092200 7272 46808925 0 12026 0 292227696 0 8221020 0 0 0 0 0 0 0 411517657 91335681 0 0 181 0 7535507 0 9705034 27099601 0 6 0 355155776 0 0 0 95712 847014989 0 514959852 1486 753318 0 1659274 474 38180 101 15177...
result:
ok 1000000 lines
Test #59:
score: 0
Accepted
time: 254ms
memory: 27344kb
input:
100 999999 )((())()))((())((((()(((())((()())()((())))()((())(((((()()()(()()(()(((((()())()(())(())(((((((())) 1 24 55 4 2 77 90 20 1 49 58 12 1 33 91 19 2 50 53 3 1 8 21 18 2 11 57 10 2 23 34 1 2 83 86 13 2 21 53 13 1 23 34 19 1 29 97 8 2 62 70 11 1 45 86 6 2 40 69 11 2 14 40 17 2 66 76 16 1 45 66...
output:
21360 0 0 0 0 0 1244160 321 0 0 0 73210402 0 2056840 0 0 0 0 0 79626240 185 0 185894202 0 0 0 380671080 78708 0 88978 0 0 24 0 0 0 0 498074 0 0 2440704 106725170 17712112 0 0 0 0 0 201379222 12188 0 488262546 28 408 622508954 578327813 5201756 1656 0 0 10949184 0 0 0 619409843 0 0 473376 0 0 0 0 0 1...
result:
ok 999999 lines
Test #60:
score: 0
Accepted
time: 263ms
memory: 27188kb
input:
100 999998 )))(()()()(())())(((()))))()())()))())()()(((()()(())(()))((())))()((()))(()((((((()(())()())))((()) 2 19 81 13 2 24 87 17 1 70 83 11 1 9 37 18 1 85 89 3 2 10 36 4 2 21 89 14 2 7 79 15 2 41 51 16 1 98 100 4 1 12 93 4 2 19 59 1 1 48 52 5 1 11 52 18 2 28 81 1 1 26 63 8 2 13 35 17 1 5 21 9 2...
output:
251239420 0 0 0 0 84120 831653327 62554891 0 0 157323234 25491 0 0 90893 995296 0 0 0 0 0 0 8572 405652480 0 316 253094353 991299633 0 0 48 0 229937623 7122154 205 0 357101192 4976640 2014 0 14437928 0 0 895419130 0 20736 42195200 1250658 156221420 38671191 0 0 0 0 0 681556604 10497 0 0 0 0 0 4299 4...
result:
ok 999998 lines
Test #61:
score: 0
Accepted
time: 257ms
memory: 27180kb
input:
100 999997 ))))(())((())()()())())((()()))(())()((()()))()()(()))()(()))(((())(((()(()))))((()))()(((()(()()))) 2 3 18 6 1 58 88 14 2 12 82 15 1 74 81 13 1 28 37 20 2 8 55 14 2 23 33 6 1 27 93 13 2 8 94 16 1 35 83 19 1 9 41 5 2 40 84 6 2 29 30 3 1 28 51 2 1 1 16 15 1 8 12 20 1 57 89 2 1 52 64 13 2 1...
output:
0 0 35502492 0 0 419904 0 27375924 3725198 0 268715 88956192 0 592 0 0 2701 0 0 0 1961774 0 218510 0 0 0 888949305 216 0 6 9487531 0 16768838 372322303 1920130 378947808 0 60257184 0 0 0 0 8640 0 0 0 31 0 1608 12693060 0 0 234 0 0 0 1938090 580135181 0 2592 0 725436 41129533 0 306 27171 0 11760336 0...
result:
ok 999997 lines
Test #62:
score: 0
Accepted
time: 284ms
memory: 27348kb
input:
100 999996 ))))))())())))()(()())())((()))))((())))((()()(())))()()))())()())())()))((()((())))(()((((())(()))( 1 17 29 15 1 1 92 11 1 6 36 10 2 23 53 12 2 59 84 4 1 6 69 20 1 25 73 7 1 71 75 3 1 44 61 19 2 62 84 11 1 98 100 2 1 14 62 7 2 3 11 17 1 54 58 6 1 8 13 5 2 69 86 4 1 12 48 2 2 4 18 14 1 51...
output:
0 150469406 0 0 77934 0 63729764 0 0 0 0 44712724 0 0 0 0 2846 0 0 0 0 119117490 0 0 0 0 0 116582842 0 180 0 214839562 0 111052 0 0 0 381460659 0 0 0 0 0 991992233 0 352979303 0 25 597055208 88990 63000 341112384 0 0 9408528 0 772297151 0 638555921 0 0 0 0 2 135032 3909340 0 14 0 0 0 0 313658109 0 0...
result:
ok 999996 lines
Test #63:
score: 0
Accepted
time: 265ms
memory: 27384kb
input:
100 999995 )(())(())()))()(())))))((())))))(()()())()))()(()())))((((()()(()())(()(()(()))()))))())))(()()))()( 2 16 63 8 2 2 34 8 1 19 65 5 2 29 65 20 2 35 91 8 1 12 76 11 1 9 31 11 1 31 49 18 1 18 98 3 1 21 40 2 1 51 91 12 2 40 83 20 1 81 93 12 2 65 83 18 1 1 25 15 1 17 63 15 2 7 56 7 2 61 63 18 1...
output:
56230352 0 2047358 0 679450797 771291932 0 0 3586073 271 0 0 0 0 0 0 372956350 0 0 597196800 0 0 0 50547236 1280 7006 0 0 0 0 0 0 1173952 0 143762967 943743053 373825067 0 0 492790974 0 0 0 100902432 0 641751679 20661 812812 0 3686400 7747043 721877 30712464 0 0 0 0 2093760 0 0 0 0 0 0 0 130776 0 53...
result:
ok 999995 lines
Test #64:
score: 0
Accepted
time: 253ms
memory: 27352kb
input:
100 999994 )(((()))((((((()()))(()()((((((()(((()(())(()()()())(((()))))()(()())((()))()(((()()(()()(()()())))( 1 15 93 13 2 12 69 9 2 43 90 4 2 1 2 19 2 30 71 20 2 15 90 17 1 30 53 3 2 34 79 12 1 51 78 2 1 23 62 1 1 7 88 9 1 4 70 5 2 59 78 10 2 72 100 6 1 40 93 9 1 41 66 11 2 7 65 16 2 11 15 15 2 2...
output:
996257460 318415837 48811809 0 0 907736325 3395 345600 1359 253 724674125 226582802 0 143896 807281776 0 0 0 0 0 0 0 0 0 0 137557960 0 0 0 1202916 0 0 0 254116 0 904 0 0 0 0 427322514 0 0 0 6682032 0 272970694 0 0 0 0 791801043 0 208 0 76 0 30431 5688931 2258304 693147713 141 0 398706 0 0 0 0 895027...
result:
ok 999994 lines
Test #65:
score: 0
Accepted
time: 264ms
memory: 27120kb
input:
100 999993 )(((()()()((())()))(((()()))((((())(((()(()((()()))()(())(())))()))((()(()(())))))(((((()))))())(()( 2 10 19 14 2 3 13 2 2 22 60 15 2 51 65 18 1 18 62 5 2 9 21 7 1 36 92 12 2 12 26 6 2 9 27 1 2 2 10 12 1 62 69 2 1 26 100 6 2 29 56 16 2 29 67 18 1 52 81 19 2 15 27 19 1 20 55 12 2 58 74 19 ...
output:
0 128 0 0 3729426 0 11943936 0 1575 0 0 49985042 0 0 0 0 0 0 4868 86418962 43255961 0 0 0 0 0 660125000 0 0 0 0 65 0 0 3 0 518818644 0 0 0 0 159 0 0 165888 0 0 0 0 0 547998 0 30507673 0 468 2475 0 826115159 0 0 0 0 0 0 0 0 0 414720 830185497 0 179159040 0 0 129042 792 270 0 0 0 0 0 0 710046 0 648 32...
result:
ok 999993 lines
Extra Test:
score: 0
Extra Test Passed