QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#703837 | #5362. I'm always close to you | TheZone | 100 ✓ | 48ms | 93488kb | C++20 | 20.1kb | 2024-11-02 18:39:41 | 2024-11-02 18:39:42 |
Judging History
answer
#include <algorithm>
#include <bit>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <cstring>
#include <iostream>
#include <limits>
#include <numeric>
#include <string>
#include <vector>
#ifndef __OY_FASTIO__
#define __OY_FASTIO__
#define cin OY::IO::InputHelper::get_instance()
#define cout OY::IO::OutputHelper::get_instance()
#define endl '\n'
#ifndef INPUT_FILE
#define INPUT_FILE "in.txt"
#endif
#ifndef OUTPUT_FILE
#define OUTPUT_FILE "out.txt"
#endif
namespace OY {
namespace IO {
using size_type = size_t;
static constexpr size_type INPUT_BUFFER_SIZE = 1 << 16, OUTPUT_BUFFER_SIZE = 1 << 16, MAX_INTEGER_SIZE = 20, MAX_FLOAT_SIZE = 50;
#ifdef OY_LOCAL
static constexpr char input_file[] = INPUT_FILE, output_file[] = OUTPUT_FILE;
#else
static constexpr char input_file[] = "", output_file[] = "";
#endif
struct InputHelper {
FILE *m_file_ptr;
char m_buf[INPUT_BUFFER_SIZE], *m_end, *m_cursor;
bool m_ok;
InputHelper &set_bad() { return m_ok = false, *this; }
template <size_type BlockSize>
void _reserve() {
size_type a = m_end - m_cursor;
if (a >= BlockSize) return;
memmove(m_buf, m_cursor, a), m_cursor = m_buf;
size_type b = a + fread(m_buf + a, 1, INPUT_BUFFER_SIZE - a, m_file_ptr);
if (b < INPUT_BUFFER_SIZE) m_end = m_buf + b, *m_end = EOF;
}
template <typename Tp, typename BinaryOperation>
InputHelper &fill_integer(Tp &ret, BinaryOperation op) {
if (!isdigit(*m_cursor)) return set_bad();
ret = op(Tp(0), *m_cursor - '0');
size_type len = 1;
while (isdigit(*(m_cursor + len))) ret = op(ret * 10, *(m_cursor + len++) - '0');
m_cursor += len;
return *this;
}
explicit InputHelper(const char *inputFileName) : m_ok(true), m_cursor(m_buf + INPUT_BUFFER_SIZE), m_end(m_buf + INPUT_BUFFER_SIZE) { m_file_ptr = *inputFileName ? fopen(inputFileName, "rt") : stdin; }
~InputHelper() { fclose(m_file_ptr); }
static InputHelper &get_instance() {
static InputHelper s_obj(input_file);
return s_obj;
}
static bool is_blank(char c) { return c == ' ' || c == '\t' || c == '\n' || c == '\r'; }
static bool is_endline(char c) { return c == '\n' || c == EOF; }
const char &getchar_checked() {
_reserve<1>();
return *m_cursor;
}
const char &getchar_unchecked() const { return *m_cursor; }
void next() { ++m_cursor; }
template <typename Tp, typename std::enable_if<std::is_signed<Tp>::value & std::is_integral<Tp>::value>::type * = nullptr>
InputHelper &operator>>(Tp &num) {
while (is_blank(getchar_checked())) next();
_reserve<MAX_INTEGER_SIZE>();
if (getchar_unchecked() != '-') return fill_integer(num, std::plus<Tp>());
next();
return fill_integer(num, std::minus<Tp>());
}
template <typename Tp, typename std::enable_if<std::is_unsigned<Tp>::value & std::is_integral<Tp>::value>::type * = nullptr>
InputHelper &operator>>(Tp &num) {
while (is_blank(getchar_checked())) next();
_reserve<MAX_INTEGER_SIZE>();
return fill_integer(num, std::plus<Tp>());
}
template <typename Tp, typename std::enable_if<std::is_floating_point<Tp>::value>::type * = nullptr>
InputHelper &operator>>(Tp &num) {
bool neg = false, integer = false, decimal = false;
while (is_blank(getchar_checked())) next();
_reserve<MAX_FLOAT_SIZE>();
if (getchar_unchecked() == '-') {
neg = true;
next();
}
if (!isdigit(getchar_unchecked()) && getchar_unchecked() != '.') return set_bad();
if (isdigit(getchar_unchecked())) {
integer = true;
num = getchar_unchecked() - '0';
while (next(), isdigit(getchar_unchecked())) num = num * 10 + (getchar_unchecked() - '0');
}
if (getchar_unchecked() == '.')
if (next(), isdigit(getchar_unchecked())) {
if (!integer) num = 0;
decimal = true;
Tp unit = 0.1;
num += unit * (getchar_unchecked() - '0');
while (next(), isdigit(getchar_unchecked())) num += (unit *= 0.1) * (getchar_unchecked() - '0');
}
if (!integer && !decimal) return set_bad();
if (neg) num = -num;
return *this;
}
InputHelper &operator>>(char &c) {
while (is_blank(getchar_checked())) next();
if (getchar_checked() == EOF) return set_bad();
c = getchar_checked(), next();
return *this;
}
InputHelper &operator>>(std::string &s) {
while (is_blank(getchar_checked())) next();
if (getchar_checked() == EOF) return set_bad();
s.clear();
do {
s += getchar_checked();
next();
} while (!is_blank(getchar_checked()) && getchar_unchecked() != EOF);
return *this;
}
explicit operator bool() { return m_ok; }
};
struct OutputHelper {
FILE *m_file_ptr = nullptr;
char m_buf[OUTPUT_BUFFER_SIZE], *m_end, *m_cursor;
char m_temp_buf[MAX_FLOAT_SIZE], *m_temp_buf_cursor, *m_temp_buf_dot;
uint64_t m_float_reserve, m_float_ratio;
void _write() { fwrite(m_buf, 1, m_cursor - m_buf, m_file_ptr), m_cursor = m_buf; }
template <size_type BlockSize>
void _reserve() {
size_type a = m_end - m_cursor;
if (a >= BlockSize) return;
_write();
}
OutputHelper(const char *outputFileName, size_type prec = 6) : m_cursor(m_buf), m_end(m_buf + OUTPUT_BUFFER_SIZE), m_temp_buf_cursor(m_temp_buf) { m_file_ptr = *outputFileName ? fopen(outputFileName, "wt") : stdout, precision(prec); }
static OutputHelper &get_instance() {
static OutputHelper s_obj(output_file);
return s_obj;
}
~OutputHelper() { flush(), fclose(m_file_ptr); }
void precision(size_type prec) { m_float_reserve = prec, m_float_ratio = uint64_t(pow(10, prec)), m_temp_buf_dot = m_temp_buf + prec; }
OutputHelper &flush() { return _write(), fflush(m_file_ptr), *this; }
void putchar(const char &c) {
if (m_cursor == m_end) _write();
*m_cursor++ = c;
}
template <typename Tp, typename std::enable_if<std::is_signed<Tp>::value & std::is_integral<Tp>::value>::type * = nullptr>
OutputHelper &operator<<(Tp ret) {
_reserve<MAX_INTEGER_SIZE>();
size_type len = 0;
if (ret >= 0)
do *(m_cursor + len++) = '0' + ret % 10, ret /= 10;
while (ret);
else {
putchar('-');
do *(m_cursor + len++) = '0' - ret % 10, ret /= 10;
while (ret);
}
for (size_type i = 0, j = len - 1; i < j;) std::swap(*(m_cursor + i++), *(m_cursor + j--));
m_cursor += len;
return *this;
}
template <typename Tp, typename std::enable_if<std::is_unsigned<Tp>::value & std::is_integral<Tp>::value>::type * = nullptr>
OutputHelper &operator<<(Tp ret) {
_reserve<MAX_INTEGER_SIZE>();
size_type len = 0;
do *(m_cursor + len++) = '0' + ret % 10, ret /= 10;
while (ret);
for (size_type i = 0, j = len - 1; i < j;) std::swap(*(m_cursor + i++), *(m_cursor + j--));
m_cursor += len;
return *this;
}
template <typename Tp, typename std::enable_if<std::is_floating_point<Tp>::value>::type * = nullptr>
OutputHelper &operator<<(Tp ret) {
if (ret < 0) {
putchar('-');
return *this << -ret;
}
ret *= m_float_ratio;
uint64_t integer = ret;
if (ret - integer >= 0.4999999999) integer++;
do {
*m_temp_buf_cursor++ = '0' + integer % 10;
integer /= 10;
} while (integer);
if (m_temp_buf_cursor > m_temp_buf_dot) {
do putchar(*--m_temp_buf_cursor);
while (m_temp_buf_cursor > m_temp_buf_dot);
putchar('.');
} else {
putchar('0'), putchar('.');
for (size_type i = m_temp_buf_dot - m_temp_buf_cursor; i--;) putchar('0');
}
do putchar(*--m_temp_buf_cursor);
while (m_temp_buf_cursor > m_temp_buf);
return *this;
}
OutputHelper &operator<<(const char &ret) {
putchar(ret);
return *this;
}
OutputHelper &operator<<(const char *ret) {
while (*ret) putchar(*ret++);
return *this;
}
OutputHelper &operator<<(const std::string &ret) { return *this << ret.data(); }
};
InputHelper &getline(InputHelper &ih, std::string &line) {
line.clear();
if (ih.getchar_checked() == EOF) return ih.set_bad();
while (!InputHelper::is_endline(ih.getchar_checked())) line += ih.getchar_unchecked(), ih.next();
if (ih.getchar_unchecked() != EOF) ih.next();
return ih;
}
}
}
using OY::IO::getline;
#endif
#ifndef __OY_BISUFFIXTREE__
#define __OY_BISUFFIXTREE__
namespace OY {
namespace BISUFTREE {
using size_type = uint32_t;
template <size_type ChildCount>
struct StaticChildGetter {
size_type m_child[ChildCount];
void set_child(size_type index, size_type child) { m_child[index] = child; }
size_type get_child(size_type index) const { return m_child[index]; }
void copy_children(const StaticChildGetter<ChildCount> &rhs) { std::copy_n(rhs.m_child, ChildCount, m_child); }
};
template <typename Tp, typename ChildGetter, size_type MAX_LEN>
struct Tree {
static constexpr size_type inf = std::numeric_limits<size_type>::max() / 2;
struct node : ChildGetter {
size_type m_length, m_parent, m_fail;
Tp *m_ptr;
ChildGetter m_trans;
};
std::vector<node> m_data;
Tp m_seq[MAX_LEN * 2], *m_first, *m_last;
size_type m_now, m_remain, m_lst1, m_lst2, m_leaf;
uint64_t m_unique_cnt;
size_type _newnode(size_type length, Tp *ptr) {
m_data.push_back({});
m_data.back().m_length = length, m_data.back().m_ptr = ptr;
return m_data.size() - 1;
}
void _link(size_type child, size_type parent) {
m_data[child].m_parent = parent;
m_data[parent].set_child(m_data[child].m_ptr[m_data[parent].m_length], child);
}
void _init() {
m_now = m_remain = m_lst1 = m_lst2 = m_leaf = m_unique_cnt = 0;
m_first = m_last = m_seq + MAX_LEN;
m_data.clear(), m_data.resize(1), m_data[0].m_fail = m_data[0].m_parent = -1;
}
Tree() { _init(); }
void reserve(size_type length) { m_data.clear(), m_data.reserve(length * 2 + 1), _init(); }
void clear() { m_data.clear(), _init(); }
size_type size() const { return m_last - m_first; }
size_type leaf_count() const { return m_leaf; }
uint64_t unique_count() const { return m_unique_cnt; }
bool empty() const { return m_first == m_last; }
void push_back(const Tp &elem) {
*m_last = elem, m_remain++;
size_type lst = 0;
while (m_remain) {
if (m_remain <= m_data[m_now].m_length ? m_data[m_now].m_ptr[m_remain - 1] == elem : m_data[m_now].get_child(elem)) break;
if (m_remain <= m_data[m_now].m_length) {
size_type u = _newnode(m_remain - 1, m_data[m_now].m_ptr);
m_data[u].m_trans.copy_children(m_data[m_now].m_trans);
_link(u, m_data[m_now].m_parent), _link(m_now, u);
m_now = u;
}
size_type x = _newnode(inf, m_last - m_remain + 1);
_link(x, m_now);
m_remain--, m_leaf++;
if (lst)
m_data[lst].m_fail = m_now, m_data[m_now].m_trans.set_child(*m_data[lst].m_ptr, lst);
else if (m_lst2)
m_data[m_now].m_trans.set_child(*m_data[m_lst2].m_ptr, m_lst2);
if (m_lst2) m_data[x].m_trans.set_child(*m_data[m_lst2].m_ptr, m_lst2);
lst = m_now, m_lst2 = x;
if (!m_now)
m_data[0].m_trans.set_child(*m_data[x].m_ptr, x);
else {
if (!m_data[m_now].m_parent)
m_data[0].m_trans.set_child(*m_data[lst].m_ptr, lst), m_now = 0;
else
m_now = m_data[m_data[m_now].m_parent].m_fail;
if (m_data[m_now].m_length < m_remain - 1)
while (m_now = m_data[m_now].get_child((m_last - m_remain)[m_data[m_now].m_length + 1]), m_data[m_now].m_length < m_remain - 1) m_data[m_now].m_trans.set_child(*m_data[lst].m_ptr, lst);
}
}
if (lst) m_data[lst].m_fail = m_now, m_data[m_now].m_trans.set_child(*m_data[lst].m_ptr, lst);
if (!m_lst1) m_lst1 = m_data[0].get_child(elem);
if (m_remain > m_data[m_now].m_length) m_now = m_data[m_now].get_child(elem);
if (m_remain == m_data[m_now].m_length) m_data[m_now].m_trans.set_child(*m_data[m_lst2].m_ptr, m_lst2);
m_last++, m_unique_cnt += m_leaf;
}
void push_front(const Tp &elem) {
auto old_Ans = m_unique_cnt;
*--m_first = elem;
size_type p = m_lst1, x;
while (~p && !m_data[p].m_trans.get_child(elem)) p = m_data[p].m_parent;
if (!~p)
x = _newnode(inf, m_first), m_unique_cnt += m_remain + ++m_leaf;
else if ((m_data[p].m_length == m_remain ? p : m_data[p].get_child(m_data[m_lst1].m_ptr[m_data[p].m_length])) == m_now && m_data[m_lst1].m_ptr[m_leaf - 1] == elem) {
x = m_lst2, m_data[x].m_length = inf, m_data[x].m_ptr = m_first;
if (x != m_lst1) {
m_lst2 = m_data[x].m_trans.get_child(m_data[m_lst1].m_ptr[m_leaf - 2]);
m_data[x].m_trans.set_child(m_data[m_lst1].m_ptr[m_leaf - 2], 0);
}
m_remain++, m_now = x, m_unique_cnt += m_leaf;
} else
x = _newnode(inf, m_first), m_unique_cnt += m_leaf++ + m_remain - m_data[p].m_length;
if (x != m_lst1) {
for (p = m_lst1; ~p && !m_data[p].m_trans.get_child(elem); p = m_data[p].m_parent) m_data[p].m_trans.set_child(elem, x);
if (!~p)
_link(x, 0);
else if (m_data[p].m_trans.get_child(elem) != x) {
size_type t = m_data[p].m_trans.get_child(elem);
if (m_data[t].m_length == m_data[p].m_length + 1)
_link(x, t);
else {
size_type u = _newnode(m_data[p].m_length + 1, m_data[t].m_ptr);
m_data[u].m_fail = p;
m_data[u].m_trans.copy_children(m_data[t].m_trans);
_link(u, m_data[t].m_parent), _link(t, u), _link(x, u);
for (; ~p && m_data[p].m_trans.get_child(elem) == t; p = m_data[p].m_parent) m_data[p].m_trans.set_child(elem, u);
if (m_now == t) {
if (m_remain <= m_data[u].m_length) m_now = u;
if (m_data[u].m_length <= m_remain) m_data[u].m_trans.set_child(*m_data[m_lst2].m_ptr, m_lst2);
}
}
}
}
m_lst1 = x;
if (!m_lst2) m_lst2 = m_lst1;
}
const node *get_node(size_type node_index) const { return &m_data[node_index]; }
node *get_node(size_type node_index) { return &m_data[node_index]; }
};
}
template <typename Tp, BISUFTREE::size_type ChildCount = 26, BISUFTREE::size_type MAX_LEN = 1 << 20>
using StaticBiSufTree_string = BISUFTREE::Tree<Tp, BISUFTREE::StaticChildGetter<ChildCount>, MAX_LEN>;
}
#endif
/*
lib code is above
temp code is below
*/
void solve_BiSTree() {
using BiSTree = OY::StaticBiSufTree_string<uint8_t, 26, 200000>;
BiSTree st;
uint32_t n, type;
cin >> n >> type;
st.reserve(n);
if (type) {
uint64_t lst = 0;
for (uint32_t i = 0; i < n; i++) {
std::string s;
char c;
cin >> s >> c;
if (s.size() == 9)
st.push_back((c - 'a' + lst) % 26);
else
st.push_front((c - 'a' + lst) % 26);
lst = st.unique_count();
cout << lst << endl;
}
} else
for (uint32_t i = 0; i < n; i++) {
std::string s;
char c;
cin >> s >> c;
if (s.size() == 9)
st.push_back(c - 'a');
else
st.push_front(c - 'a');
cout << st.unique_count() << endl;
}
}
int main() {
solve_BiSTree();
}
/*#include <algorithm>
#incl::is_unsigned<Tp>::value & std::is_integral<Tp>::value>::type * = nullptr>
InputHelper &operator>>(Tp &num) {
while (is_blank(getchar_checked())) next();
_reserve<MAX_INTEGER_SIZE>();
return fill_integer(num, std::plus<Tp>());
}
template <typename Tp, typename std::enable_if<std::is_floating_point<Tp>::value>::type * = nullptr>
InputHelper &operator>>(Tp &num) {
bool neg = false, integer = false, decimal = false;
while (is_blank(getchar_checked())) next();
_reserve<MAX_FLOAT_SIZE>();
if (getchar_unchecked() == '-') {
neg = true;
next();
}
if (!isdigit(getchar_unchecked()) && getchar_unchecked() != '.') return set_bad();
if (isdigit(getchar_unchecked())) {
integer = true;
num = getchar_unchecked() - '0';
while (next(), isdigit(getchar_unchecked())) num = num * 10 + (getchar_unchecked() - '0');
}
if (getchar_unchecked() == '.')
}
int main() {
solve_BiSTree();
}
*/
这程序好像有点Bug,我给组数据试试?
詳細信息
Subtask #1:
score: 100
Accepted
Test #1:
score: 100
Accepted
time: 0ms
memory: 4412kb
input:
2000 0 push-front a push-front b push-front a push-back a push-back a push-front a push-front a push-back a push-front a push-back b push-back a push-back b push-front b push-front b push-front a push-back b push-front b push-front b push-back b push-back a push-front a push-back a push-front b push...
output:
1 3 5 8 11 15 19 24 29 34 39 49 55 68 81 94 107 122 139 156 173 191 209 228 248 268 291 316 338 364 387 416 445 475 505 535 565 599 634 669 705 741 777 815 852 892 930 971 1010 1052 1094 1135 1178 1220 1271 1322 1373 1425 1479 1532 1587 1642 1698 1754 1812 1875 1938 1997 2063 2129 2195 2263 2331 239...
result:
ok 2000 lines
Test #2:
score: 100
Accepted
time: 1ms
memory: 4368kb
input:
2000 0 push-back b push-front b push-back a push-back b push-back a push-front b push-back a push-front a push-front b push-back b push-back a push-back b push-back b push-back a push-front a push-back a push-front a push-back a push-front b push-back b push-back b push-back b push-front a push-fron...
output:
1 2 5 8 11 15 21 27 33 41 49 58 67 78 88 101 112 128 140 157 175 193 208 228 249 272 296 320 345 371 398 425 454 484 514 546 577 611 646 681 717 754 793 831 871 913 955 997 1041 1085 1130 1175 1221 1267 1313 1362 1412 1465 1516 1571 1627 1683 1739 1798 1858 1918 1978 2041 2102 2163 2229 2296 2364 24...
result:
ok 2000 lines
Subtask #2:
score: 100
Accepted
Test #3:
score: 100
Accepted
time: 35ms
memory: 61820kb
input:
200000 0 push-back m push-front x push-front y push-front e push-back l push-back c push-front y push-back n push-front q push-back w push-back k push-back f push-back c push-front j push-front h push-back y push-back w push-front k push-back b push-front f push-back e push-front v push-back x push-...
output:
1 3 6 10 15 21 27 35 44 54 65 77 89 103 118 133 149 166 185 204 224 246 268 292 316 342 369 396 425 455 485 517 549 582 616 651 687 724 762 801 841 883 926 969 1012 1057 1103 1151 1199 1248 1298 1349 1401 1453 1507 1562 1617 1674 1732 1791 1851 1912 1974 2036 2100 2165 2231 2297 2365 2434 2503 2574 ...
result:
ok 200000 lines
Test #4:
score: 100
Accepted
time: 31ms
memory: 61536kb
input:
200000 0 push-back u push-back b push-back y push-front w push-back j push-back n push-back s push-front d push-back x push-front s push-back a push-front r push-front a push-front d push-front v push-back b push-front n push-front l push-back j push-back i push-front z push-back a push-back e push-...
output:
1 3 6 10 15 21 28 36 45 54 65 77 89 102 117 132 148 166 184 204 225 246 269 293 317 343 370 397 426 454 484 515 547 580 614 649 685 722 760 800 840 882 924 967 1011 1057 1103 1150 1198 1247 1297 1348 1400 1453 1507 1562 1619 1676 1734 1793 1854 1915 1977 2040 2104 2169 2235 2301 2369 2438 2508 2579 ...
result:
ok 200000 lines
Test #5:
score: 100
Accepted
time: 35ms
memory: 61240kb
input:
200000 0 push-front o push-back l push-front z push-front m push-back v push-front k push-front i push-back t push-back q push-front k push-back u push-back l push-back z push-back e push-back d push-back i push-front y push-back q push-front m push-back p push-back s push-back t push-front v push-b...
output:
1 3 6 10 15 21 28 36 45 54 65 76 88 102 117 132 149 166 184 204 225 246 268 292 316 342 368 395 422 451 479 510 543 576 610 646 682 719 757 796 836 877 920 963 1007 1052 1098 1145 1194 1243 1293 1345 1397 1450 1505 1560 1616 1673 1731 1791 1851 1912 1974 2037 2101 2166 2232 2299 2367 2436 2507 2578 ...
result:
ok 200000 lines
Subtask #3:
score: 100
Accepted
Dependency #1:
100%
Accepted
Test #6:
score: 100
Accepted
time: 37ms
memory: 92932kb
input:
200000 0 push-back b push-back b push-front c push-back b push-front c push-front a push-front c push-back c push-back c push-front c push-back a push-back c push-front c push-back b push-front c push-back b push-front c push-back c push-back b push-front b push-back a push-front a push-front c push...
output:
1 2 5 7 11 17 23 30 37 45 53 61 72 84 96 109 122 137 154 171 191 212 233 254 277 300 323 347 373 399 429 459 490 522 555 588 621 654 687 725 763 803 844 881 923 966 1009 1053 1099 1145 1193 1242 1291 1341 1391 1441 1493 1548 1601 1657 1716 1775 1834 1896 1956 2020 2083 2147 2212 2279 2346 2414 2484 ...
result:
ok 200000 lines
Test #7:
score: 100
Accepted
time: 42ms
memory: 93488kb
input:
200000 0 push-back a push-front b push-back a push-front c push-front a push-front b push-front b push-front a push-front b push-front c push-back b push-front c push-back b push-front b push-front c push-front c push-back a push-back a push-back b push-back a push-back c push-back b push-back b pus...
output:
1 3 5 9 13 17 23 30 37 44 53 64 74 87 100 113 126 141 156 174 192 210 231 253 274 295 320 345 371 399 426 453 483 513 545 578 612 647 682 718 754 790 832 874 917 960 1004 1049 1094 1139 1186 1235 1284 1334 1385 1438 1493 1547 1604 1661 1720 1780 1840 1900 1961 2023 2085 2148 2211 2278 2342 2410 2479...
result:
ok 200000 lines
Test #8:
score: 100
Accepted
time: 26ms
memory: 92828kb
input:
200000 0 push-back b push-front a push-back b push-back b push-front a push-back b push-front c push-front a push-back c push-back b push-front c push-front b push-front a push-front b push-front c push-back c push-front a push-back a push-back a push-back a push-front c push-back c push-front c pus...
output:
1 3 5 7 11 14 21 28 36 45 54 64 75 88 101 115 130 145 161 179 197 217 239 261 283 306 330 356 382 409 437 467 497 527 558 589 622 655 691 729 768 807 846 888 930 971 1016 1061 1106 1153 1201 1250 1299 1350 1401 1452 1505 1558 1612 1666 1721 1776 1834 1892 1954 2017 2080 2144 2208 2275 2342 2410 2478...
result:
ok 200000 lines
Test #9:
score: 100
Accepted
time: 14ms
memory: 59356kb
input:
200000 0 push-back a push-front a push-front a push-front a push-back a push-back a push-front a push-back a push-front a push-front a push-back a push-front a push-back a push-front a push-back a push-front a push-back a push-back a push-back a push-back a push-front a push-front a push-back a push...
output:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 ...
result:
ok 200000 lines
Test #10:
score: 100
Accepted
time: 32ms
memory: 69976kb
input:
200000 0 push-back a push-front b push-back b push-front a push-front b push-front a push-back a push-front b push-front a push-back b push-back a push-front b push-front a push-back b push-front b push-front a push-back a push-front b push-back b push-back a push-back b push-front a push-front b pu...
output:
1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 51 53 55 57 59 61 63 65 67 69 71 73 75 77 79 81 83 85 87 89 91 93 95 97 99 101 103 105 107 109 111 113 115 117 119 121 123 125 127 129 131 133 135 137 139 141 143 145 147 149 151 153 155 157 159 161 163 165 167 169 171 173 175 177...
result:
ok 200000 lines
Test #11:
score: 100
Accepted
time: 39ms
memory: 92376kb
input:
200000 0 push-back a push-front a push-back a push-back a push-front a push-front a push-back a push-back a push-back a push-front a push-back a push-back a push-back a push-back a push-back a push-back a push-front a push-front a push-front a push-back a push-front a push-front a push-front a push-...
output:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 77 116 119 122 163 167 209 214 257 300 343 386 429 439 449 494 539 584 597 610 657 704 719 767 783 799 849 866 883 935 987 1006 1059 1079 1133 1187 1209 1231 1253 1310 1333 1356 1415 1474 1499 15...
result:
ok 200000 lines
Test #12:
score: 100
Accepted
time: 25ms
memory: 63524kb
input:
200000 0 push-back f push-back f push-front f push-back f push-front f push-front f push-back f push-front f push-front f push-back f push-front f push-front f push-front f push-front f push-front f push-front f push-front f push-back f push-back f push-back f push-front f push-front f push-back f p...
output:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 ...
result:
ok 200000 lines
Subtask #4:
score: 100
Accepted
Dependency #1:
100%
Accepted
Dependency #2:
100%
Accepted
Dependency #3:
100%
Accepted
Test #13:
score: 100
Accepted
time: 32ms
memory: 91128kb
input:
200000 1 push-back a push-front a push-front z push-back w push-back s push-back q push-back j push-front e push-back y push-back r push-front h push-back a push-back t push-back h push-back z push-back k push-back w push-front g push-front q push-back a push-front i push-back q push-back x push-fro...
output:
1 3 6 9 12 17 23 29 37 45 53 61 71 81 94 108 124 140 157 174 192 212 233 255 277 300 324 348 374 403 432 461 490 521 552 584 618 652 688 723 761 801 840 882 924 966 1010 1053 1097 1141 1188 1233 1281 1332 1379 1430 1484 1538 1591 1648 1705 1763 1821 1883 1945 2008 2071 2135 2201 2268 2335 2404 2473 ...
result:
ok 200000 lines
Test #14:
score: 100
Accepted
time: 48ms
memory: 91000kb
input:
200000 1 push-back b push-back a push-front y push-front v push-back t push-back r push-front j push-back g push-front y push-front r push-back h push-back y push-back n push-back c push-front r push-front f push-front p push-front b push-back k push-front v push-back e push-back j push-front s push...
output:
1 2 5 8 11 17 22 29 37 46 55 65 76 87 101 116 131 147 163 180 199 218 239 259 281 302 325 350 375 401 429 457 487 519 552 586 621 656 691 729 767 805 845 886 929 971 1014 1059 1105 1152 1200 1249 1299 1350 1401 1453 1505 1559 1614 1669 1726 1785 1844 1904 1964 2026 2088 2150 2217 2282 2347 2416 2482...
result:
ok 200000 lines
Test #15:
score: 100
Accepted
time: 21ms
memory: 59472kb
input:
200000 1 push-back a push-front z push-front y push-front x push-back w push-back v push-front u push-back t push-front s push-front r push-back q push-front p push-back o push-front n push-back m push-front l push-back k push-back j push-back i push-back h push-front g push-front f push-back e push...
output:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 ...
result:
ok 200000 lines
Test #16:
score: 100
Accepted
time: 28ms
memory: 70204kb
input:
200000 1 push-back a push-front a push-back y push-front v push-front u push-front r push-back p push-front o push-front l push-back k push-back h push-front g push-front d push-back c push-front a push-front x push-back v push-front u push-back s push-back p push-back o push-front l push-front k pu...
output:
1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 51 53 55 57 59 61 63 65 67 69 71 73 75 77 79 81 83 85 87 89 91 93 95 97 99 101 103 105 107 109 111 113 115 117 119 121 123 125 127 129 131 133 135 137 139 141 143 145 147 149 151 153 155 157 159 161 163 165 167 169 171 173 175 177...
result:
ok 200000 lines
Test #17:
score: 100
Accepted
time: 31ms
memory: 92348kb
input:
200000 1 push-back a push-front z push-back y push-back x push-front w push-front v push-back u push-back t push-back s push-front r push-back q push-back p push-back o push-back n push-back m push-back l push-front k push-front j push-front i push-back h push-front g push-front f push-front e push-...
output:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 77 116 119 122 163 167 209 214 257 300 343 386 429 439 449 494 539 584 597 610 657 704 719 767 783 799 849 866 883 935 987 1006 1059 1079 1133 1187 1209 1231 1253 1310 1333 1356 1415 1474 1499 15...
result:
ok 200000 lines
Test #18:
score: 100
Accepted
time: 25ms
memory: 64368kb
input:
200000 1 push-back f push-back e push-front d push-back c push-front b push-front a push-back z push-front y push-front x push-back w push-front v push-front u push-front t push-front s push-front r push-front q push-front p push-back o push-back n push-back m push-front l push-front k push-back j p...
output:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 ...
result:
ok 200000 lines