QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#612027 | #9425. Generated String | ucup-team4435 | TL | 717ms | 61532kb | C++20 | 44.7kb | 2024-10-05 02:28:45 | 2024-10-13 20:42:17 |
Judging History
answer
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
#define rep1n(i, n) for (int i = 1; i <= (n); ++i)
#define repr(i, n) for (int i = (n) - 1; i >= 0; --i)
#define pb push_back
#define eb emplace_back
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define each(x, a) for (auto &x : a)
#define ar array
#define vec vector
#define range(i, n) rep(i, n)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using str = string;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vpi = vector<pair<int, int>>;
using vvi = vector<vi>;
int Bit(int mask, int b) { return (mask >> b) & 1; }
template<class T>
bool ckmin(T &a, const T &b) {
if (b < a) {
a = b;
return true;
}
return false;
}
template<class T>
bool ckmax(T &a, const T &b) {
if (b > a) {
a = b;
return true;
}
return false;
}
// [l, r)
template<typename T, typename F>
T FindFirstTrue(T l, T r, const F &predicat) {
--l;
while (r - l > 1) {
T mid = l + (r - l) / 2;
if (predicat(mid)) {
r = mid;
} else {
l = mid;
}
}
return r;
}
template<typename T, typename F>
T FindLastFalse(T l, T r, const F &predicat) {
return FindFirstTrue(l, r, predicat) - 1;
}
namespace SPARSE {
#ifndef __OY_CATTREE__
#define __OY_CATTREE__
namespace OY {
namespace CAT {
using size_type = uint32_t;
template <typename Tp, typename Operation>
struct BaseMonoid {
using value_type = Tp;
static value_type op(const value_type &x, const value_type &y) { return Operation()(x, y); }
};
template <typename Tp, typename Compare>
struct ChoiceByCompare {
Tp operator()(const Tp &x, const Tp &y) const { return Compare()(x, y) ? y : x; }
};
template <typename Tp, Tp (*Fp)(Tp, Tp)>
struct FpTransfer {
Tp operator()(const Tp &x, const Tp &y) const { return Fp(x, y); }
};
template <typename Monoid, size_t MAX_LEVEL = 30>
class Table {
public:
using monoid = Monoid;
using value_type = typename Monoid::value_type;
private:
std::vector<value_type> m_sub[MAX_LEVEL];
size_type m_size, m_depth;
void _update(size_type i) {
auto sub = m_sub[0].data();
for (size_type j = 1, k = 4; j != m_depth; j++, k <<= 1) {
auto cur = m_sub[j].data();
size_type l = i & -(1 << (j + 1));
if (i >> j & 1) {
size_type j = i, end = std::min(l + k, m_size);
cur[j] = (j == l + (k >> 1)) ? sub[j] : Monoid::op(cur[j - 1], sub[j]);
while (++j != end) cur[j] = Monoid::op(cur[j - 1], sub[j]);
} else {
if (m_size <= l + k / 2) continue;
size_type j = i + 1;
cur[j - 1] = (j == l + (k >> 1)) ? sub[j - 1] : Monoid::op(sub[j - 1], cur[j]);
while (--j != l) cur[j - 1] = Monoid::op(sub[j - 1], cur[j]);
}
}
}
public:
Table() = default;
template <typename InitMapping>
Table(size_type length, InitMapping mapping) { resize(length, mapping); }
template <typename Iterator>
Table(Iterator first, Iterator last) { reset(first, last); }
template <typename InitMapping>
void resize(size_type length, InitMapping mapping) {
if (!(m_size = length)) return;
m_depth = m_size == 1 ? 1 : std::bit_width(m_size - 1);
for (size_type i = 0; i != m_depth; i++) m_sub[i].resize(m_size);
auto sub = m_sub[0].data();
for (size_type i = 0; i != m_size; i++) sub[i] = mapping(i);
for (size_type j = 1, k = 4, l; j != m_depth; j++, k <<= 1) {
auto cur = m_sub[j].data();
for (l = 0; l + k <= m_size; l += k) {
size_type i = l + (k >> 1);
cur[i - 1] = sub[i - 1];
while (--i != l) cur[i - 1] = Monoid::op(sub[i - 1], cur[i]);
i = l + (k >> 1);
cur[i] = sub[i];
while (++i != l + k) cur[i] = Monoid::op(cur[i - 1], sub[i]);
}
if (l != m_size && (l + (k >> 1) < m_size)) {
size_type i = l + (k >> 1);
cur[i - 1] = sub[i - 1];
while (--i != l) cur[i - 1] = Monoid::op(sub[i - 1], cur[i]);
i = l + (k >> 1);
cur[i] = sub[i];
while (++i != m_size) cur[i] = Monoid::op(cur[i - 1], sub[i]);
}
}
}
template <typename Iterator>
void reset(Iterator first, Iterator last) {
resize(last - first, [&](size_type i) { return *(first + i); });
}
size_type size() const { return m_size; }
void modify(size_type i, value_type val) { m_sub[0][i] = val, _update(i); }
value_type query(size_type i) const { return m_sub[0][i]; }
value_type query(size_type left, size_type right) const {
if (left == right) return m_sub[0][left];
size_type d = std::bit_width(left ^ right) - 1;
return Monoid::op(m_sub[d][left], m_sub[d][right]);
}
value_type query_all() const { return query(0, m_size - 1); }
template <typename Judger>
size_type max_right(size_type left, Judger &&judge) const {
value_type val = m_sub[0][left];
if (!judge(val)) return left - 1;
if (++left == m_size) return left - 1;
size_type d = std::bit_width(left ^ (m_size - 1));
while (d && left < m_size) {
size_type split = (left & -(1 << (d - 1))) | (1 << (d - 1));
if (m_size <= split)
while (--d && (left >> (d - 1) & 1)) {}
else {
value_type a = Monoid::op(val, m_sub[d - 1][left]);
if (judge(a))
val = a, --d, left = split;
else
while (--d && (left >> (d - 1) & 1)) {}
}
}
if (left < m_size && judge(Monoid::op(val, m_sub[0][left]))) left++;
return std::min(left, m_size) - 1;
}
template <typename Judger>
size_type min_left(size_type right, Judger &&judge) const {
value_type val = m_sub[0][right];
if (!judge(val)) return right + 1;
if (!right--) return right + 1;
size_type d = std::bit_width(right);
while (d) {
value_type a = Monoid::op(m_sub[d - 1][right], val);
if (judge(a))
val = a, --d, right = (right & -(1 << d)) - 1;
else
while (--d && !(right >> (d - 1) & 1)) {}
}
if (!(right & 1) && judge(Monoid::op(m_sub[0][right], val))) right--;
return right + 1;
}
};
template <typename Ostream, typename Monoid, size_t MAX_LEVEL>
Ostream &operator<<(Ostream &out, const Table<Monoid, MAX_LEVEL> &x) {
out << "[";
for (size_type i = 0; i != x.size(); i++) {
if (i) out << ", ";
out << x.query(i);
}
return out << "]";
}
}
template <typename Tp, size_t MAX_LEVEL = 30, typename Operation, typename InitMapping, typename TreeType = CAT::Table<CAT::BaseMonoid<Tp, Operation>, MAX_LEVEL>>
auto make_CatTree(CAT::size_type length, Operation op, InitMapping mapping) -> TreeType { return TreeType(length, mapping); }
template <size_t MAX_LEVEL = 30, typename Iterator, typename Operation, typename Tp = typename std::iterator_traits<Iterator>::value_type, typename TreeType = CAT::Table<CAT::BaseMonoid<Tp, Operation>, MAX_LEVEL>>
auto make_CatTree(Iterator first, Iterator last, Operation op) -> TreeType { return TreeType(first, last); }
template <typename Tp, size_t MAX_LEVEL = 30>
using CatMaxTable = CAT::Table<CAT::BaseMonoid<Tp, CAT::ChoiceByCompare<Tp, std::less<Tp>>>, MAX_LEVEL>;
template <typename Tp, size_t MAX_LEVEL = 30>
using CatMinTable = CAT::Table<CAT::BaseMonoid<Tp, CAT::ChoiceByCompare<Tp, std::greater<Tp>>>, MAX_LEVEL>;
template <typename Tp, size_t MAX_LEVEL = 30>
using CatGcdTable = CAT::Table<CAT::BaseMonoid<Tp, CAT::FpTransfer<Tp, std::gcd<Tp>>>, MAX_LEVEL>;
template <typename Tp, size_t MAX_LEVEL = 30>
using CatLcmTable = CAT::Table<CAT::BaseMonoid<Tp, CAT::FpTransfer<Tp, std::lcm<Tp>>>, MAX_LEVEL>;
template <typename Tp, size_t MAX_LEVEL = 30>
using CatBitAndTable = CAT::Table<CAT::BaseMonoid<Tp, std::bit_and<Tp>>, MAX_LEVEL>;
template <typename Tp, size_t MAX_LEVEL = 30>
using CatBitOrTable = CAT::Table<CAT::BaseMonoid<Tp, std::bit_or<Tp>>, MAX_LEVEL>;
template <typename Tp, size_t MAX_LEVEL = 30>
using CatBitXorTable = CAT::Table<CAT::BaseMonoid<Tp, std::bit_xor<Tp>>, MAX_LEVEL>;
template <typename Tp, size_t MAX_LEVEL = 30>
using CatSumTable = CAT::Table<CAT::BaseMonoid<Tp, std::plus<Tp>>, MAX_LEVEL>;
}
#endif
#ifndef __OY_SQRTTREE__
#define __OY_SQRTTREE__
namespace OY {
namespace SQRT {
using size_type = uint32_t;
using CAT::BaseMonoid;
using CAT::ChoiceByCompare;
using CAT::FpTransfer;
template <size_type BlockSize = 16>
struct StaticController {
void reserve(size_type capacity) {}
static constexpr bool is_first(size_type i) { return i % BlockSize == 0; }
static constexpr size_type block_id(size_type i) { return i / BlockSize; }
static constexpr size_type block_first(size_type i) { return i / BlockSize * BlockSize; }
static constexpr size_type block_size() { return BlockSize; }
static constexpr size_type block_count(size_type length) { return (length + BlockSize - 1) / BlockSize; }
};
template <size_type DefaultDepth = 5>
struct RandomController {
size_type m_mask = (1 << DefaultDepth) - 1, m_depth = DefaultDepth;
void reserve(size_type capacity) { m_depth = (std::bit_width(capacity) - 1) / 2, m_mask = (1 << m_depth) - 1; }
bool is_first(size_type i) const { return !(i & m_mask); }
size_type block_id(size_type i) const { return i >> m_depth; }
size_type block_first(size_type i) const { return i & ~m_mask; }
size_type block_size() const { return m_mask + 1; }
size_type block_count(size_type length) const { return (length + m_mask) >> m_depth; }
};
template <size_type DefaultDepth = 5>
struct NonRandomController {
size_type m_mask = (1 << DefaultDepth) - 1, m_depth = DefaultDepth;
void reserve(size_type capacity) { m_depth = capacity >= 32 ? std::bit_width<size_type>(std::bit_width(capacity / std::bit_width(capacity)) - 1) : (std::bit_width(capacity) - 1) / 2, m_mask = (size_type(1) << m_depth) - 1; }
bool is_first(size_type i) const { return !(i & m_mask); }
size_type block_id(size_type i) const { return i >> m_depth; }
size_type block_first(size_type i) const { return i & ~m_mask; }
size_type block_size() const { return m_mask + 1; }
size_type block_count(size_type length) const { return (length + m_mask) >> m_depth; }
};
template <typename Monoid, typename Controller = RandomController<>, size_t MAX_LEVEL = 30>
class Table {
public:
using monoid = Monoid;
using value_type = typename Monoid::value_type;
using inner_table = CAT::Table<Monoid, MAX_LEVEL>;
private:
inner_table m_table;
std::vector<value_type> m_data, m_prefix, m_suffix;
size_type m_size;
Controller m_ctrl;
template <typename Judger>
size_type _max_right(size_type left, size_type end, Judger &&judge) const {
value_type val = m_data[left];
if (judge(val))
while (++left != end) {
value_type a = Monoid::op(val, m_data[left]);
if (!judge(a)) break;
val = a;
}
return left - 1;
}
template <typename Judger>
size_type _max_right2(size_type left, size_type end, Judger &&judge) const {
size_type low = left, high = end;
while (low != high) {
size_type mid = (low + high) / 2;
if (judge(m_prefix[mid]))
low = mid + 1;
else
high = mid;
}
return low - 1;
}
template <typename Judger>
size_type _min_left(size_type end, size_type right, Judger &&judge) const {
value_type val = m_data[right];
if (judge(val))
while (--right != end) {
value_type a = Monoid::op(m_data[right], val);
if (!judge(a)) break;
val = a;
}
return right + 1;
}
template <typename Judger>
size_type _min_left2(size_type end, size_type right, Judger &&judge) const {
size_type low = end, high = right;
while (low != high) {
size_type mid = (low + high + 1) / 2;
if (judge(m_suffix[mid]))
high = mid - 1;
else
low = mid;
}
return low + 1;
}
void _update(size_type i) {
size_type cur = m_ctrl.block_first(i), nxt = std::min(cur + m_ctrl.block_size(), m_size);
m_prefix[i] = (i == cur) ? m_data[i] : Monoid::op(m_prefix[i - 1], m_data[i]);
for (size_type j = i + 1; j != nxt; j++) m_prefix[j] = Monoid::op(m_prefix[j - 1], m_data[j]);
m_suffix[i] = (i == nxt - 1) ? m_data[i] : Monoid::op(m_data[i], m_suffix[i + 1]);
for (size_type j = i - 1; j != cur - 1; j--) m_suffix[j] = Monoid::op(m_data[j], m_suffix[j + 1]);
m_table.modify(m_ctrl.block_id(i), m_suffix[cur]);
}
public:
Table() = default;
template <typename InitMapping>
Table(size_type length, InitMapping mapping) { resize(length, mapping); }
template <typename Iterator>
Table(Iterator first, Iterator last) { reset(first, last); }
size_type size() const { return m_size; }
template <typename InitMapping>
void resize(size_type length, InitMapping mapping) {
if (!(m_size = length)) return;
m_ctrl.reserve(m_size);
m_data.resize(m_size);
for (size_type i = 0; i != m_size; i++) m_data[i] = mapping(i);
m_prefix = m_suffix = m_data;
for (size_type i = 1; i != m_size; i++)
if (!m_ctrl.is_first(i)) m_prefix[i] = Monoid::op(m_prefix[i - 1], m_prefix[i]);
for (size_type i = m_size - 1; i; i--)
if (!m_ctrl.is_first(i)) m_suffix[i - 1] = Monoid::op(m_suffix[i - 1], m_suffix[i]);
m_table.resize(m_ctrl.block_count(m_size), [&](size_type i) { return m_suffix[i * m_ctrl.block_size()]; });
}
template <typename Iterator>
void reset(Iterator first, Iterator last) {
resize(last - first, [&](size_type i) { return *(first + i); });
}
void modify(size_type i, value_type val) { m_data[i] = val, _update(i); }
value_type query(size_type i) const { return m_data[i]; }
value_type query(size_type left, size_type right) const {
size_type l = m_ctrl.block_id(left), r = m_ctrl.block_id(right);
if (l == r) {
value_type res = m_data[left];
#ifndef __clang__
#pragma GCC unroll 64
#endif
for (size_type i = left + 1; i <= right; i++) res = Monoid::op(res, m_data[i]);
return res;
} else if (l + 1 == r)
return Monoid::op(m_suffix[left], m_prefix[right]);
else
return Monoid::op(Monoid::op(m_suffix[left], m_table.query(l + 1, r - 1)), m_prefix[right]);
}
value_type query_all() const { return m_table.query_all(); }
template <typename Judger>
size_type max_right(size_type left, Judger &&judge) const {
value_type val = m_suffix[left];
if (!judge(val)) return _max_right(left, std::min(m_size, m_ctrl.block_first(left) + m_ctrl.block_size()), judge);
size_type l = m_ctrl.block_id(left);
if (l + 1 == m_table.size()) return m_size - 1;
size_type r = m_table.max_right(l + 1, [&](const value_type &x) { return judge(Monoid::op(val, x)); });
if (r + 1 == m_table.size()) return m_size - 1;
if (r > l) val = Monoid::op(val, m_table.query(l + 1, r));
return _max_right2((r + 1) * m_ctrl.block_size(), std::min(m_size, (r + 2) * m_ctrl.block_size()), [&](const value_type &x) { return judge(Monoid::op(val, x)); });
}
template <typename Judger>
size_type min_left(size_type right, Judger &&judge) const {
value_type val = m_prefix[right];
if (!judge(val)) return _min_left(m_ctrl.block_first(right) - 1, right, judge);
size_type r = m_ctrl.block_id(right);
if (!r) return 0;
size_type l = m_table.min_left(r - 1, [&](const value_type &x) { return judge(Monoid::op(x, val)); });
if (!l) return 0;
if (l < r) val = Monoid::op(m_table.query(l, r - 1), val);
return _min_left2(((l - 1) * m_ctrl.block_size()) - 1, (l * m_ctrl.block_size()) - 1, [&](const value_type &x) { return judge(Monoid::op(x, val)); });
}
};
template <typename Ostream, typename Node, typename Controller, size_t MAX_LEVEL>
Ostream &operator<<(Ostream &out, const Table<Node, Controller, MAX_LEVEL> &x) {
out << "[";
for (size_type i = 0; i != x.size(); i++) {
if (i) out << ", ";
out << x.query(i);
}
return out << "]";
}
}
template <typename Tp, typename Controller = SQRT::RandomController<>, size_t MAX_LEVEL = 30, typename Operation, typename InitMapping, typename TreeType = SQRT::Table<SQRT::BaseMonoid<Tp, Operation>, Controller, MAX_LEVEL>>
auto make_SqrtTree(SQRT::size_type length, Operation op, InitMapping mapping) -> TreeType { return TreeType(length, mapping); }
template <typename Controller = SQRT::RandomController<>, size_t MAX_LEVEL = 30, typename Iterator, typename Operation, typename Tp = typename std::iterator_traits<Iterator>::value_type, typename TreeType = SQRT::Table<SQRT::BaseMonoid<Tp, Operation>, Controller, MAX_LEVEL>>
auto make_SqrtTree(Iterator first, Iterator last, Operation op) -> TreeType { return TreeType(first, last); }
template <typename Tp,typename Controller = SQRT::RandomController<>, size_t MAX_LEVEL = 30>
using SqrtMaxTable = SQRT::Table<SQRT::BaseMonoid<Tp, SQRT::ChoiceByCompare<Tp, std::less<Tp>>>, Controller, MAX_LEVEL>;
template <typename Tp,typename Controller = SQRT::RandomController<>, size_t MAX_LEVEL = 30>
using SqrtMinTable = SQRT::Table<SQRT::BaseMonoid<Tp, SQRT::ChoiceByCompare<Tp, std::greater<Tp>>>, Controller, MAX_LEVEL>;
template <typename Tp,typename Controller = SQRT::RandomController<>, size_t MAX_LEVEL = 30>
using SqrtGcdTable = SQRT::Table<SQRT::BaseMonoid<Tp, SQRT::FpTransfer<Tp, std::gcd<Tp>>>, Controller, MAX_LEVEL>;
template <typename Tp,typename Controller = SQRT::RandomController<>, size_t MAX_LEVEL = 30>
using SqrtLcmTable = SQRT::Table<SQRT::BaseMonoid<Tp, SQRT::FpTransfer<Tp, std::lcm<Tp>>>, Controller, MAX_LEVEL>;
template <typename Tp, typename Controller = SQRT::RandomController<>, size_t MAX_LEVEL = 30>
using SqrtBitAndTable = SQRT::Table<SQRT::BaseMonoid<Tp, std::bit_and<Tp>>, Controller, MAX_LEVEL>;
template <typename Tp,typename Controller = SQRT::RandomController<>, size_t MAX_LEVEL = 30>
using SqrtBitOrTable = SQRT::Table<SQRT::BaseMonoid<Tp, std::bit_or<Tp>>, Controller, MAX_LEVEL>;
template <typename Tp, typename Controller = SQRT::RandomController<>, size_t MAX_LEVEL = 30>
using SqrtBitXorTable = SQRT::Table<SQRT::BaseMonoid<Tp, std::bit_xor<Tp>>, Controller, MAX_LEVEL>;
template <typename Tp,typename Controller = SQRT::RandomController<>, size_t MAX_LEVEL = 30>
using SqrtSumTable = SQRT::Table<SQRT::BaseMonoid<Tp, std::plus<Tp>>, Controller, MAX_LEVEL>;
}
#endif
}
// faster implementation
// source: https://judge.yosupo.jp/submission/42086
void SA_IS(const int *s, int *SA, int n, int K) {
// s 为字符串数组[0..n-1] 必须保证 s[n-1]=0 且为最小值
// SA 为存储后缀数组[0..n-1]
// n 为字符串长度
// K 为值域
bool *t = new bool[n]; // 类型数组
int *bkt = new int[K]; // 桶
int *bkt_l = new int[K];
int *bkt_r = new int[K];
int n1 = 0; // LMS-后缀的数量
int *p1; //按出现顺序存储所有 LMS-后缀的索引
#define is_S_type(x) (t[x])
#define is_L_type(x) (!t[x])
#define is_LMS_type(x) (is_S_type(x) && x != 0 && is_L_type(x - 1))
// 预处理每一个后缀的类型
t[n - 1] = true; // 0 为 S-型后缀且为 LMS-型后缀
for (int i = n - 2; i >= 0; --i) {
t[i] = (s[i] < s[i + 1] || (is_S_type(i + 1) && s[i] == s[i + 1]));
n1 += is_LMS_type(i + 1); // s[0] 必然不是 LMS-型后缀,不会影响
}
// 预处理桶的边界
for (int i = 0; i != K; ++i) bkt[i] = 0;
for (int i = 0; i != n; ++i) ++bkt[s[i]];
for (int i = 0, sum = 0; i != K; ++i) sum += bkt[i], bkt_r[i] = sum, bkt_l[i] = sum - bkt[i];
#define indecud_sort() \
do { \
for (int i = 0; i != K; ++i) bkt[i] = bkt_l[i]; \
for (int i = 0, j; i != n; ++i) \
if ((j = SA[i] - 1) >= 0 && is_L_type(j)) SA[bkt[s[j]]++] = j; \
for (int i = 0; i != K; ++i) bkt[i] = bkt_r[i]; \
for (int i = n - 1, j; i >= 0; --i) \
if ((j = SA[i] - 1) >= 0 && is_S_type(j)) SA[--bkt[s[j]]] = j; \
} while (0)
// 将所有 LMS-后缀放入 SA 对应桶的末尾并诱导排序
p1 = new int[n1];
for (int i = 0, j = 0; i != n; ++i) {
SA[i] = -1;
if (is_LMS_type(i)) p1[j++] = i;
}
for (int i = 0; i != K; ++i) bkt[i] = bkt_r[i];
for (int i = n1 - 1; i >= 0; --i) SA[--bkt[s[p1[i]]]] = p1[i];
indecud_sort();
int *s1 = new int[n1]; // 新的字符串
int *SA1 = new int[n1]; // 存储新的字符串排的后缀数组
for (int i = 0, j = 0; i != n; ++i)
if (is_LMS_type(SA[i])) SA1[j++] = SA[i]; // 存储 LMS-子串的相对顺序
int name = 0;
// 对所有 LMS-子串命名
for (int i = 0, prev = -1; i != n1; ++i) {
int pos = SA1[i];
for (int j = 0;; ++j) // 无需设置范围,因为 s[n-1]=0 为最小值且不会出现在其余位置
if (prev == -1 || s[pos + j] != s[prev + j] || is_S_type(pos + j) != is_S_type(prev + j)) {
prev = pos, ++name;
break;
} else if (j != 0 && (is_LMS_type(pos + j) || is_LMS_type(prev + j))) // 到末尾了停止比较
break;
SA[pos] = name - 1; // 利用 SA 暂时存储新字符串的 name
}
for (int i = 0; i != n1; ++i) s1[i] = SA[p1[i]];
if (name != n1)
SA_IS(s1, SA1, n1, name);
else
for (int i = 0; i != n1; ++i) SA1[s1[i]] = i;
for (int i = 0; i != K; ++i) bkt[i] = bkt_r[i];
for (int i = 0; i != n; ++i) SA[i] = -1;
for (int i = n1 - 1; i >= 0; --i) SA[--bkt[s[p1[SA1[i]]]]] = p1[SA1[i]];
indecud_sort();
delete[] SA1;
delete[] s1;
delete[] p1;
delete[] bkt_r;
delete[] bkt_l;
delete[] bkt;
delete[] t;
#undef is_S_type
#undef is_L_type
#undef is_LMS_type
#undef indecud_sort
}
const ll INF = 2e18;
const int INFi = 1e9;
const int N = 2e5 + 50;
const int LG = 20;
std::vector<int> get_sa(const std::string &s) {
int len = s.size();
std::vector<int> SA(len + 1), s_cpy(len + 1);
for (int i = 0; i != len; ++i) s_cpy[i] = s[i];
s_cpy.back() = 0;
SA_IS(s_cpy.data(), SA.data(), len + 1, 128);
return std::vector<int>(SA.begin() + 1, SA.end());
}
auto min_merge = [](int x, int y) {
return min(x, y);
};
struct suffix_array {
std::vector<int> order, suffix_position, lcp;
string s;
SPARSE::OY::SqrtMinTable<uint32_t, SPARSE::OY::SQRT::NonRandomController<4>, 16> sp;
suffix_array() {
}
void build(std::string str) {
order.clear();
suffix_position.clear();
lcp.clear();
s.clear();
s = str;
int n = str.size() + 1;
order = get_sa(str);
order.insert(order.begin(), n - 1);
suffix_position.resize(n);
for (int i = 0; i < n; i++) {
suffix_position[order[i]] = i;
}
lcp.resize(n);
int current_lcp = 0;
for (int suffix = 0; suffix < n - 1; suffix++, current_lcp = current_lcp == 0 ? 0 : current_lcp - 1) {
int previous_suffix = order[suffix_position[suffix] - 1];
while (str[suffix + current_lcp] == str[previous_suffix + current_lcp])
current_lcp++;
lcp[suffix_position[suffix]] = current_lcp;
}
sp = SPARSE::OY::SqrtMinTable<uint32_t, SPARSE::OY::SQRT::NonRandomController<4>, 16>(all(lcp));
}
int LCP(int l, int r) {
if (l == r) return (int) suffix_position.size() - 1 - l;
l = suffix_position[l];
r = suffix_position[r];
if (l > r) swap(l, r);
return sp.query(l + 1, r);
}
char Get(int pos) {
return s[pos];
}
} S;
namespace rect_solve {
template<typename Val = long long>
struct binary_indexed_tree {
int M, H;
std::vector<Val> sum;
binary_indexed_tree() {}
binary_indexed_tree(int N) : M(N), H(31 - __builtin_clz(M)), sum(M + 1, 0) { assert(N > 0); }
binary_indexed_tree(const std::vector<Val> &v) : M(v.size()), H(31 - __builtin_clz(M)), sum(1) {
assert(v.size() > 0);
sum.insert(sum.begin() + 1, v.begin(), v.end());
for (int i = 1; i <= v.size(); i++) {
int nxt = i + (i & (-i));
if (nxt <= M) sum[nxt] += sum[i];
}
}
void update(int k, Val x) {
for (int i = k + 1; i <= M; i += (i & (-i))) sum[i] += x;
}
Val query(int r) {
Val ret = 0;
for (int k = r; k > 0; k -= (k & (-k))) ret += sum[k];
return ret;
}
Val query(int l, int r) {
return query(r) - query(l);
}
// sum[0, k]がx以上になるような最小のkとsum[0, k], 無い場合は{M, 総和}
// sumが単調非減少であることが必要
using p = std::pair<int, Val>;
p lower_bound(Val x) {
int v = 1 << H, h = H;
Val s = 0, t = 0;
while (h--) {
if (M < v) v -= 1 << h;
else if (x <= s + sum[v]) t = s + sum[v], v -= 1 << h;
else s += sum[v], v += 1 << h;
}
if (v == M + 1) return {M, s};
return (x <= s + sum[v] ? p{v - 1, s + sum[v]} : p{v, t});
}
};
//#line 3 ".lib/minior/map_sum_cache.hpp"
//#include <limits>
//#line 5 ".lib/minior/map_sum_cache.hpp"
template<typename Key, typename Val>
struct map_sum_cache {
static constexpr Key inf = std::numeric_limits<Key>::max();
static constexpr Val inf_val = std::numeric_limits<Val>::max();
static constexpr int limit_size_per_node = 16;
private:
struct node {
int h, sz, sz_sum;
std::array<Key, limit_size_per_node> keys;
std::array<Val, limit_size_per_node> vals;
Val sum, sumsub;
node *l, *r;
node() : h(1), l(nullptr), r(nullptr), sum(0) {}
node(Key _key, Val _val) : h(1), sz(1), sz_sum(1), l(nullptr), r(nullptr) {
keys[0] = _key;
vals[0] = sum = sumsub = _val;
}
node(const std::vector<std::pair<Key, Val>> &v, int l, int r) : h(1), sz(r - l), sz_sum(sz), sum(0),
l(nullptr), r(nullptr) {
assert(sz < limit_size_per_node);
for (int i = 0; i < sz; i++) {
keys[i] = v[l + i].first;
vals[i] = v[l + i].second;
sum += vals[i];
}
sumsub = sum;
}
int balanace_factor() {
return (l ? l->h : 0) - (r ? r->h : 0);
}
node *split_half() {
assert(sz == limit_size_per_node);
node *u = new node();
sz = limit_size_per_node / 2;
u->sz_sum = u->sz = limit_size_per_node - sz;
for (int i = 0; i < u->sz; i++) {
u->keys[i] = keys[sz + i];
u->vals[i] = vals[sz + i];
u->sum += u->vals[i];
}
u->sumsub = u->sum;
sum -= u->sum;
return u;
}
};
node *root;
int size(node *v) { return v ? v->sz_sum : 0; }
void update(node *v) {
v->h = std::max(v->l ? v->l->h : 0, v->r ? v->r->h : 0) + 1;
v->sz_sum = (v->l ? v->l->sz_sum : 0) + (v->r ? v->r->sz_sum : 0) + v->sz;
v->sumsub = (v->l ? v->l->sumsub : 0) + (v->r ? v->r->sumsub : 0) + v->sum;
}
node *rotate_right(node *v) {
node *l = v->l;
v->l = l->r;
l->r = v;
update(v);
update(l);
return l;
}
node *rotate_left(node *v) {
node *r = v->r;
v->r = r->l;
r->l = v;
update(v);
update(r);
return r;
}
node *balance(node *v) {
int bf = v->balanace_factor();
assert(-2 <= bf && bf <= 2);
if (bf == 2) {
if (v->l->balanace_factor() == -1) {
v->l = rotate_left(v->l);
update(v);
}
return rotate_right(v);
} else if (bf == -2) {
if (v->r->balanace_factor() == 1) {
v->r = rotate_right(v->r);
update(v);
}
return rotate_left(v);
}
return v;
}
node *build(const std::vector<node *> &nodes, int l, int r) {
int m = (l + r) >> 1;
node *v = nodes[m];
if (m > l) v->l = build(nodes, l, m);
if (r > m + 1) v->r = build(nodes, m + 1, r);
update(v);
return v;
}
node *insert_leftmost(node *v, node *u) {
if (!v) return u;
v->l = insert_leftmost(v->l, u);
update(v);
return balance(v);
}
node *emplace_inner(node *v, Key k, Val val, bool replace = false) {
if (!v) return new node(k, val);
if (v->l && k < v->keys[0]) {
v->l = emplace_inner(v->l, k, val, replace);
} else if (v->r && v->keys[v->sz - 1] < k) {
v->r = emplace_inner(v->r, k, val, replace);
} else {
int idx = std::lower_bound(v->keys.begin(), v->keys.begin() + v->sz, k) - v->keys.begin();
if (idx < v->sz && v->keys[idx] == k) {
v->vals[idx] += val;
v->sum += val;
v->sumsub += val;
return v;
}
for (int i = v->sz; i > idx; i--) {
v->keys[i] = v->keys[i - 1];
v->vals[i] = v->vals[i - 1];
}
v->keys[idx] = k;
v->vals[idx] = val;
v->sum += val;
v->sz++;
if (v->sz == limit_size_per_node) {
v->r = insert_leftmost(v->r, v->split_half());
}
}
update(v);
return balance(v);
}
Val query_inner(node *v, Key k) {
Val ret = 0;
while (v) {
if (k < v->keys[0]) {
v = v->l;
} else if (k > v->keys[v->sz - 1]) {
ret += (v->l ? v->l->sumsub : 0) + v->sum;
v = v->r;
} else {
ret += (v->l ? v->l->sumsub : 0);
for (int i = 0; i < v->sz; i++) {
if (v->keys[i] >= k) return ret;
ret += v->vals[i];
}
}
}
return ret;
}
public:
map_sum_cache() : root(nullptr) {}
map_sum_cache(std::vector<std::pair<Key, Val>> v) {
std::sort(v.begin(), v.end());
init_sorted(v);
}
// すでにソート済みかつキーがユニーク
void init_sorted(const std::vector<std::pair<Key, Val>> &v) {
if (v.empty()) {
root = nullptr;
return;
}
int n = v.size();
int size_per_node = limit_size_per_node / 2;
int m = (n + size_per_node - 1) / size_per_node;
std::vector<node *> nodes(m);
for (int i = 0; i < m; i++) {
nodes[i] = new node(v, i * size_per_node, std::min((i + 1) * size_per_node, n));
}
root = build(nodes, 0, m);
}
int size() {
return size(root);
}
void update(Key key, Val val) {
root = emplace_inner(root, key, val);
}
Val query(Key l, Key r) {
return query_inner(root, r) - query_inner(root, l);
}
};
//#line 8 ".lib/data_structure/range_query/point_add_rectangle_sum.hpp"
template<typename Idx, typename Val>
struct offline_point_add_rectangle_sum {
private:
struct query_type {
int id;
Idx lx, rx, ly, ry;
Val z;
query_type(int a, Idx b, Idx c, Idx d, Idx e, Val f) : id(a), lx(b), rx(c), ly(d), ry(e), z(f) {}
};
struct event_type {
Idx x;
int q, id;
int lyc, ryc;
Val z;
event_type(Idx a, int b, int c, int d, int e, Val f) : x(a), q(b), id(c), lyc(d), ryc(e), z(f) {}
};
std::vector<query_type> q;
std::vector<int> qcount{0};
int qs = 0;
void solve(int l, int r, std::vector<Val> &ans) {
if (r - l < 2) return;
int mid = (l + r) >> 1;
solve(l, mid, ans);
solve(mid, r, ans);
int left_update = (mid - l) - (qcount[mid] - qcount[l]);
int right_query = qcount[r] - qcount[mid];
if (left_update == 0 || right_query == 0) return;
// compress y
std::vector<Idx> y;
for (int i = l; i < mid; i++) if (q[i].id == -1) y.push_back(q[i].ly);
std::sort(y.begin(), y.end());
y.erase(std::unique(y.begin(), y.end()), y.end());
binary_indexed_tree<Val> bit(y.size());
std::vector<event_type> e;
for (int i = l; i < mid; i++) {
if (q[i].id == -1) {
int y_idx = std::lower_bound(y.begin(), y.end(), q[i].ly) - y.begin();
e.push_back(event_type(q[i].lx, 2, -1, y_idx, 0, q[i].z));
}
}
for (int i = mid; i < r; i++) {
if (q[i].id != -1) {
int ly_idx = std::lower_bound(y.begin(), y.end(), q[i].ly) - y.begin();
int ry_idx = std::lower_bound(y.begin(), y.end(), q[i].ry) - y.begin();
e.push_back(event_type(q[i].lx, 0, q[i].id, ly_idx, ry_idx, 0));
e.push_back(event_type(q[i].rx, 1, q[i].id, ly_idx, ry_idx, 0));
}
}
std::sort(e.begin(), e.end(), [](event_type &a, event_type &b) {
if (a.x != b.x) return a.x < b.x;
return a.q < b.q;
});
for (event_type &ei: e) {
if (ei.q == 0) {
ans[ei.id] -= bit.query(ei.lyc, ei.ryc);
} else if (ei.q == 1) {
ans[ei.id] += bit.query(ei.lyc, ei.ryc);
} else {
bit.update(ei.lyc, ei.z);
}
}
}
public:
offline_point_add_rectangle_sum() {}
void update(Idx x, Idx y, Val z) {
q.push_back(query_type(-1, x, 0, y, 0, z));
qcount.push_back(0);
}
void query(Idx lx, Idx rx, Idx ly, Idx ry) {
q.push_back(query_type(qs++, lx, rx, ly, ry, 0));
qcount.push_back(1);
}
std::vector<Val> solve() {
std::vector<Val> ret(qs, 0);
for (int i = 1; i < qcount.size(); i++) qcount[i] += qcount[i - 1];
solve(0, q.size(), ret);
return ret;
}
};
}
struct Element {
vpi a;
int idx;
int priority;
void read() {
int k;
cin >> k;
a.resize(k);
for (auto &[l, r]: a) {
cin >> l >> r;
l--;
}
}
};
bool operator<(const Element &a, const Element &b) {
int i = 0;
int used_i = 0;
int j = 0;
int used_j = 0;
while (true) {
if (j == b.a.size() && i == a.a.size()) return a.priority < b.priority;
if (j == b.a.size()) return b.priority > 0 ? true : false;
if (i == a.a.size()) return a.priority > 0 ? false : true;
int mx_i = a.a[i].second - a.a[i].first - used_i;
int mx_j = b.a[j].second - b.a[j].first - used_j;
int mx = min(mx_i, mx_j);
int len = S.LCP(a.a[i].first + used_i, b.a[j].first + used_j);
ckmin(len, mx);
used_i += len;
used_j += len;
if (len < mx) return S.Get(a.a[i].first + used_i) < S.Get(b.a[j].first + used_j);
if (mx_i == len) {
i++;
used_i = 0;
}
if (mx_j == len) {
j++;
used_j = 0;
}
}
return false;
}
void solve() {
int n, q;
cin >> n >> q;
string s;
cin >> s;
vector<Element> elems;
vector<int> ban;
auto Add = [&](Element e, int ww) {
e.idx = elems.size();
elems.push_back(e);
ban.push_back(ww);
return e.idx;
};
vector<ar<int, 5>> qs(q, {-1, -1, -1, -1, -1});
for (auto &[tp, l1, r1, l2, r2]: qs) {
char t;
cin >> t;
if (t == '+') {
Element e;
e.read();
e.priority = -1;
tp = 1;
l1 = Add(e, -1);
} else if (t == '-') {
tp = -1;
int pos;
cin >> pos;
pos--;
l1 = qs[pos][1];
} else {
tp = 0;
Element e1, e2;
e1.read();
e2.read();
e1.priority = -2;
l1 = Add(e1, 1);
e1.priority = 2;
r1 = Add(e1, 1);
e2.priority = -2;
l2 = Add(e2, 0);
e2.priority = 2;
r2 = Add(e2, 0);
}
}
vector<ar<int, 2>> pos(elems.size());
rep(rot, 2) {
S.build(s);
vector<Element> els;
rep(i, elems.size()) if (ban[i] != rot) {
els.push_back(elems[i]);
}
sort(all(els));
rep(i, els.size()) pos[els[i].idx][rot] = i;
reverse(all(s));
for (auto &e: elems) {
for (auto &[l, r]: e.a) {
r--;
swap(l, r);
l = n - 1 - l;
r = n - 1 - r;
r++;
}
reverse(all(e.a));
}
}
rect_solve::offline_point_add_rectangle_sum<int, ll> rect1, rect2;
for (auto &[tp, l1, r1, l2, r2]: qs) {
if (tp == 1) {
int i = l1;
l1 = r1 = pos[i][0];
l2 = r2 = pos[i][1];
// cerr << "+ " << l1 << ' ' << l2 << endl;
rect1.update(l1, l2, 1);
} else if (tp == -1) {
int i = l1;
l1 = r1 = pos[i][0];
l2 = r2 = pos[i][1];
// cerr << "- " << l1 << ' ' << l2 << endl;
rect2.update(l1, l2, 1);
} else {
l1 = pos[l1][0];
r1 = pos[r1][0];
l2 = pos[l2][1];
r2 = pos[r2][1];
// cerr << "? " << l1 << ' ' << r1 << ' ' << l2 << ' ' << r2 << endl;
rect1.query(l1, r1, l2, r2);
rect2.query(l1, r1, l2, r2);
}
}
auto ans1 = rect1.solve();
auto ans2 = rect2.solve();
rep(i, ans1.size()) {
cout << ans1[i] - ans2[i] << '\n';
}
}
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout << setprecision(12) << fixed;
int t = 1;
// cin >> t;
rep(i, t) {
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3588kb
input:
8 7 abcaabbc + 3 1 3 2 4 3 8 + 2 1 4 1 8 + 1 2 4 ? 1 5 6 1 7 8 - 3 + 1 2 5 ? 1 2 3 1 5 5
output:
2 1
result:
ok 2 lines
Test #2:
score: 0
Accepted
time: 4ms
memory: 3956kb
input:
5 2000 bbaab + 1 3 5 + 2 5 5 3 5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 1 3 1 2 2 10 22 8 21 4 3 16 3 8 2 12 9 0 2 12 4 5 19 16 7 5 4 4 3 8 5 11 4 6 5 13 0 6 5 1...
result:
ok 33583 lines
Test #7:
score: 0
Accepted
time: 360ms
memory: 39836kb
input:
100000 100000 baabbabaabaaaabbaaababaaabbbbbaabbababbabbbaabbaaabbbbababaababbbbbababaabaaabaaababaabbbbaaababbbbabaabbaaaaaabbbabbbabababababaabbabbbbbaaabababbbaabababbbaaababaabbaaaabbabbaabbababaabbaaaababaabbbbbababbaaabbbaababbaaaaaabbbbabbbbbbabbaabababbbaaaaaabbabbabaaaaaabbbaaaaaabaabaaabab...
output:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
result:
ok 33381 lines
Test #8:
score: 0
Accepted
time: 717ms
memory: 40048kb
input:
100000 100000 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
output:
2 2 0 2 1 1 2 2 2 2 0 0 0 0 0 1 0 0 1 0 0 0 2 2 2 0 1 0 0 0 0 1 0 2 3 0 1 0 1 0 0 1 1 2 2 2 1 1 1 0 0 0 2 0 3 0 0 0 0 0 1 2 0 0 1 1 0 0 0 1 1 2 0 2 1 2 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 1 2 2 1 2 4 3 2 0 2 0 0 1 4 0 0 1 1 5 1 0 1 0 0 2 1 0 3 3 1 0 1 1 2 2 3 0 1 3 7 6 0 7 1 1 1 5 2 5 0 2 6 2 2 2 5 ...
result:
ok 33565 lines
Test #9:
score: 0
Accepted
time: 350ms
memory: 42520kb
input:
100000 100000 aaabbbabbaababbbbbbaaababbbaaaaaabbaaaabababbabababbabbabbbaababbbbabaabaaabbaaabbabababbaaabbabbaaaaabbabababbaaaaababbbbabbabaaabbbaabaabbbaaababbbbbabaaabaaaaabbaabaabbabababbabaaabbbbbbbbaababaabbbabaabbabaaabbbbbababaaabbbbbaaaaaaabbbabbbaabbaabbaaaaaaabbbaabbbaabbaaaababbabaababb...
output:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
result:
ok 33118 lines
Test #10:
score: 0
Accepted
time: 716ms
memory: 41880kb
input:
100000 100000 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
output:
0 1 0 0 0 2 0 0 0 0 0 0 0 1 0 0 1 0 0 3 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 4 0 1 0 0 0 0 2 0 3 4 4 5 8 7 9 5 0 9 3 8 2 9 0 5 7 1 7 9 0 1 4 1 5 8 5 1 0 0 5 0 4 12 0 9 5 11 10 3 1 8 1 9 2 1 0 5 5 5 0 2 5 1 1 0 0 12 8 11 11 1 4 11 10 3 7 9 9 4 12 11 5 9 6 1 2 8 10 11 4 17 11 6 3 2 4 1 1 3 1 3 2 3 6 5 4 8 12...
result:
ok 33215 lines
Test #11:
score: 0
Accepted
time: 341ms
memory: 38556kb
input:
100000 100000 mwtmtwnsgaynckkprtjhfnmyzylblnkmrismcyyksqxcikyhrsannbmflvloshydnfvydmuoyphxpjgxsfmyqozidivsigleuvmnyniccdqjekyzjtytudpjbwjmsulfipurvjuxququmkfbrigctewalryoiilmqapofcwpllcwjnzmbtirmfmyhbuqkwqhzidrqbxnulklkjmrnzzclykjoflrbimnshtruucmjiukgvzoekyjnjpkkpwcgrbidyuyodlqaaywfsnbcczuxwsbnrcprq...
output:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
result:
ok 33475 lines
Test #12:
score: 0
Accepted
time: 547ms
memory: 37544kb
input:
100000 100000 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
output:
0 0 1 1 1 1 3 1 3 4 3 3 4 5 7 4 4 4 5 3 4 6 1 0 4 4 12 3 9 9 9 3 7 10 6 9 2 9 4 8 8 7 4 7 7 6 1 5 6 6 4 5 4 3 0 1 1 1 0 0 0 0 0 0 0 0 0 1 0 1 1 0 2 0 0 0 0 0 0 0 0 0 0 1 0 1 1 3 1 1 1 4 4 1 0 4 3 2 0 2 1 0 0 0 0 6 5 0 2 4 2 0 0 0 0 1 0 1 0 0 0 2 4 4 1 3 5 1 0 0 0 0 0 0 2 2 2 0 0 0 0 0 0 0 0 2 2 3 1 ...
result:
ok 33689 lines
Test #13:
score: 0
Accepted
time: 463ms
memory: 38388kb
input:
100000 100000 bbbbbaabbbbbaaabaabaaabbbbaabaaabaabbababbaaaaaaaabbababbbbabbababaabbabaabbaaaabbbbabaabbababbbbbbbaaabaabbabbbbbbaaaaababaaabbbabbaabaabaaabbbabbaaabaaaababbaaabaabbabaaaaaaababababbbbaabbaaaabaabbbbaaaababbabbbbabaabbbaaabbbaabaaabbbaaabaabbbbbabbaaabbaabbabbaababbbabbababbabbaabbbb...
output:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
result:
ok 33438 lines
Test #14:
score: 0
Accepted
time: 272ms
memory: 36516kb
input:
100000 100000 aaabbbbabbaababbabaabbabababaaaaabbababababaabbaaabbbaaaaaabaaabbabbabbbabaabbaabbabbbbbbbaabaaababaaaaabaaaabbbaaaabbaabbaabbbbaaababbabababbaaaaabbbababababaabaabababbabbbbbabbabbbbaaababbbbaabbaaabababaabbbaaabaaaabbabbaabbbaabbbbabbbababbbabaabbaababaaaabbaabaaabbaaabaaaaabbbbbbbab...
output:
0 0 0 0 0 0 0 2 1 4 0 0 1 1 0 0 0 2 0 0 0 8 2 0 2 0 0 0 0 0 0 7 0 0 0 0 10 5 4 4 0 1 4 0 0 2 4 4 0 0 0 6 0 4 0 0 0 7 4 7 3 5 0 0 0 7 0 7 7 0 8 7 3 0 0 11 0 0 4 11 0 2 2 0 11 9 2 11 3 2 12 3 0 13 0 0 3 0 4 5 0 0 0 4 6 0 0 6 0 4 4 0 0 0 5 5 0 0 6 0 7 0 7 8 7 0 6 6 7 7 7 6 17 6 8 7 7 3 15 0 14 6 0 0 14...
result:
ok 33321 lines
Test #15:
score: 0
Accepted
time: 3ms
memory: 4172kb
input:
5 1000 glbdh + 2 2 2 1 2 ? 2 1 2 3 4 1 1 5 ? 1 3 4 3 2 3 4 4 1 5 - 1 ? 1 1 2 2 1 2 1 4 + 1 1 3 + 2 1 4 1 2 ? 2 4 5 1 2 3 2 3 3 4 1 2 ? 2 4 4 1 1 2 3 4 1 3 ? 1 1 2 1 1 3 - 7 + 1 1 5 ? 1 3 3 1 1 2 ? 3 3 4 4 4 2 3 1 1 2 + 3 1 5 2 5 1 2 ? 1 1 1 3 1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: 0
Accepted
time: 652ms
memory: 31912kb
input:
100000 100000 dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd...
output:
0 6 5 7 5 8 6 6 17 13 14 20 26 23 16 21 20 17 39 26 31 32 46 39 36 52 36 28 28 28 26 29 46 53 48 55 18 43 44 40 49 25 59 42 57 60 42 36 65 50 52 59 25 56 42 42 16 77 43 42 65 57 57 52 44 48 42 19 43 72 65 56 101 69 37 69 73 106 72 55 66 22 70 60 40 73 81 78 60 79 94 63 74 62 74 78 110 76 107 113 108...
result:
ok 9964 lines
Test #18:
score: 0
Accepted
time: 666ms
memory: 60568kb
input:
100000 100000 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
output:
0 0 1 1 0 0 0 2 2 0 0 1 2 2 0 0 3 3 3 2 0 1 3 0 1 0 2 1 1 1 2 5 4 3 4 3 3 1 3 1 2 1 5 2 3 2 3 5 2 5 3 1 5 3 1 3 1 1 2 4 4 1 5 1 1 2 3 3 3 4 2 5 3 2 2 4 4 2 4 3 3 5 4 7 4 8 6 8 5 4 4 4 6 3 4 7 5 4 9 6 6 5 7 7 5 6 6 5 5 5 6 8 6 5 5 4 7 4 7 4 4 5 4 5 4 8 4 4 5 5 4 8 4 8 8 8 4 7 9 5 7 6 7 6 6 6 8 6 10 6...
result:
ok 90061 lines
Test #19:
score: 0
Accepted
time: 651ms
memory: 47276kb
input:
100000 100000 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
output:
0 0 0 0 0 0 0 0 0 0 0 1 0 0 3 0 0 1 0 1 0 0 1 3 2 0 2 3 1 0 2 3 0 0 0 0 3 3 3 0 5 2 0 3 0 1 3 1 0 1 1 0 3 3 3 0 6 3 0 3 0 0 1 3 3 2 3 4 0 1 3 1 3 1 1 6 5 4 8 2 1 3 4 3 0 0 6 8 10 1 4 11 2 4 0 0 0 4 3 9 3 2 10 10 7 3 1 1 3 8 5 0 3 1 8 1 3 0 8 1 6 1 4 1 8 8 6 1 7 0 1 6 9 1 6 4 3 1 2 6 7 1 9 10 3 7 2 2...
result:
ok 49932 lines
Test #20:
score: 0
Accepted
time: 616ms
memory: 33024kb
input:
100000 100000 zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz...
output:
1 1 1 0 1 2 2 1 4 4 4 6 6 7 7 9 12 12 11 15 8 21 3 4 8 8 26 11 15 11 20 21 22 29 14 26 25 31 34 26 19 11 29 33 17 20 20 27 33 29 29 43 31 33 33 16 35 30 17 24 40 36 41 19 33 38 51 32 64 28 21 50 42 41 46 29 48 51 62 56 30 45 62 37 54 38 22 43 38 45 43 40 59 53 73 73 72 45 68 27 68 64 62 72 51 65 39 ...
result:
ok 10030 lines
Test #21:
score: 0
Accepted
time: 598ms
memory: 61532kb
input:
100000 100000 pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp...
output:
0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 1 1 1 2 0 0 0 1 1 1 1 1 0 1 3 1 1 1 2 0 1 2 3 3 0 1 1 1 1 1 1 2 2 2 0 2 3 1 1 1 1 0 1 1 0 2 0 2 0 1 0 2 3 2 1 1 1 1 1 5 3 0 2 2 2 0 2 2 2 1 2 4 5 2 2 5 2 1 2 5 0 2 5 3 5 5 0 2 2 3 0 4 2 4 0 2 1 2 1 2 2 1 0 2 1 3 1 0 2 0 2 2 0 3 3 3 5 2 2 5 3 6 5 3 3 ...
result:
ok 90160 lines
Test #22:
score: 0
Accepted
time: 406ms
memory: 47280kb
input:
100000 100000 faxyuxswncplvrzynzvlbjqvkdhqfmdddimahxygchjxwqaouebuiijkydypsvhlqeoelcnizmzcnuzvxzqilitcmbrhwjtbastbqyktczoarrihswnbsjtzvkrdjkwzijqkcziwqndcfgyvpepsokrgtlvrwxwjbtctdluemgbpzneomxcqdxxaoxdrgdzrherrygznacprcimyudgbjpelkpxotckckzihjuxnlmkczsutackpunsfnkwvhkadjfnhmvplqfgzmkssoacpuxaipepwro...
output:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 2 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 ...
result:
ok 49806 lines
Test #23:
score: 0
Accepted
time: 324ms
memory: 32704kb
input:
100000 100000 twdczjujsjrmpsipsunndczjujsjrmpsipsuwynwdczjujsjrmpsipsuwjwdczjujsjrmpsipsuyhtwdczjujsjrmpsipsuwwddczjujsjrmpsipsudczjujsjrmpsipsuybtwdczjujsjrmpsipsuwexdczjujsjrmpsipsuwevtwdczjujsjrmpsipsuwexatwdczjujsjrmpsipsuapwdczjujsjrmpsipsuwepwdczjujsjrmpsipsuwowdczjujsjrmpsipsudczjujsjrmpsipsu...
output:
0 1 0 0 0 1 0 0 1 1 7 0 0 0 0 3 3 0 3 3 1 1 0 0 0 0 0 3 9 13 0 14 5 0 2 10 6 5 2 9 3 9 3 5 6 2 1 0 4 2 1 0 0 10 3 5 2 0 7 0 30 27 0 3 13 0 0 0 1 0 22 0 0 1 0 0 27 0 35 1 0 1 17 0 0 0 1 10 0 0 0 2 2 15 0 52 0 4 14 0 0 36 6 0 25 0 12 0 6 1 0 1 0 0 0 3 9 2 0 60 38 16 15 11 0 0 0 2 13 0 0 6 0 7 0 0 0 25...
result:
ok 9909 lines
Test #24:
score: 0
Accepted
time: 266ms
memory: 57920kb
input:
100000 100000 gqxicygqxicygqxicygqxicygqxicygqxicygqxicygqxicygqxicygqxicygqxicygqxicygqxicygqxicygqxicygqxicygqxicygqxicygqxicygqxicygqxicygqxicygqxicygqxicygqxicygqxicygqxicygqxicygqxicygqxicygqxicygqxicygqxicygqxicygqxicygqxicygqxicygqxicygqxicygqxicygqxicygqxicygqxicygqxicygqxicygqxicygqxicygqxi...
output:
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 6 6 6 6 7 7 7 7 7 7 7 8 8 8 8 8 8 8 8 8 8 8 9 9 9 10 10 11 11 11 11 11 11 11 11 12 12 12 12 12 12 13 13 13 13 13 13 13 14 14 14 15 15 15 15 15 1...
result:
ok 90066 lines
Test #25:
score: 0
Accepted
time: 368ms
memory: 46712kb
input:
100000 100000 nbaiostoyrvtrkngnuatnddlyjzqnfgufkqtmahrkmxxstxnqszjxibrnymsyujvzvazdmernpfoapfefjnbberzsmfmfqjwyyrqmbgdzppkratnddlyjzqnfgufkqtmahrkmxxstxnqszjxibrnymsyujvzvazdmernpfoapfefjnbberzsmfmfqjwyyrqvazynjzqnfgufkqtmahrkmxxstxnqszjxibrnymsyujvzvazdmernpfoapfefjnbberzsjzqnfgufkqtmahrkmxxstxnqsz...
output:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
result:
ok 50106 lines
Test #26:
score: 0
Accepted
time: 283ms
memory: 32452kb
input:
100000 100000 avrzpogavrzpogavrzpogavrzpogavrzpogavrzpogavrzpogavrzpogavrzpogavrzpogavrzpogavrzpogavrzpogavrzpogavrzpogavrzpogavrzpogavrzpogavrzpogavrzpogavrzpogavrzpogavrzpogavrzpogavrzpogavrzpogavrzpogavrzpogavrzpogavrzpogavrzpogavrzpogavrzpogavrzpogavrzpogavrzpogavrzpogavrzpogavrzpogavrzpogavrzpo...
output:
2 2 13 28 31 64 83 95 108 119 121 127 134 141 157 158 162 164 175 181 181 195 201 201 209 210 215 218 253 259 263 263 273 274 280 303 310 317 318 325 328 342 360 368 376 392 393 420 427 431 434 440 456 457 485 501 502 533 556 593 601 601 605 606 614 617 644 654 687 700 721 723 728 728 731 731 738 74...
result:
ok 9852 lines
Test #27:
score: 0
Accepted
time: 349ms
memory: 59428kb
input:
100000 100000 nzqcglfwczqmzqcglfwczazqcglfwczzmzqcglfwczzqcglfwczpmzqcglfwczzqcglfwcxmzqcglfwcznzqcglfwczqcglfwcmzqcglfwczmzqcglfwcjmzqcglfwczzqcglfwczrzqcglfwczqcglfwczqcglfwczmzqcglfwczwzqcglfwczqcglfwcjzqcglfwcmzqcglfwcmzqcglfwczzqcglfwcizqcglfwcomzqcglfwcmzqcglfwczzqcglfwcjmzqcglfwczmzqcglfwczmz...
output:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 2 0 1 0 0 3 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 0 0 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 3 0 0 0 0 0 0 0 1 2 0 0 0 0 1 0 1 0 1 0 0 ...
result:
ok 90005 lines
Test #28:
score: 0
Accepted
time: 570ms
memory: 53700kb
input:
100000 100000 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
output:
5379 21600 8676 17796 6561 7062 8794 24490 12428 13642 26349 12930 17230 4054 29012 19503 23951 2084 14612 6542 11110 18521 5532 30725 21338 30107 893 12051 20828 7845 32580 8063 4190 21112 8005 33480 15470 3466 1311 10240 13981 29868 3358 35905 19687 9180 46665 11173 4030 5610 14002 22315 28887 629...
result:
ok 49879 lines
Extra Test:
score: -3
Extra Test Failed : Time Limit Exceeded on 2
input:
100000 100000 acbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb...