Tsukihjy/testcase / testcase-data /eval /To-fix-wrong-code-v26-EXE.json
Tsukihjy's picture
download
raw
76.9 kB
[
{
"code_id": 1,
"code": "#include <algorithm>\n#include <bitset>\n#include <cassert>\n#include <climits>\n#include <cstring>\n#include <iostream>\n#include <list>\n#include <map>\n#include <memory>\n#include <queue>\n#include <random>\n#include <set>\n#include <sstream>\n#include <stack>\n#include <unordered_set>\n#include <immintrin.h>\nnamespace OY {\n#define cin OY::inputHelper<1 << 18, 1024>::getInstance()\n#define getchar() ({char c=cin.getChar_Checked();cin.next();c; })\n#define cout OY::outputHelper<1 << 20>::getInstance()\n#define putchar cout.putChar\n#define endl '\\n'\n#define putlog(...) OY::printLog(\", \", __VA_ARGS__)\ntemplate < uint64_t _BufferSize = 1 << 10, uint64_t _BlockSize = 20 >\nclass inputHelper {\npublic:\n FILE *m_filePtr;\n char m_buf[_BufferSize], *m_end, *m_cursor;\n bool m_ok;\n void flush() {\n uint64_t a = m_end - m_cursor;\n\n if (a >= _BlockSize)\n return;\n\n memmove(m_buf, m_cursor, a);\n uint64_t b = fread(m_buf + a, 1, _BufferSize - a, m_filePtr);\n m_cursor = m_buf;\n\n if (a + b < _BufferSize) {\n m_end = m_buf + a + b;\n *m_end = EOF;\n }\n }\n\npublic:\n explicit inputHelper(const char *inputFileName) : m_ok(true) {\n if (!*inputFileName)\n m_filePtr = stdin;\n else\n m_filePtr = fopen(inputFileName, \"rt\");\n\n m_end = m_cursor = m_buf + _BufferSize;\n }\n ~inputHelper() {\n fclose(m_filePtr);\n }\n static inputHelper<_BufferSize, _BlockSize> &getInstance() {\n static inputHelper<_BufferSize, _BlockSize> s_obj(\"\");\n return s_obj;\n }\n static constexpr bool isBlank(char c) {\n return c == ' ' || c == '\\t' || c == '\\n' || c == '\\r';\n }\n static constexpr bool isEndline(char c) {\n return c == '\\n' || c == EOF;\n }\n const char &getChar_Checked() {\n if (m_cursor < m_end)\n return *m_cursor;\n\n uint64_t b = fread(m_buf, 1, _BufferSize, m_filePtr);\n m_cursor = m_buf;\n\n if (b < _BufferSize) {\n m_end = m_buf + b;\n *m_end = EOF;\n }\n\n return *m_cursor;\n }\n const char &getChar_Unchecked() const {\n return *m_cursor;\n }\n void next() {\n ++m_cursor;\n }\n void setState(bool _ok) {\n m_ok = _ok;\n }\n template <typename _Tp, typename std::enable_if<std::is_signed<_Tp>::value &std::is_integral<_Tp>::value>::type * = nullptr>\n inputHelper<_BufferSize, _BlockSize> &operator>>(_Tp &ret) {\n while (isBlank(getChar_Checked()))\n next();\n\n flush();\n\n if (getChar_Unchecked() == '-') {\n next();\n\n if (isdigit(getChar_Unchecked())) {\n ret = -(getChar_Unchecked() - '0');\n\n while (next(), isdigit(getChar_Unchecked()))\n ret = ret * 10 - (getChar_Unchecked() - '0');\n } else\n m_ok = false;\n } else {\n if (isdigit(getChar_Unchecked())) {\n ret = getChar_Unchecked() - '0';\n\n while (next(), isdigit(getChar_Unchecked()))\n ret = ret * 10 + (getChar_Unchecked() - '0');\n } else\n m_ok = false;\n }\n\n return *this;\n }\n template <typename _Tp, typename std::enable_if<std::is_unsigned<_Tp>::value &std::is_integral<_Tp>::value>::type * = nullptr>\n inputHelper<_BufferSize, _BlockSize> &operator>>(_Tp &ret) {\n while (isBlank(getChar_Checked()))\n next();\n\n flush();\n\n if (isdigit(getChar_Unchecked())) {\n ret = getChar_Unchecked() - '0';\n\n while (next(), isdigit(getChar_Unchecked()))\n ret = ret * 10 + (getChar_Unchecked() - '0');\n } else\n m_ok = false;\n\n return *this;\n }\n template <typename _Tp, typename std::enable_if<std::is_floating_point<_Tp>::value>::type * = nullptr>\n inputHelper<_BufferSize, _BlockSize> &operator>>(_Tp &ret) {\n bool neg = false, integer = false, decimal = false;\n\n while (isBlank(getChar_Checked()))\n next();\n\n flush();\n\n if (getChar_Unchecked() == '-') {\n neg = true;\n next();\n }\n\n if (!isdigit(getChar_Unchecked()) && getChar_Unchecked() != '.') {\n m_ok = false;\n return *this;\n }\n\n if (isdigit(getChar_Unchecked())) {\n integer = true;\n ret = getChar_Unchecked() - '0';\n\n while (next(), isdigit(getChar_Unchecked()))\n ret = ret * 10 + (getChar_Unchecked() - '0');\n }\n\n if (getChar_Unchecked() == '.') {\n next();\n\n if (isdigit(getChar_Unchecked())) {\n if (!integer)\n ret = 0;\n\n decimal = true;\n _Tp unit = 0.1;\n ret += unit * (getChar_Unchecked() - '0');\n\n while (next(), isdigit(getChar_Unchecked())) {\n unit *= 0.1;\n ret += unit * (getChar_Unchecked() - '0');\n }\n }\n }\n\n if (!integer && !decimal)\n m_ok = false;\n else if (neg)\n ret = -ret;\n\n return *this;\n }\n inputHelper<_BufferSize, _BlockSize> &operator>>(char &ret) {\n while (isBlank(getChar_Checked()))\n next();\n\n ret = getChar_Checked();\n\n if (ret == EOF)\n m_ok = false;\n else\n next();\n\n return *this;\n }\n inputHelper<_BufferSize, _BlockSize> &operator>>(std::string &ret) {\n while (isBlank(getChar_Checked()))\n next();\n\n if (getChar_Checked() != EOF) {\n ret.clear();\n\n do {\n ret += getChar_Checked();\n next();\n } while (!isBlank(getChar_Checked()) && getChar_Unchecked() != EOF);\n } else\n m_ok = false;\n\n return *this;\n }\n explicit operator bool() {\n return m_ok;\n }\n};\ntemplate < uint64_t _BufferSize = 1 << 20 >\nclass outputHelper {\n FILE *m_filePtr = nullptr;\n char m_buf[_BufferSize], *m_end, *m_cursor;\n char m_tempBuf[50], *m_tempBufCursor, *m_tempBufDot;\n uint64_t m_floatReserve, m_floatRatio;\n\npublic:\n outputHelper(const char *outputFileName, int prec = 6) : m_end(m_buf + _BufferSize) {\n if (!*outputFileName)\n m_filePtr = stdout;\n else\n m_filePtr = fopen(outputFileName, \"wt\");\n\n m_cursor = m_buf;\n m_tempBufCursor = m_tempBuf;\n precision(prec);\n }\n static outputHelper<_BufferSize> &getInstance() {\n static outputHelper<_BufferSize> s_obj(\"\");\n return s_obj;\n }\n ~outputHelper() {\n flush();\n fclose(m_filePtr);\n }\n void precision(int prec) {\n m_floatReserve = prec;\n m_floatRatio = pow(10, prec);\n m_tempBufDot = m_tempBuf + prec;\n }\n outputHelper<_BufferSize> &flush() {\n fwrite(m_buf, 1, m_cursor - m_buf, m_filePtr);\n fflush(m_filePtr);\n m_cursor = m_buf;\n return *this;\n }\n void putChar(const char &c) {\n if (m_cursor == m_end)\n flush();\n\n *m_cursor++ = c;\n }\n void putS(const char *c) {\n while (*c)\n putChar(*c++);\n }\n template <typename _Tp, typename std::enable_if<std::is_signed<_Tp>::value &std::is_integral<_Tp>::value>::type * = nullptr>\n outputHelper<_BufferSize> &operator<<(const _Tp &ret) {\n _Tp _ret = _Tp(ret);\n\n if (_ret >= 0) {\n do {\n *m_tempBufCursor++ = '0' + _ret % 10;\n _ret /= 10;\n } while (_ret);\n\n do\n putChar(*--m_tempBufCursor);\n\n while (m_tempBufCursor > m_tempBuf);\n } else {\n putChar('-');\n\n do {\n *m_tempBufCursor++ = '0' - _ret % 10;\n _ret /= 10;\n } while (_ret);\n\n do\n putChar(*--m_tempBufCursor);\n\n while (m_tempBufCursor > m_tempBuf);\n }\n\n return *this;\n }\n template <typename _Tp, typename std::enable_if<std::is_unsigned<_Tp>::value &std::is_integral<_Tp>::value>::type * = nullptr>\n outputHelper<_BufferSize> &operator<<(const _Tp &ret) {\n _Tp _ret = _Tp(ret);\n\n do {\n *m_tempBufCursor++ = '0' + _ret % 10;\n _ret /= 10;\n } while (_ret);\n\n do\n putChar(*--m_tempBufCursor);\n\n while (m_tempBufCursor > m_tempBuf);\n\n return *this;\n }\n template <typename _Tp, typename std::enable_if<std::is_floating_point<_Tp>::value>::type * = nullptr>\n outputHelper<_BufferSize> &operator<<(const _Tp &ret) {\n if (ret < 0) {\n putChar('-');\n return *this << -ret;\n }\n\n _Tp _ret = ret * m_floatRatio;\n uint64_t integer = _ret;\n\n if (_ret - integer >= 0.4999999999)\n integer++;\n\n do {\n *m_tempBufCursor++ = '0' + integer % 10;\n integer /= 10;\n } while (integer);\n\n if (m_tempBufCursor > m_tempBufDot) {\n do\n putChar(*--m_tempBufCursor);\n\n while (m_tempBufCursor > m_tempBufDot);\n\n putChar('.');\n } else {\n putS(\"0.\");\n\n for (int i = m_tempBufDot - m_tempBufCursor; i--;)\n putChar('0');\n }\n\n do\n putChar(*--m_tempBufCursor);\n\n while (m_tempBufCursor > m_tempBuf);\n\n return *this;\n }\n outputHelper<_BufferSize> &operator<<(const char &ret) {\n putChar(ret);\n return *this;\n }\n outputHelper<_BufferSize> &operator<<(const std::string &ret) {\n putS(ret.data());\n return *this;\n }\n};\ntemplate <uint64_t _BufferSize, uint64_t _BlockSize>\ninputHelper<_BufferSize, _BlockSize> &getline(inputHelper<_BufferSize, _BlockSize> &ih, std::string &ret) {\n ret.clear();\n\n if (ih.getChar_Checked() == EOF)\n ih.setState(false);\n else {\n while (!inputHelper<_BufferSize, _BlockSize>::isEndline(ih.getChar_Checked())) {\n ret += ih.getChar_Unchecked();\n ih.next();\n }\n\n ih.next();\n }\n\n return ih;\n}\ntemplate <typename D, typename T, typename... S>\nvoid printLog(D delim, const T &x, S... rest) {\n cout << x;\n\n if (sizeof...(rest) > 0) {\n cout << delim;\n printLog(delim, rest...);\n }\n}\n}\nusing OY::getline;\nconstexpr unsigned int constexpr_primitive_root(unsigned int mod) {\n\tusing u32 = unsigned int;\n\tusing u64 = unsigned long long;\n\tif(mod == 2) return 1;\n\tu64 m = mod - 1, ds[32] = {}, idx = 0;\n\tfor (u64 i = 2; i * i <= m; ++i) {\n\t\tif (m % i == 0) {\n\t\t\tds[idx++] = i;\n\t\t\twhile (m % i == 0) m /= i;\n\t\t}\n\t}\n\tif (m != 1) ds[idx++] = m;\n\tfor (u32 _pr = 2, flg = true;; _pr++, flg = true) {\n\t\tfor (u32 i = 0; i < idx && flg; ++i) {\n\t\t\tu64 a = _pr, b = (mod - 1) / ds[i], r = 1;\n\t\t\tfor (; b; a = a * a % mod, b >>= 1)\n\t\t\t\tif (b & 1) r = r * a % mod;\n\t\t\tif (r == 1) flg = false;\n\t\t}\n\t\tif (flg == true) return _pr;\n\t}\n}\n\n\n\n\n\ntemplate <uint32_t mod>\nstruct LazyMontgomeryModInt {\n\tusing mint = LazyMontgomeryModInt;\n\tusing i32 = int32_t;\n\tusing u32 = uint32_t;\n\tusing u64 = uint64_t;\n\n\tstatic constexpr u32 get_r() {\n\t\tu32 ret = mod;\n\t\tfor (i32 i = 0; i < 4; ++i) ret *= 2 - mod * ret;\n\t\treturn ret;\n\t}\n\n\tstatic constexpr u32 r = get_r();\n\tstatic constexpr u32 n2 = -u64(mod) % mod;\n\tstatic_assert(r * mod == 1, \"invalid, r * mod != 1\");\n\tstatic_assert(mod < (1 << 30), \"invalid, mod >= 2 ^ 30\");\n\tstatic_assert((mod & 1) == 1, \"invalid, mod % 2 == 0\");\n\n\tu32 a;\n\n\tconstexpr LazyMontgomeryModInt() : a(0) {}\n\tconstexpr LazyMontgomeryModInt(const int64_t &b)\n\t\t\t: a(reduce(u64(b % mod + mod) * n2)){};\n\n\tstatic constexpr u32 reduce(const u64 &b) {\n\t\treturn (b + u64(u32(b) * u32(-r)) * mod) >> 32;\n\t}\n\n\tconstexpr mint &operator+=(const mint &b) {\n\t\tif (i32(a += b.a - 2 * mod) < 0) a += 2 * mod;\n\t\treturn *this;\n\t}\n\n\tconstexpr mint &operator-=(const mint &b) {\n\t\tif (i32(a -= b.a) < 0) a += 2 * mod;\n\t\treturn *this;\n\t}\n\n\tconstexpr mint &operator*=(const mint &b) {\n\t\ta = reduce(u64(a) * b.a);\n\t\treturn *this;\n\t}\n\n\tconstexpr mint &operator/=(const mint &b) {\n\t\t*this *= b.inv();\n\t\treturn *this;\n\t}\n\n\tconstexpr mint operator+(const mint &b) const { return mint(*this) += b; }\n\tconstexpr mint operator-(const mint &b) const { return mint(*this) -= b; }\n\tconstexpr mint operator*(const mint &b) const { return mint(*this) *= b; }\n\tconstexpr mint operator/(const mint &b) const { return mint(*this) /= b; }\n\tconstexpr bool operator==(const mint &b) const {\n\t\treturn (a >= mod ? a - mod : a) == (b.a >= mod ? b.a - mod : b.a);\n\t}\n\tconstexpr bool operator!=(const mint &b) const {\n\t\treturn (a >= mod ? a - mod : a) != (b.a >= mod ? b.a - mod : b.a);\n\t}\n\tconstexpr mint operator-() const { return mint() - mint(*this); }\n\n\tconstexpr mint pow(u64 n) const {\n\t\tmint ret(1), mul(*this);\n\t\twhile (n > 0) {\n\t\t\tif (n & 1) ret *= mul;\n\t\t\tmul *= mul;\n\t\t\tn >>= 1;\n\t\t}\n\t\treturn ret;\n\t}\n\t\n\tconstexpr mint inv() const { return pow(mod - 2); }\n\n\ttemplate <typename _Ostream>\n\tfriend _Ostream &operator<<(_Ostream &os, const mint &b) {\n\t\treturn os << b.get();\n\t}\n\n\ttemplate <typename _Istream>\n\tfriend _Istream &operator>>(_Istream &is, mint &b) {\n\t\tint64_t t;\n\t\tis >> t;\n\t\tb = LazyMontgomeryModInt<mod>(t);\n\t\treturn (is);\n\t}\n\t\n\tconstexpr u32 get() const {\n\t\tu32 ret = reduce(a);\n\t\treturn ret >= mod ? ret - mod : ret;\n\t}\n\n\tstatic constexpr u32 get_mod() { return mod; }\n};\n\n#pragma GCC target(\"avx,avx2\")\nusing ymm = __m256i;\nstruct mmint {\n\tymm x;\n\tstatic mmint R, M0, M1, M2, N2;\n\n\tmmint() : x() {}\n\tinline mmint(const ymm& _x) : x(_x) {}\n\tinline mmint(unsigned int a) : x(_mm256_set1_epi32(a)) {}\n\tinline mmint(unsigned int a0, unsigned int a1, unsigned int a2,\n\t\t\t\t\t\t\t unsigned int a3, unsigned int a4, unsigned int a5,\n\t\t\t\t\t\t\t unsigned int a6, unsigned int a7)\n\t\t\t: x(_mm256_set_epi32(a7, a6, a5, a4, a3, a2, a1, a0)) {}\n\tinline operator ymm&() { return x; }\n\tinline operator const ymm&() const { return x; }\n\tinline int& operator[](int i) { return *(reinterpret_cast<int*>(&x) + i); }\n\tinline const int& operator[](int i) const {\n\t\treturn *(reinterpret_cast<const int*>(&x) + i);\n\t}\n\n\ttemplate <typename _Ostream>\n\tfriend _Ostream& operator<<(_Ostream& os, const mmint& m) {\n\t\tunsigned r = R[0], mod = M1[0];\n\t\tauto reduce1 = [&](const uint64_t& b) {\n\t\t\tunsigned res = (b + uint64_t(unsigned(b) * unsigned(-r)) * mod) >> 32;\n\t\t\treturn res >= mod ? res - mod : res;\n\t\t};\n\t\tfor (int i = 0; i < 8; i++) {\n\t\t\tos << reduce1(m[i]) << (i == 7 ? \"\" : \" \");\n\t\t}\n\t\treturn os;\n\t}\n\n\ttemplate <typename mint>\n\tstatic void set_mod() {\n\t\tR = _mm256_set1_epi32(mint::r);\n\t\tM0 = _mm256_setzero_si256();\n\t\tM1 = _mm256_set1_epi32(mint::get_mod());\n\t\tM2 = _mm256_set1_epi32(mint::get_mod() * 2);\n\t\tN2 = _mm256_set1_epi32(mint::n2);\n\t}\n\n\tstatic inline mmint reduce(const mmint& prod02, const mmint& prod13) {\n\t\tymm unpalo = _mm256_unpacklo_epi32(prod02, prod13);\n\t\tymm unpahi = _mm256_unpackhi_epi32(prod02, prod13);\n\t\tymm prodlo = _mm256_unpacklo_epi64(unpalo, unpahi);\n\t\tymm prodhi = _mm256_unpackhi_epi64(unpalo, unpahi);\n\t\tymm hiplm1 = _mm256_add_epi32(prodhi, M1);\n\t\tymm prodlohi = _mm256_shuffle_epi32(prodlo, 0xF5);\n\t\tymm lmlr02 = _mm256_mul_epu32(prodlo, R);\n\t\tymm lmlr13 = _mm256_mul_epu32(prodlohi, R);\n\t\tymm prod02_ = _mm256_mul_epu32(lmlr02, M1);\n\t\tymm prod13_ = _mm256_mul_epu32(lmlr13, M1);\n\t\tymm unpalo_ = _mm256_unpacklo_epi32(prod02_, prod13_);\n\t\tymm unpahi_ = _mm256_unpackhi_epi32(prod02_, prod13_);\n\t\tymm prod = _mm256_unpackhi_epi64(unpalo_, unpahi_);\n\t\treturn _mm256_sub_epi32(hiplm1, prod);\n\t}\n\n\tstatic inline mmint itom(const mmint& A) { return A * N2; }\n\n\tstatic inline mmint mtoi(const mmint& A) {\n\t\tymm A13 = _mm256_shuffle_epi32(A, 0xF5);\n\t\tymm lmlr02 = _mm256_mul_epu32(A, R);\n\t\tymm lmlr13 = _mm256_mul_epu32(A13, R);\n\t\tymm prod02_ = _mm256_mul_epu32(lmlr02, M1);\n\t\tymm prod13_ = _mm256_mul_epu32(lmlr13, M1);\n\t\tymm unpalo_ = _mm256_unpacklo_epi32(prod02_, prod13_);\n\t\tymm unpahi_ = _mm256_unpackhi_epi32(prod02_, prod13_);\n\t\tymm prod = _mm256_unpackhi_epi64(unpalo_, unpahi_);\n\t\tymm cmp = _mm256_cmpgt_epi32(prod, M0);\n\t\tymm dif = _mm256_and_si256(cmp, M1);\n\t\treturn _mm256_sub_epi32(dif, prod);\n\t}\n\n\tfriend inline mmint operator+(const mmint& A, const mmint& B) {\n\t\tymm apb = _mm256_add_epi32(A, B);\n\t\tymm ret = _mm256_sub_epi32(apb, M2);\n\t\tymm cmp = _mm256_cmpgt_epi32(M0, ret);\n\t\tymm add = _mm256_and_si256(cmp, M2);\n\t\treturn _mm256_add_epi32(add, ret);\n\t}\n\n\tfriend inline mmint operator-(const mmint& A, const mmint& B) {\n\t\tymm ret = _mm256_sub_epi32(A, B);\n\t\tymm cmp = _mm256_cmpgt_epi32(M0, ret);\n\t\tymm add = _mm256_and_si256(cmp, M2);\n\t\treturn _mm256_add_epi32(add, ret);\n\t}\n\n\tfriend inline mmint operator*(const mmint& A, const mmint& B) {\n\t\tymm a13 = _mm256_shuffle_epi32(A, 0xF5);\n\t\tymm b13 = _mm256_shuffle_epi32(B, 0xF5);\n\t\tymm prod02 = _mm256_mul_epu32(A, B);\n\t\tymm prod13 = _mm256_mul_epu32(a13, b13);\n\t\treturn reduce(prod02, prod13);\n\t}\n\n\tinline mmint& operator+=(const mmint& A) { return (*this) = (*this) + A; }\n\tinline mmint& operator-=(const mmint& A) { return (*this) = (*this) - A; }\n\tinline mmint& operator*=(const mmint& A) { return (*this) = (*this) * A; }\n\n\tbool operator==(const mmint& A) {\n\t\tymm sub = _mm256_sub_epi32(x, A.x);\n\t\treturn _mm256_testz_si256(sub, sub) == 1;\n\t}\n\tbool operator!=(const mmint& A) { return !((*this) == A); }\n};\nmmint mmint::R;\nmmint mmint::M0, mmint::M1, mmint::M2, mmint::N2;\n\nusing mint = LazyMontgomeryModInt<998244353>;\n\nconstexpr uint32_t mod = mint::get_mod();\nconstexpr uint32_t pr = constexpr_primitive_root(mod);\nconstexpr int level = __builtin_ctzll(mod - 1);\nmint dw[level], dy[level];\n\nvoid setwy(int k) {\n\tmint w[level], y[level];\n\tw[k - 1] = mint(pr).pow((mod - 1) / (1 << k));\n\ty[k - 1] = w[k - 1].inv();\n\tfor (int i = k - 2; i > 0; --i)\n\t\tw[i] = w[i + 1] * w[i + 1], y[i] = y[i + 1] * y[i + 1];\n\tdw[1] = w[1], dy[1] = y[1], dw[2] = w[2], dy[2] = y[2];\n\tfor (int i = 3; i < k; ++i) {\n\t\tdw[i] = dw[i - 1] * y[i - 2] * w[i];\n\t\tdy[i] = dy[i - 1] * w[i - 2] * y[i];\n\t}\n}\n\nvoid ntt(mmint* a, int k) {\n\tif (k & 1) {\n\t\tint v = 1 << (k - 4);\n\t\tfor (int j = 0; j < v; ++j) {\n\t\t\tstatic mmint ajv = a[j + v];\n\t\t\ta[j + v] = a[j] - ajv;\n\t\t\ta[j] += ajv;\n\t\t}\n\t}\n\tint u = 4;\n\tu <<= (k & 1);\n\tint v = 1 << k;\n\tv >>= 2;\n\tv >>= (k & 1);\n\tmint one = mint(1), imag = dw[1];\n\tmmint ONE{one.a}, IMAG{imag.a};\n\n\twhile (v) {\n\t\tif (v == 1) {\n\t\t\tmint W = one, X = one, Y = imag;\n\t\t\tmmint A = a[0];\n\t\t\tmmint B = {one.a, one.a, W.a,\t\t\t\t\t W.a,\n\t\t\t\t\t\t\t\t one.a, one.a, (W * dw[1]).a, (W * dw[1]).a};\n\t\t\tint jh = 0;\n\t\t\tfor (; jh < u - 8; jh += 8) {\n\t\t\t\tmmint T0 = A * B;\n\t\t\t\tmmint T0m = _mm256_sub_epi32(mmint::M2, T0);\n\t\t\t\tmmint T1 = ymm(_mm256_shuffle_ps((__m256)T0m.x, (__m256)T0.x, 0x4E));\n\t\t\t\tmmint C = {one.a, Y.a,\t\t\t\t\t one.a, X.a,\n\t\t\t\t\t\t\t\t\t one.a, (Y * dw[2]).a, one.a, (X * dw[2]).a};\n\t\t\t\tX = X * dw[2];\n\t\t\t\tmmint T2 = (T0 + T1) * C;\n\t\t\t\tX *= dw[__builtin_ctzll(jh + 8)];\n\t\t\t\tW = X * X, Y = X * imag;\n\t\t\t\tmmint T2m = _mm256_sub_epi32(mmint::M2, T2);\n\t\t\t\tmmint T3 = _mm256_shuffle_epi32(T2, 0x88);\n\t\t\t\tA = a[(jh >> 3) + 1];\n\t\t\t\tB = {one.a, one.a, W.a,\t\t\t\t\t W.a,\n\t\t\t\t\t\t one.a, one.a, (W * dw[1]).a, (W * dw[1]).a};\n\t\t\t\tmmint T4 = ymm(_mm256_shuffle_ps((__m256)T2.x, (__m256)T2m.x, 0xDD));\n\t\t\t\tmmint T5 = T3 + T4;\n\t\t\t\ta[jh >> 3] = _mm256_shuffle_epi32(T5, 0x8D);\n\t\t\t}\n\t\t\tmmint T0 = A * B;\n\t\t\tmmint T0m = _mm256_sub_epi32(mmint::M2, T0);\n\t\t\tmmint T1 = ymm(_mm256_shuffle_ps((__m256)T0m.x, (__m256)T0.x, 0x4E));\n\t\t\tmmint C = {one.a, Y.a,\t\t\t\t\t one.a, X.a,\n\t\t\t\t\t\t\t\t one.a, (Y * dw[2]).a, one.a, (X * dw[2]).a};\n\t\t\tmmint T2 = (T0 + T1) * C;\n\t\t\tmmint T2m = _mm256_sub_epi32(mmint::M2, T2);\n\t\t\tmmint T3 = _mm256_shuffle_epi32(T2, 0x88);\n\t\t\tmmint T4 = ymm(_mm256_shuffle_ps((__m256)T2.x, (__m256)T2m.x, 0xDD));\n\t\t\tmmint T5 = T3 + T4;\n\t\t\ta[jh >> 3] = _mm256_shuffle_epi32(T5, 0x8D);\n\t\t} else if (v == 4) {\n\t\t\tmint W = one, X = one, WX = one;\n\t\t\tmmint IMAG1{one.a, one.a, one.a, one.a, imag.a, imag.a, imag.a, imag.a};\n\t\t\tmmint t01 = a[0], t23 = a[1], c01{one.a}, c23{one.a};\n\t\t\tint jh = 0;\n\t\t\tfor (; jh < u - 4; jh += 4) {\n\t\t\t\tX *= dw[__builtin_ctzll(jh + 4)];\n\t\t\t\tmmint tp = t01 + t23, tm = (t01 - t23) * IMAG1;\n\t\t\t\tmmint tpm = _mm256_sub_epi32(mmint::M2, tp);\n\t\t\t\tmmint tmm = _mm256_sub_epi32(mmint::M2, tm);\n\t\t\t\tt01 = a[(jh >> 1) + 2];\n\t\t\t\tt23 = a[(jh >> 1) + 3];\n\t\t\t\tW = X * X, WX = W * X;\n\t\t\t\tc01 = {one.a, one.a, one.a, one.a, X.a, X.a, X.a, X.a};\n\t\t\t\tc23 = {W.a, W.a, W.a, W.a, WX.a, WX.a, WX.a, WX.a};\n\t\t\t\tmmint u0 = _mm256_permute2x128_si256(tp, tpm, 0x00);\n\t\t\t\tmmint u1 = _mm256_permute2x128_si256(tp, tpm, 0x31);\n\t\t\t\tmmint u2 = _mm256_permute2x128_si256(tm, tmm, 0x00);\n\t\t\t\tmmint u3 = _mm256_permute2x128_si256(tm, tmm, 0x31);\n\t\t\t\tt01 *= c01, t23 *= c23;\n\t\t\t\ta[(jh >> 1) | 0] = u0 + u1;\n\t\t\t\ta[(jh >> 1) | 1] = u2 + u3;\n\t\t\t}\n\t\t\tmmint tp = t01 + t23, tm = (t01 - t23) * IMAG1;\n\t\t\tmmint tpm = _mm256_sub_epi32(mmint::M2, tp);\n\t\t\tmmint tmm = _mm256_sub_epi32(mmint::M2, tm);\n\t\t\tmmint u0 = _mm256_permute2x128_si256(tp, tpm, 0x00);\n\t\t\tmmint u1 = _mm256_permute2x128_si256(tp, tpm, 0x31);\n\t\t\tmmint u2 = _mm256_permute2x128_si256(tm, tmm, 0x00);\n\t\t\tmmint u3 = _mm256_permute2x128_si256(tm, tmm, 0x31);\n\t\t\ta[(jh >> 1) | 0] = u0 + u1;\n\t\t\ta[(jh >> 1) | 1] = u2 + u3;\n\t\t} else {\n\t\t\tint v8 = v >> 3;\n\t\t\t{\n\t\t\t\tint j0 = 0, j1 = v8, j2 = j1 + v8, j3 = j2 + v8;\n\t\t\t\tint je = v8 - 1;\n\t\t\t\tmmint t0 = a[j0], t1 = a[j1];\n\t\t\t\tmmint t2 = a[j2], t3 = a[j3];\n\t\t\t\tfor (; j0 < je; ++j0, ++j1, ++j2, ++j3) {\n\t\t\t\t\tmmint t0p2 = t0 + t2, t1p3 = t1 + t3;\n\t\t\t\t\tmmint t0m2 = t0 - t2, t1m3 = (t1 - t3) * IMAG;\n\t\t\t\t\tt0 = a[j0 + 1], t1 = a[j1 + 1];\n\t\t\t\t\tt2 = a[j2 + 1], t3 = a[j3 + 1];\n\t\t\t\t\ta[j0] = t0p2 + t1p3, a[j1] = t0p2 - t1p3;\n\t\t\t\t\ta[j2] = t0m2 + t1m3, a[j3] = t0m2 - t1m3;\n\t\t\t\t}\n\t\t\t\tmmint t0p2 = t0 + t2, t1p3 = t1 + t3;\n\t\t\t\tmmint t0m2 = t0 - t2, t1m3 = (t1 - t3) * IMAG;\n\t\t\t\ta[j0] = t0p2 + t1p3, a[j1] = t0p2 - t1p3;\n\t\t\t\ta[j2] = t0m2 + t1m3, a[j3] = t0m2 - t1m3;\n\t\t\t}\n\t\t\tmmint W{one.a}, X{dw[2].a}, Y{one.a};\n\t\t\tfor (int jh = 4; jh < u;) {\n\t\t\t\tW = X * X, Y = X * IMAG;\n\t\t\t\tint j0 = jh * v8, j1 = j0 + v8, j2 = j1 + v8, j3 = j2 + v8;\n\t\t\t\tint je = j0 + v8 - 1;\n\t\t\t\tmmint t0, t1, t2, t3;\n\t\t\t\tt0 = a[j0], t1 = a[j1];\n\t\t\t\tt2 = a[j2] * W, t3 = a[j3] * W;\n\t\t\t\tfor (; j0 < je; ++j0, ++j1, ++j2, ++j3) {\n\t\t\t\t\tmmint t0p2 = t0 + t2, t1p3 = (t1 + t3) * X;\n\t\t\t\t\tmmint t0m2 = t0 - t2, t1m3 = (t1 - t3) * Y;\n\t\t\t\t\tt0 = a[j0 + 1], t1 = a[j1 + 1];\n\t\t\t\t\tt2 = a[j2 + 1] * W, t3 = a[j3 + 1] * W;\n\t\t\t\t\ta[j0] = t0p2 + t1p3, a[j1] = t0p2 - t1p3;\n\t\t\t\t\ta[j2] = t0m2 + t1m3, a[j3] = t0m2 - t1m3;\n\t\t\t\t}\n\t\t\t\tmmint t0p2 = t0 + t2, t1p3 = (t1 + t3) * X;\n\t\t\t\tmmint t0m2 = t0 - t2, t1m3 = (t1 - t3) * Y;\n\t\t\t\ta[j0] = t0p2 + t1p3, a[j1] = t0p2 - t1p3;\n\t\t\t\ta[j2] = t0m2 + t1m3, a[j3] = t0m2 - t1m3;\n\t\t\t\tX *= mmint{dw[__builtin_ctzll((jh += 4))].a};\n\t\t\t}\n\t\t}\n\t\tu <<= 2;\n\t\tv >>= 2;\n\t}\n}\n\nvoid intt(mmint* a, int k) {\n\tint u = 1 << k;\n\tu >>= 2;\n\tint v = 1;\n\tmint one = mint(1), imag = dy[1];\n\tmmint ONE{one.a}, IMAG{imag.a};\n\twhile (u) {\n\t\tif (v == 1) {\n\t\t\tu <<= 2;\n\t\t\tmint W = one, X = one, Y = one;\n\t\t\tfor (int jh = 0; jh < u;) {\n\t\t\t\tW = X * X, Y = X * imag;\n\t\t\t\tmmint& A = a[jh >> 3];\n\t\t\t\tmint t0, t1, t2, t3, t4, t5, t6, t7;\n\t\t\t\tt0.a = A[0], t1.a = A[1], t2.a = A[2], t3.a = A[3];\n\t\t\t\tt4.a = A[4], t5.a = A[5], t6.a = A[6], t7.a = A[7];\n\t\t\t\tmint t0p1 = t0 + t1, t2p3 = t2 + t3;\n\t\t\t\tmint t0m1 = (t0 - t1) * X, t2m3 = (t2 - t3) * Y;\n\t\t\t\tA[0] = (t0p1 + t2p3).a;\n\t\t\t\tA[1] = (t0m1 + t2m3).a;\n\t\t\t\tA[2] = ((t0p1 - t2p3) * W).a;\n\t\t\t\tA[3] = ((t0m1 - t2m3) * W).a;\n\t\t\t\tX *= dy[2], W *= dy[1], Y *= dy[2];\n\t\t\t\tmint t4p5 = t4 + t5, t6p7 = t6 + t7;\n\t\t\t\tmint t4m5 = (t4 - t5) * X, t6m7 = (t6 - t7) * Y;\n\t\t\t\tA[4] = (t4p5 + t6p7).a;\n\t\t\t\tA[5] = (t4m5 + t6m7).a;\n\t\t\t\tA[6] = ((t4p5 - t6p7) * W).a;\n\t\t\t\tA[7] = ((t4m5 - t6m7) * W).a;\n\t\t\t\tX *= dy[__builtin_ctzll(jh += 8)];\n\t\t\t}\n\t\t} else if (v == 4) {\n\t\t\tu <<= 2;\n\t\t\tmint W = one, X = one, Y = one;\n\n\t\t\tfor (int jh = 0; jh < u;) {\n\t\t\t\tW = X * X, Y = X * imag;\n\t\t\t\tmmint c23{X.a, X.a, X.a, X.a, Y.a, Y.a, Y.a, Y.a};\n\t\t\t\tmmint Ws{W.a};\n\t\t\t\tmmint t01 = a[(jh >> 1) | 0];\n\t\t\t\tmmint t23 = a[(jh >> 1) | 1];\n\t\t\t\tmmint t02 = _mm256_permute2x128_si256(t01, t23, 0x20);\n\t\t\t\tmmint t13 = _mm256_permute2x128_si256(t01, t23, 0x31);\n\t\t\t\tmmint tp = t02 + t13, tm = (t02 - t13) * c23;\n\t\t\t\tmmint u0 = _mm256_permute2x128_si256(tp, tm, 0x20);\n\t\t\t\tmmint u1 = _mm256_permute2x128_si256(tp, tm, 0x31);\n\t\t\t\ta[(jh >> 1) | 0] = u0 + u1;\n\t\t\t\ta[(jh >> 1) | 1] = (u0 - u1) * Ws;\n\t\t\t\tX *= dy[__builtin_ctzll((jh += 4))];\n\t\t\t}\n\t\t} else {\n\t\t\tint v8 = v >> 3;\n\t\t\tu <<= 2;\n\t\t\t{\n\t\t\t\tint j0 = 0, j1 = v8, j2 = j1 + v8, j3 = j2 + v8;\n\t\t\t\tint je = v8 - 1;\n\t\t\t\tmmint t0 = a[j0], t1 = a[j1];\n\t\t\t\tmmint t2 = a[j2], t3 = a[j3];\n\t\t\t\tfor (; j0 < je; ++j0, ++j1, ++j2, ++j3) {\n\t\t\t\t\tmmint t0p1 = t0 + t1, t2p3 = t2 + t3;\n\t\t\t\t\tmmint t0m1 = t0 - t1, t2m3 = (t2 - t3) * IMAG;\n\t\t\t\t\tt0 = a[j0 + 1], t1 = a[j1 + 1];\n\t\t\t\t\tt2 = a[j2 + 1], t3 = a[j3 + 1];\n\t\t\t\t\ta[j0] = t0p1 + t2p3, a[j1] = t0m1 + t2m3;\n\t\t\t\t\ta[j2] = t0p1 - t2p3, a[j3] = t0m1 - t2m3;\n\t\t\t\t}\n\t\t\t\tmmint t0p1 = t0 + t1, t2p3 = t2 + t3;\n\t\t\t\tmmint t0m1 = t0 - t1, t2m3 = (t2 - t3) * IMAG;\n\t\t\t\ta[j0] = t0p1 + t2p3, a[j1] = t0m1 + t2m3;\n\t\t\t\ta[j2] = t0p1 - t2p3, a[j3] = t0m1 - t2m3;\n\t\t\t}\n\t\t\tmmint W{one.a}, X{dy[2].a}, Y{one.a};\n\t\t\tfor (int jh = 4; jh < u;) {\n\t\t\t\tW = X * X, Y = X * IMAG;\n\t\t\t\tint j0 = jh * v8, j1 = j0 + v8, j2 = j1 + v8, j3 = j2 + v8;\n\t\t\t\tint je = j0 + v8 - 1;\n\t\t\t\tmmint t0 = a[j0], t1 = a[j1];\n\t\t\t\tmmint t2 = a[j2], t3 = a[j3];\n\t\t\t\tfor (; j0 < je; ++j0, ++j1, ++j2, ++j3) {\n\t\t\t\t\tmmint t0p1 = t0 + t1, t2p3 = t2 + t3;\n\t\t\t\t\tmmint t0m1 = (t0 - t1) * X, t2m3 = (t2 - t3) * Y;\n\t\t\t\t\tt0 = a[j0 + 1], t1 = a[j1 + 1];\n\t\t\t\t\tt2 = a[j2 + 1], t3 = a[j3 + 1];\n\t\t\t\t\ta[j0] = t0p1 + t2p3, a[j1] = t0m1 + t2m3;\n\t\t\t\t\ta[j2] = (t0p1 - t2p3) * W, a[j3] = (t0m1 - t2m3) * W;\n\t\t\t\t}\n\t\t\t\tmmint t0p1 = t0 + t1, t2p3 = t2 + t3;\n\t\t\t\tmmint t0m1 = (t0 - t1) * X, t2m3 = (t2 - t3) * Y;\n\t\t\t\ta[j0] = t0p1 + t2p3, a[j1] = t0m1 + t2m3;\n\t\t\t\ta[j2] = (t0p1 - t2p3) * W, a[j3] = (t0m1 - t2m3) * W;\n\t\t\t\tX *= mmint{dy[__builtin_ctzll(jh += 4)].a};\n\t\t\t}\n\t\t}\n\t\tu >>= 4;\n\t\tv <<= 2;\n\t}\n\tif (k & 1) {\n\t\tu = 1 << k;\n\t\tu >>= 4;\n\t\tfor (int j = 0; j < u; ++j) {\n\t\t\tmmint ajv = a[j] - a[j + u];\n\t\t\ta[j] += a[j + u];\n\t\t\ta[j + u] = ajv;\n\t\t}\n\t}\n}\n\nmmint a[1 << 15], b[1 << 15];\n\nvoid inline_multiply(int M, int k) {\n\tsetwy(k);\n\tntt(a, k), ntt(b, k);\n\tfor (int i = 0; i < M >> 3; i += 8) {\n\t\ta[i + 0] *= b[i + 0];\n\t\ta[i + 1] *= b[i + 1];\n\t\ta[i + 2] *= b[i + 2];\n\t\ta[i + 3] *= b[i + 3];\n\t\ta[i + 4] *= b[i + 4];\n\t\ta[i + 5] *= b[i + 5];\n\t\ta[i + 6] *= b[i + 6];\n\t\ta[i + 7] *= b[i + 7];\n\t}\n\tintt(a, k);\n}\n\nint main() {\n\tmmint::set_mod<mint>();\n\tint n, m;\n\tunsigned int x, *p;\n\n\tcin >> n >> m, n++, m++;\n\n int i = 0;\n\tp = (unsigned int*)a;\n\tfor (i = 0; i < n; ++i, ++p) cin >> x, *p = x;\n\tp = (unsigned int*)b;\n\tfor (i = 0; i < m; ++i, ++p) cin >> x, *p = x;\n\n\tif (n + m < 1e4 && n * m <= 1e7) {\n\t\tlong long *c = new long long[n + m];\n\t\tfor (i = 0; i < n; i++) {\n\t\t\tfor (int j = 0; j < m; j++) {\n\t\t\t\tc[i + j] += 1LL * a[i >> 3][i & 7] * b[j >> 3][j & 7];\n\t\t\t\tc[i + j] %= 998244353;\n\t\t\t}\n\t\t}\n\t\tfor (i = 0; i < n + m - 1; i++) cout << c[i] << \" \\n\"[i == n + m - 2];\n\t\treturn 0;\n\t}\n\n\tint k = 2, M = 4, l = n + m - 1;\n\twhile (M < l) M <<= 1, ++k;\n\tfor (i = 0; i < n >> 3; ++i) {\n\t\ta[i] = mmint::itom(a[i]);\n\t}\n\tswitch (n & 7) {\n case 7: a[i] = mmint::itom(a[i]), i++;\n case 6: a[i] = mmint::itom(a[i]), i++;\n case 5: a[i] = mmint::itom(a[i]), i++;\n case 4: a[i] = mmint::itom(a[i]), i++;\n case 3: a[i] = mmint::itom(a[i]), i++;\n case 2: a[i] = mmint::itom(a[i]), i++;\n case 1: a[i] = mmint::itom(a[i]), i++;\n\t}\n\tfor (int i = 0; i < m >> 3; ++i) {\n\t\tb[i] = mmint::itom(b[i]);\n\t}\n\tswitch (m & 7) {\n case 7: b[i] = mmint::itom(b[i]), i++;\n case 6: b[i] = mmint::itom(b[i]), i++;\n case 5: b[i] = mmint::itom(b[i]), i++;\n case 4: b[i] = mmint::itom(b[i]), i++;\n case 3: b[i] = mmint::itom(b[i]), i++;\n case 2: b[i] = mmint::itom(b[i]), i++;\n case 1: b[i] = mmint::itom(b[i]), i++;\n\t}\n\tinline_multiply(M, k);\n\tmmint im{(mint(M).inv()).a};\n\tfor (int i = 0; i < M >> 3; ++i) {\n\t\ta[i] *= im;\n\t\ta[i] = mmint::mtoi(a[i]);\n\t}\n\n\tp = (unsigned int*)a;\n\tcout << *p;\n\tp++;\n\tfor (int i = 1; i < l; i++, p++) {\n\t\tcout << ' ' << *p;\n\t}\n}",
"status": [
"CE"
],
"details": [
"/tmp/_my_pojsjr1_8rk/d075e81e-da4b-4a15-9029-a556dbf0bbab.cpp: In function ‘mmint operator*(const mmint&, const mmint&)’:\n/tmp/_my_pojsjr1_8rk/d075e81e-da4b-4a15-9029-a556dbf0bbab.cpp:605:51: warning: AVX vector return without AVX enabled changes the ABI [-Wpsabi]\n 605 | ymm prod02 = _mm256_mul_epu32(A, B);\n | ^\nIn file included from /usr/lib/gcc/x86_64-linux-gnu/12/include/immintrin.h:47,\n from /tmp/_my_pojsjr1_8rk/d075e81e-da4b-4a15-9029-a556dbf0bbab.cpp:16:\n/usr/lib/gcc/x86_64-linux-gnu/12/include/avx2intrin.h: In function ‘mmint operator+(const mmint&, const mmint&)’:\n/usr/lib/gcc/x86_64-linux-gnu/12/include/avx2intrin.h:119:1: error: inlining failed in call to ‘always_inline’ ‘__m256i _mm256_add_epi32(__m256i, __m256i)’: target specific option mismatch\n 119 | _mm256_add_epi32 (__m256i __A, __m256i __B)\n | ^~~~~~~~~~~~~~~~\n/tmp/_my_pojsjr1_8rk/d075e81e-da4b-4a15-9029-a556dbf0bbab.cpp:592:40: note: called from here\n 592 | return _mm256_add_epi32(add, ret);\n | ~~~~~~~~~~~~~~~~^~~~~~~~~~\n/usr/lib/gcc/x86_64-linux-gnu/12/include/avx2intrin.h:179:1: error: inlining failed in call to ‘always_inline’ ‘__m256i _mm256_and_si256(__m256i, __m256i)’: target specific option mismatch\n 179 | _mm256_and_si256 (__m256i __A, __m256i __B)\n | ^~~~~~~~~~~~~~~~\n/tmp/_my_pojsjr1_8rk/d075e81e-da4b-4a15-9029-a556dbf0bbab.cpp:591:43: note: called from here\n 591 | ymm add = _mm256_and_si256(cmp, M2);\n | ~~~~~~~~~~~~~~~~^~~~~~~~~\n/usr/lib/gcc/x86_64-linux-gnu/12/include/avx2intrin.h:273:1: error: inlining failed in call to ‘always_inline’ ‘__m256i _mm256_cmpgt_epi32(__m256i, __m256i)’: target specific option mismatch\n 273 | _mm256_cmpgt_epi32 (__m256i __A, __m256i __B)\n | ^~~~~~~~~~~~~~~~~~\n/tmp/_my_pojsjr1_8rk/d075e81e-da4b-4a15-9029-a556dbf0bbab.cpp:590:45: note: called from here\n 590 | ymm cmp = _mm256_cmpgt_epi32(M0, ret);\n | ~~~~~~~~~~~~~~~~~~^~~~~~~~~\n/usr/lib/gcc/x86_64-linux-gnu/12/include/avx2intrin.h:815:1: error: inlining failed in call to ‘always_inline’ ‘__m256i _mm256_sub_epi32(__m256i, __m256i)’: target specific option mismatch\n 815 | _mm256_sub_epi32 (__m256i __A, __m256i __B)\n | ^~~~~~~~~~~~~~~~\n/tmp/_my_pojsjr1_8rk/d075e81e-da4b-4a15-9029-a556dbf0bbab.cpp:589:43: note: called from here\n 589 | ymm ret = _mm256_sub_epi32(apb, M2);\n | ~~~~~~~~~~~~~~~~^~~~~~~~~\n/usr/lib/gcc/x86_64-linux-gnu/12/include/avx2intrin.h:119:1: error: inlining failed in call to ‘always_inline’ ‘__m256i _mm256_add_epi32(__m256i, __m256i)’: target specific option mismatch\n 119 | _mm256_add_epi32 (__m256i __A, __m256i __B)\n | ^~~~~~~~~~~~~~~~\n/tmp/_my_pojsjr1_8rk/d075e81e-da4b-4a15-9029-a556dbf0bbab.cpp:588:43: note: called from here\n 588 | ymm apb = _mm256_add_epi32(A, B);\n | ~~~~~~~~~~~~~~~~^~~~~~\n"
],
"tcb_id": "多项式乘法",
"query": "# 多项式乘法\n## 题目描述\n\r\n\r\n输入两个多项式,输出这两个多项式的乘积。\n## 输入格式\n第一行两个整数 $ n $ 和 $ m $,分别表示两个多项式的次数。\r\n\r\n第二行 $ n + 1 $ 个整数,分别表示第一个多项式的 $ 0 $ 到 $ n $ 次项前的系数。\r\n\r\n第三行 $ m + 1 $ 个整数,分别表示第二个多项式的 $ 0 $ 到 $ m $ 次项前的系数。\n## 输出格式\n一行 $ n + m + 1 $ 个整数,分别表示乘起来后的多项式的 $ 0 $ 到 $ n + m $ 次项前的系数。\n## 样例\n输入:\n1 2\n1 2\n1 2 1\n输出:\n1 4 5 2\n\n\n## 数据范围与提示\n$ 0 \\leq n, m \\leq 10 ^ 5 $,保证输入中的系数大于等于 $ 0 $ 且小于等于 $ 9 $。",
"sample": {
"input": "1 2\n1 2\n1 2 1",
"output": "1 4 5 2"
}
},
{
"code_id": 4,
"code": "var\r\nc:array[0..100000] of longint;\r\nn,m,i,p,k:longint;\r\nch:char;\r\nfunction lowbit(x:longint):longint;\r\nbegin\r\n lowbit:=x and -x;\r\nend;\r\nprocedure add(i,x:longint);\r\nbegin\r\n while i<=n do\r\n begin\r\n inc(c[i],x);\r\n i:=i+lowbit(i);\r\n end;\r\nend;\r\nfunction get(x:longint):longint;\r\nbegin\r\n get:=0;\r\n while x>=1 do\r\n begin\r\n get:=get+c[x];\r\n x:=x-lowbit(x);\r\n end;\r\nend;\r\nbegin\r\n readln(n,k);\r\n for i:=1 to k do\r\n begin\r\n read(ch);\r\n case ch of\r\n 'A':\r\n begin\r\n readln(m);\r\n writeln(get(m));\r\n end;\r\n 'B':\r\n begin\r\n readln(m,p);\r\n add(m,p);\r\n end;\r\n 'C':\r\n begin\r\n readln(m,p);\r\n add(m,-p);\r\n end;\r\n end; \r\n end;\r\nend.",
"status": [
"EXE"
],
"details": "'std'",
"tcb_id": "清点人数",
"query": "# 清点人数\n## 题目描述\nNK 中学组织同学们去五云山寨参加社会实践活动,按惯例要乘坐火车去。由于 NK 中学的学生很多,在火车开之前必须清点好人数。 \r\n\r\n初始时,火车上没有学生。当同学们开始上火车时,年级主任从第一节车厢出发走到最后一节车厢,每节车厢随时都有可能有同学上下。年级主任走到第 $m$ 节车厢时,他想知道前 $m$ 节车厢上一共有多少学生,但是他没有调头往回走的习惯。也就是说每次当他提问时,$m$ 总会比前一次大。\n## 输入格式\n第一行两个整数 $n,k$,表示火车共有 $n$ 节车厢以及 $k$ 个事件。\r\n\r\n接下来有 $k$ 行,按时间先后给出 $k$ 个事件,每行开头都有一个字母 `A`,`B` 或 `C`。\r\n+ 如果字母为 `A`,接下来是一个数 $m$,表示年级主任现在在第 $m$ 节车厢;\r\n+ 如果字母为 `B`,接下来是两个数 $m,p$,表示在第 $m$ 节车厢有 $p$ 名学生上车;\r\n+ 如果字母为 `C`,接下来是两个数 $m,p$,表示在第 $m$ 节车厢有 $p$ 名学生下车。\r\n\r\n学生总人数不会超过 $10^5$。\n## 输出格式\n对于每个 `A` ,输出一行,一个整数,表示年级主任的问题的答案。\n## 样例\n输入:\n10 7\nA 1\nB 1 1\nB 3 1\nB 4 1\nA 2\nA 3\nA 10\n输出:\n0\n1\n2\n3\n\n\n## 数据范围与提示\n对于 $100\\%$ 的数据,$1\\le n\\le 5\\times 10^5,1\\le k\\le 10^5$,至少有 $3\\times 10^4$ 个 `A`。",
"sample": {
"input": "10 7\nA 1\nB 1 1\nB 3 1\nB 4 1\nA 2\nA 3\nA 10",
"output": "0\n1\n2\n3"
}
},
{
"code_id": 3,
"code": "#ifndef _MENCI_AVL_TREE_H\n\n#define _MENCI_AVL_TREE_H\n\n\n\n#include <stdbool.h>\n\n#include <stddef.h>\n\n\n\ntypedef int (*compare_function_t)(void *, void *);\n\ntypedef void (*destruct_function_t)(void *);\n\ntypedef struct _avl_node_t *avl_node_t;\n\ntypedef struct _avl_tree_t *avl_tree_t;\n\n\n\navl_tree_t avl_create(compare_function_t compare_function, destruct_function_t destruct_function);\n\nvoid avl_destroy(avl_tree_t tree);\n\nsize_t avl_size(avl_tree_t tree);\n\navl_node_t avl_insert(avl_tree_t tree, void *data);\n\nvoid *avl_get_data(avl_node_t node);\n\navl_node_t avl_find(avl_tree_t tree, void *data);\n\navl_node_t avl_find_by_order(avl_tree_t tree, int order);\n\nint avl_get_order(avl_tree_t tree, void *data);\n\nint avl_get_order_of_node(avl_node_t node);\n\nvoid avl_delete_node(avl_node_t node);\n\nbool avl_delete_data(avl_tree_t tree, void *data);\n\n\n\navl_node_t avl_lower_bound(avl_tree_t tree, void *data);\n\navl_node_t avl_upper_bound(avl_tree_t tree, void *data);\n\navl_node_t avl_node_predecessor(avl_node_t node);\n\navl_node_t avl_node_successor(avl_node_t node);\n\n\n\n#endif // _MENCI_AVL_TREE_H\n\n#ifndef _MENCI_AVL_TREE_INTERNEL_H\n\n#define _MENCI_AVL_TREE_INTERNEL_H\n\n\n\n// #include \"avl-tree.h\"\n\n\n\nstruct _avl_node_t {\n\n struct _avl_node_t *left_child;\n\n struct _avl_node_t *right_child;\n\n struct _avl_node_t *parent;\n\n\n\n // The data field.\n\n void *data;\n\n\n\n // The height of the subtree with this node as its root.\n\n int height;\n\n\n\n // The count of nodes in this subtree.\n\n size_t size;\n\n\n\n // The reference to its tree, to replace the root node when rotated to root.\n\n struct _avl_tree_t *tree;\n\n};\n\n\n\nstruct _avl_tree_t {\n\n // The root node of the tree.\n\n avl_node_t root;\n\n\n\n // The compare function, to determine the order of nodes' data.\n\n compare_function_t compare_function;\n\n\n\n // The destruct function, to destruct and free nodes' data.\n\n destruct_function_t destruct_function;\n\n};\n\n\n\ntypedef enum {\n\n LEFT = 0, RIGHT = 1\n\n} _avl_which_child_t;\n\n\n\n// Validate and print a subtree, for debugging.\n\nvoid _avl_debug(avl_node_t node, bool print, int depth);\n\n\n\n// Compare two data or node's data, compare by unsigned long if\n\n// compare_function is NULL or call the compare_function if non-NULL.\n\nint _avl_compare_data(compare_function_t compare_function, void *a, void *b);\n\nint _avl_compare_node(avl_node_t a, avl_node_t b);\n\n\n\n// Destroy a node or a subtree.\n\nvoid _avl_destroy_node(avl_node_t node);\n\nvoid _avl_destroy_subtree(avl_node_t node);\n\n\n\n// Recalculate a node's height and size after rotating, rebalancing, insertion\n\n// or deletion.\n\nvoid _avl_recalculate(avl_node_t node);\n\n\n\n// Rotate a node up, to take its parent's place.\n\n// e.g. Left rotate will let one's right-child take its place of subtree root.\n\nvoid _avl_rotate(avl_node_t node);\n\n\n\n// Do a rebalance on a subtree's root level, used when abs(balance factor) = 2.\n\nvoid _avl_rebalance(avl_node_t subtree_root, avl_node_t new_node);\n\n\n\n// Insert a node to a node's subtree.\n\nvoid _avl_insert_node(avl_node_t *subtree_root,\n\n avl_node_t parent,\n\n avl_node_t new_node);\n\n\n\ntypedef enum {\n\n // Doing a lower_bound binary search means skip all nodes less than specfied data.\n\n // So skip all nodes that compare(node->data, data) <= -1.\n\n // For the same reason, doing a upper_bound binary search skips all nodes that\n\n // compare() <= 0.\n\n // So skip nodes that compare() <= search_type will do the magic.\n\n LOWER_BOUND = -1,\n\n UPPER_BOUND = 0\n\n} _avl_search_type_t;\n\n\n\n// Binary Search a data, return found node according to search_type.\n\navl_node_t _avl_binary_search(avl_node_t root,\n\n void *data,\n\n _avl_search_type_t search_type);\n\n\n\n// Get a node's in-order predecessor or successor.\n\n// direction = LEFT means predecessor, RIGHT means successor.\n\navl_node_t _avl_neighbour(avl_node_t node, _avl_which_child_t direction);\n\n\n\n// Swap two node's position.\n\nvoid _avl_swap(avl_node_t a, avl_node_t b);\n\n\n\n// Delete a node, while maintaining the balance.\n\nvoid _avl_delete_rebalance(avl_node_t node);\n\nvoid _avl_delete(avl_node_t node);\n\n\n\nint _avl_get_order(avl_node_t node);\n\n\n\n#endif // _MENCI_AVL_TREE_INTERNEL_H\n\n// #include \"avl-tree-internel.h\"\n\n\n\n#include <assert.h>\n\n#include <stdlib.h>\n\n#include <stdio.h>\n\n\n\n#define _avl_which_child(node) \\\n\n ((node) == (node)->parent->left_child ? LEFT : RIGHT)\n\n#define _avl_get_child(node, which) \\\n\n (*((which) == LEFT ? (&(node)->left_child) : (&(node)->right_child)))\n\n#define _avl_subtree_height(node) ((node) ? ((node)->height) : 0)\n\n\n\nvoid _avl_debug(avl_node_t node, bool print, int depth) {\n\n if (!node) return;\n\n\n\n if (print && !depth) puts(\"-------------------\");\n\n\n\n int right_height = 0;\n\n size_t right_size = 0;\n\n if (node->right_child) {\n\n assert(node->right_child->parent == node);\n\n _avl_debug(node->right_child, print, depth + 1);\n\n right_height = node->right_child->height;\n\n right_size = node->right_child->size;\n\n }\n\n\n\n if (print) {\n\n for (int i = 0; i < depth; i++) fputs(\" \", stdout);\n\n printf(\"%lu\\n\", (unsigned long)node->data);\n\n }\n\n\n\n int left_height = 0;\n\n size_t left_size = 0;\n\n if (node->left_child) {\n\n assert(node->left_child->parent == node);\n\n _avl_debug(node->left_child, print, depth + 1);\n\n left_height = node->left_child->height;\n\n left_size = node->left_child->size;\n\n }\n\n\n\n\n\n if (print && !depth) puts(\"-------------------\");\n\n\n\n int max = left_height < right_height ? right_height : left_height;\n\n assert(node->height == max + 1);\n\n assert(node->size == left_size + right_size + 1);\n\n assert(abs(left_height - right_height) < 2);\n\n}\n\n\n\nint _avl_compare_data(compare_function_t compare_function, void *a, void *b) {\n\n if (a == b) return 0;\n\n if (compare_function) {\n\n return compare_function(a, b);\n\n }\n\n\n\n return (unsigned long)a < (unsigned long)b ? -1 : 1;\n\n}\n\n\n\nint _avl_compare_node(avl_node_t a, avl_node_t b) {\n\n assert(a && b && a->tree == b->tree);\n\n if (a == b) return 0;\n\n return _avl_compare_data(a->tree->compare_function, a->data, b->data);\n\n}\n\n\n\nvoid _avl_destroy_node(avl_node_t node) {\n\n if (node->tree->destruct_function) {\n\n node->tree->destruct_function(node->data);\n\n }\n\n\n\n free(node);\n\n}\n\n\n\nvoid _avl_destroy_subtree(avl_node_t node) {\n\n if (node->left_child) _avl_destroy_subtree(node->left_child);\n\n if (node->right_child) _avl_destroy_subtree(node->right_child);\n\n _avl_destroy_node(node);\n\n}\n\n\n\nvoid _avl_recalculate(avl_node_t node) {\n\n assert(node);\n\n\n\n int max_height = 0;\n\n node->size = 1;\n\n\n\n if (node->left_child) {\n\n if (node->left_child->height > max_height)\n\n max_height = node->left_child->height;\n\n node->size += node->left_child->size;\n\n }\n\n if (node->right_child) {\n\n if (node->right_child->height > max_height)\n\n max_height = node->right_child->height;\n\n node->size += node->right_child->size;\n\n }\n\n \n\n node->height = max_height + 1;\n\n}\n\n\n\nvoid _avl_rotate(avl_node_t node) {\n\n assert(node && node->parent);\n\n\n\n avl_node_t old_parent = node->parent;\n\n\n\n _avl_which_child_t which = _avl_which_child(node), another = !which;\n\n\n\n // Connect self to old parent's parent.\n\n node->parent = old_parent->parent;\n\n if (old_parent->parent)\n\n _avl_get_child(old_parent->parent, _avl_which_child(old_parent)) = node;\n\n \n\n // Connect self's another child to old parent\n\n if (_avl_get_child(node, another)) {\n\n _avl_get_child(node, another)->parent = old_parent;\n\n }\n\n _avl_get_child(old_parent, which) = _avl_get_child(node, another);\n\n\n\n // Connect old parent to self\n\n old_parent->parent = node;\n\n _avl_get_child(node, another) = old_parent;\n\n\n\n // Notice that the ancestors of old_parent's height are NOT recalculated.\n\n _avl_recalculate(old_parent);\n\n _avl_recalculate(node);\n\n\n\n // Check if rotated to root.\n\n if (!node->parent) {\n\n node->tree->root = node;\n\n }\n\n}\n\n\n\nvoid _avl_insert_node(avl_node_t *subtree_root,\n\n avl_node_t parent,\n\n avl_node_t new_node) {\n\n if (!*subtree_root) {\n\n new_node->parent = parent;\n\n *subtree_root = new_node;\n\n return;\n\n }\n\n\n\n avl_node_t current = *subtree_root;\n\n\n\n if (_avl_compare_node(new_node, current) <= 0) {\n\n // new data <= current node's data\n\n _avl_insert_node(&current->left_child, current, new_node);\n\n\n\n // Check balance.\n\n if (_avl_subtree_height(current->left_child) - \n\n _avl_subtree_height(current->right_child) == 2) {\n\n // The balance has been broken, rebalance it.\n\n // Check which child of left-child it's inserted to.\n\n if (_avl_compare_node(new_node, current->left_child) <= 0) {\n\n // The Left-Left case.\n\n _avl_rotate(current->left_child);\n\n } else {\n\n // The Left-Right case.\n\n _avl_rotate(current->left_child->right_child);\n\n _avl_rotate(current->left_child);\n\n }\n\n }\n\n } else {\n\n // new data > current node's data\n\n _avl_insert_node(&current->right_child, current, new_node);\n\n\n\n // Check balance.\n\n if (_avl_subtree_height(current->right_child) - \n\n _avl_subtree_height(current->left_child) == 2) {\n\n // The balance has been broken, rebalance it.\n\n // Check which child of right-child it's inserted to.\n\n if (_avl_compare_node(new_node, current->right_child) <= 0) {\n\n // The Right-Left case.\n\n _avl_rotate(current->right_child->left_child);\n\n _avl_rotate(current->right_child);\n\n } else {\n\n // The Right-Right case.\n\n _avl_rotate(current->right_child);\n\n }\n\n }\n\n }\n\n\n\n _avl_recalculate(*subtree_root);\n\n}\n\n\n\navl_node_t _avl_binary_search(avl_node_t root,\n\n void *data,\n\n _avl_search_type_t search_type) {\n\n if (!root) return NULL;\n\n\n\n int compare_result = _avl_compare_data(root->tree->compare_function,\n\n root->data,\n\n data);\n\n\n\n // Since we should find the first satisfied node, search in the left\n\n // subtree if satisfied.\n\n bool satisfied = compare_result > search_type;\n\n if (satisfied) {\n\n avl_node_t left_subtree_result = _avl_binary_search(root->left_child,\n\n data,\n\n search_type);\n\n // If a more left satisfied node was found, return it.\n\n if (left_subtree_result) return left_subtree_result;\n\n else return root;\n\n } else {\n\n return _avl_binary_search(root->right_child,\n\n data,\n\n search_type);\n\n }\n\n}\n\n\n\navl_node_t _avl_neighbour(avl_node_t node, _avl_which_child_t direction) {\n\n assert(node);\n\n\n\n // Imagine a traversal on the tree. We are on the node now and willing to\n\n // move to the in-order (or reversed in-order) next node.\n\n // e.g. find one's successor, with direction = RIGHT.\n\n if (_avl_get_child(node, direction)) {\n\n // If RIGHT subtree, find in the subtree.\n\n // Find the LEFT-most descendant of node's RIGHT subtree.\n\n node = _avl_get_child(node, direction);\n\n while (_avl_get_child(node, !direction)) {\n\n node = _avl_get_child(node, !direction);\n\n }\n\n return node;\n\n } else {\n\n // The RIGHT subtree doesn't exist, backtraces will occur.\n\n if (!node->parent) {\n\n // Backtrace reaches root. No successor found!\n\n return NULL;\n\n }\n\n\n\n while (_avl_which_child(node) == direction) {\n\n // If node is its parent's RIGHT child, after backtracing to parent,\n\n // another backtrace will occur to parent's parent.\n\n if (!node->parent->parent) {\n\n // Backtrace reaches root. No successor found!\n\n return NULL;\n\n }\n\n\n\n node = node->parent;\n\n }\n\n\n\n // If node is its parent's LEFT child, the next to be printed in the\n\n // traversal is just its parent!\n\n return node->parent;\n\n }\n\n}\n\n\n\nvoid _avl_swap(avl_node_t a, avl_node_t b) {\n\n assert(a && b);\n\n\n\n#define _avl_reconnect(parent_node, child, which) { \\\n\n if (parent_node) { \\\n\n _avl_get_child((parent_node), (which)) = (child); \\\n\n } else { \\\n\n assert(child); \\\n\n (child)->tree->root = (child); \\\n\n } \\\n\n if (child) (child)->parent = (parent_node); \\\n\n }\n\n\n\n // If one is another's parent, assume a is b's parent.\n\n if (a->parent == b) {\n\n _avl_swap(b, a);\n\n }\n\n\n\n _avl_which_child_t which_a = a->parent ? _avl_which_child(a) : LEFT,\n\n which_b = b->parent ? _avl_which_child(b) : LEFT;\n\n\n\n if (a == b->parent) {\n\n // If a is b's parent.\n\n avl_node_t c1 = _avl_get_child(b, which_b),\n\n c2 = _avl_get_child(b, !which_b),\n\n c3 = _avl_get_child(a, !which_b);\n\n \n\n _avl_reconnect(a->parent, b, which_a);\n\n\n\n _avl_reconnect(a, c1, which_b);\n\n _avl_reconnect(a, c2, !which_b);\n\n\n\n _avl_reconnect(b, a, which_b);\n\n _avl_reconnect(b, c3, !which_b);\n\n } else {\n\n avl_node_t a_l = a->left_child, a_r = a->right_child,\n\n b_l = b->left_child, b_r = b->right_child;\n\n\n\n avl_node_t a_p = a->parent, b_p = b->parent;\n\n _avl_reconnect(a_p, b, which_a);\n\n _avl_reconnect(b_p, a, which_b);\n\n\n\n _avl_reconnect(a, b_l, LEFT);\n\n _avl_reconnect(a, b_r, RIGHT);\n\n\n\n _avl_reconnect(b, a_l, LEFT);\n\n _avl_reconnect(b, a_r, RIGHT);\n\n }\n\n\n\n#undef _avl_reconnect\n\n}\n\n\n\nvoid _avl_delete_rebalance(avl_node_t node) {\n\n if (!node) return;\n\n\n\n if (_avl_subtree_height(node->left_child) - \n\n _avl_subtree_height(node->right_child) == 2) {\n\n // L - R = 2\n\n\n\n if (_avl_subtree_height(node->left_child->left_child) >=\n\n _avl_subtree_height(node->left_child->right_child)) {\n\n // The Left-Left case.\n\n _avl_rotate(node->left_child);\n\n } else {\n\n // The Left-Right case.\n\n _avl_rotate(node->left_child->right_child);\n\n _avl_rotate(node->left_child);\n\n }\n\n } else if (_avl_subtree_height(node->right_child) - \n\n _avl_subtree_height(node->left_child) == 2) {\n\n // R - L = 2\n\n\n\n if (_avl_subtree_height(node->right_child->left_child) <=\n\n _avl_subtree_height(node->right_child->right_child)) {\n\n // The Right-Right case.\n\n _avl_rotate(node->right_child);\n\n } else {\n\n // The Right-Left case.\n\n _avl_rotate(node->right_child->left_child);\n\n _avl_rotate(node->right_child);\n\n }\n\n }\n\n\n\n _avl_recalculate(node);\n\n _avl_delete_rebalance(node->parent);\n\n}\n\n\n\nvoid _avl_delete(avl_node_t node) {\n\n assert(node);\n\n\n\n while (node->left_child || node->right_child) {\n\n // Both children exist.\n\n // In this case its in-order predecessor or successor must be its descendant.\n\n // Find it's in-order predecessor or successor to take its place.\n\n avl_node_t neighbour = _avl_neighbour(node, node->left_child ? LEFT : RIGHT);\n\n\n\n // Swap the node and its neighbour.\n\n _avl_swap(node, neighbour);\n\n }\n\n\n\n // Now the node has no child, delete it.\n\n if (!node->parent) {\n\n node->tree->root = NULL;\n\n } else {\n\n _avl_get_child(node->parent, _avl_which_child(node)) = NULL;\n\n }\n\n\n\n // Since deleting a node breaks the balance, rebalance it.\n\n _avl_delete_rebalance(node->parent);\n\n\n\n _avl_destroy_node(node);\n\n}\n\n\n\nint _avl_get_order(avl_node_t node) {\n\n assert(node);\n\n \n\n int count = node->left_child ? node->left_child->size : 0;\n\n while (node->parent) {\n\n if (_avl_which_child(node) == RIGHT) {\n\n // If node is a RIGHT child, the parent and parent's LEFT subtree\n\n // is lesser than node, so add them to the count.\n\n if (node->parent->left_child) {\n\n count += node->parent->left_child->size;\n\n }\n\n count++;\n\n }\n\n\n\n node = node->parent;\n\n }\n\n\n\n return count + 1;\n\n}\n\n// #include \"avl-tree.h\"\n\n\n\n#include <stdlib.h>\n\n#include <assert.h>\n\n\n\n// #include \"avl-tree-internel.h\"\n\n\n\navl_tree_t avl_create(compare_function_t compare_function, destruct_function_t destruct_function) {\n\n avl_tree_t tree = malloc(sizeof(struct _avl_tree_t));\n\n tree->root = NULL;\n\n tree->compare_function = compare_function;\n\n tree->destruct_function = destruct_function;\n\n return tree;\n\n}\n\n\n\nvoid avl_destroy(avl_tree_t tree) {\n\n assert(tree);\n\n \n\n if (tree->root) _avl_destroy_subtree(tree->root);\n\n free(tree);\n\n}\n\n\n\nsize_t avl_size(avl_tree_t tree) {\n\n assert(tree);\n\n return tree->root ? tree->root->size : 0;\n\n}\n\n\n\navl_node_t avl_insert(avl_tree_t tree, void *data) {\n\n assert(tree);\n\n\n\n avl_node_t new_node = malloc(sizeof(struct _avl_node_t));\n\n new_node->left_child = new_node->right_child = new_node->parent = NULL;\n\n new_node->data = data;\n\n new_node->height = 1;\n\n new_node->size = 1;\n\n new_node->tree = tree;\n\n \n\n _avl_insert_node(&tree->root, NULL, new_node);\n\n\n\n return new_node;\n\n}\n\n\n\nvoid *avl_get_data(avl_node_t node) {\n\n return node->data;\n\n}\n\n\n\navl_node_t avl_find(avl_tree_t tree, void *data) {\n\n assert(tree);\n\n\n\n if (!tree->root) return NULL;\n\n\n\n avl_node_t node = avl_lower_bound(tree, data);\n\n if (node && node->data == data) return node;\n\n\n\n return NULL;\n\n}\n\n\n\navl_node_t avl_find_by_order(avl_tree_t tree, int order) {\n\n assert(tree);\n\n \n\n avl_node_t node = tree->root;\n\n\n\n // How many nodes should be skipped from the leftist of node's subtree.\n\n int count = order - 1;\n\n while (1) {\n\n if (!node) {\n\n // Not found - order isn't in [1, tree->root->size].\n\n return NULL;\n\n }\n\n\n\n int left_count = node->left_child ? node->left_child->size : 0;\n\n if (count < left_count) {\n\n // Skip part of the left subtree, not the whole left subtree.\n\n // So the node to find must be in the left subtree.\n\n node = node->left_child;\n\n } else if (count > left_count) {\n\n // The whole left subtree should be skipped, and node itself should\n\n // be skipped, too.\n\n // So skip them and find the node in the right subtree.\n\n count -= left_count + 1;\n\n node = node->right_child;\n\n } else {\n\n // The node to skip is exactly the whole left subtree.\n\n // So current node is what we're finding.\n\n return node;\n\n }\n\n }\n\n}\n\n\n\nint avl_get_order(avl_tree_t tree, void *data) {\n\n assert(tree);\n\n\n\n avl_node_t node = avl_find(tree, data);\n\n if (!node) return -1;\n\n return avl_get_order_of_node(node);\n\n}\n\n\n\nint avl_get_order_of_node(avl_node_t node) {\n\n assert(node);\n\n\n\n return _avl_get_order(node);\n\n}\n\n\n\nvoid avl_delete_node(avl_node_t node) {\n\n assert(node);\n\n\n\n _avl_delete(node);\n\n}\n\n\n\nbool avl_delete_data(avl_tree_t tree, void *data) {\n\n assert(tree);\n\n\n\n avl_node_t node = avl_find(tree, data);\n\n if (!node) return false;\n\n\n\n avl_delete_node(node);\n\n return true;\n\n}\n\n\n\navl_node_t avl_lower_bound(avl_tree_t tree, void *data) {\n\n assert(tree);\n\n return _avl_binary_search(tree->root, data, LOWER_BOUND);\n\n}\n\n\n\navl_node_t avl_upper_bound(avl_tree_t tree, void *data) {\n\n assert(tree);\n\n return _avl_binary_search(tree->root, data, UPPER_BOUND);\n\n}\n\n\n\navl_node_t avl_node_predecessor(avl_node_t node) {\n\n assert(node);\n\n return _avl_neighbour(node, LEFT);\n\n}\n\n\n\navl_node_t avl_node_successor(avl_node_t node) {\n\n assert(node);\n\n return _avl_neighbour(node, RIGHT);\n\n}\n\n// #include \"avl-tree.h\"\n\n\n\n#include <stdio.h>\n\n#include <assert.h>\n\n\n\n#define data_type_from_int(x) ((void *)(long)(x))\n\n#define data_type_to_int(x) ((int)(long)(x))\n\n\n\nint compare(void *a, void *b) {\n\n return data_type_to_int(a) - data_type_to_int(b);\n\n}\n\n\n\nint main() {\n\n avl_tree_t tree = avl_create(&compare, NULL);\n\n\n\n int n;\n\n assert(scanf(\"%d\", &n) == 1);\n\n assert(n >= 1 && n <= (int)3e5);\n\n\n\n for (int i = 0; i < n; i++) {\n\n int option, x;\n\n assert(scanf(\"%d %d\", &option, &x) == 2);\n\n assert(option >= 0 && option <= 5);\n\n\n\n if (option == 0) {\n\n avl_insert(tree, data_type_from_int(x));\n\n } else if (option == 1) {\n\n avl_delete_data(tree, data_type_from_int(x));\n\n } else if (option == 2) {\n\n avl_node_t node = avl_find_by_order(tree, x);\n\n assert(node);\n\n printf(\"%d\\n\", data_type_to_int(avl_get_data(node)));\n\n } else if (option == 3) {\n\n avl_node_t node = avl_lower_bound(tree, data_type_from_int(x));\n\n int answer;\n\n if (node) {\n\n answer = avl_get_order_of_node(node) - 1;\n\n } else {\n\n answer = avl_size(tree);\n\n }\n\n printf(\"%d\\n\", answer);\n\n } else if (option == 4) {\n\n avl_node_t node = avl_lower_bound(tree, data_type_from_int(x)),\n\n predecessor = node ? avl_node_predecessor(node) : NULL;\n\n if (predecessor) {\n\n printf(\"%d\\n\", data_type_to_int(avl_get_data(predecessor)));\n\n } else {\n\n puts(\"-1\");\n\n }\n\n } else if (option == 5) {\n\n avl_node_t successor = avl_upper_bound(tree, data_type_from_int(x));\n\n if (successor) {\n\n printf(\"%d\\n\", data_type_to_int(avl_get_data(successor)));\n\n } else {\n\n puts(\"-1\");\n\n }\n\n }\n\n }\n\n}\n\n",
"status": [
"CE"
],
"details": [
"/tmp/_my_pojcxcps6pp/b961af76-a4e2-4d14-823a-03dafc79d99f.cpp:263:12: error: expected ‘)’ before ‘==’ token\n 263 | ((node) == (node)->parent->left_child ? LEFT : RIGHT)\n | ~ ^~~\n | )\n/tmp/_my_pojcxcps6pp/b961af76-a4e2-4d14-823a-03dafc79d99f.cpp: In function ‘void _avl_rotate(avl_node_t)’:\n/tmp/_my_pojcxcps6pp/b961af76-a4e2-4d14-823a-03dafc79d99f.cpp:455:54: error: expected primary-expression before ‘,’ token\n 455 | _avl_which_child_t which = _avl_which_child(node), another = !which;\n | ^\n/tmp/_my_pojcxcps6pp/b961af76-a4e2-4d14-823a-03dafc79d99f.cpp:465:74: error: expected primary-expression before ‘=’ token\n 465 | _avl_get_child(old_parent->parent, _avl_which_child(old_parent)) = node;\n | ^\n/tmp/_my_pojcxcps6pp/b961af76-a4e2-4d14-823a-03dafc79d99f.cpp:471:38: error: expected primary-expression before ‘)’ token\n 471 | if (_avl_get_child(node, another)) {\n | ^\n/tmp/_my_pojcxcps6pp/b961af76-a4e2-4d14-823a-03dafc79d99f.cpp:473:38: error: expected primary-expression before ‘->’ token\n 473 | _avl_get_child(node, another)->parent = old_parent;\n | ^~\n/tmp/_my_pojcxcps6pp/b961af76-a4e2-4d14-823a-03dafc79d99f.cpp:477:39: error: expected primary-expression before ‘=’ token\n 477 | _avl_get_child(old_parent, which) = _avl_get_child(node, another);\n | ^\n/tmp/_my_pojcxcps6pp/b961af76-a4e2-4d14-823a-03dafc79d99f.cpp:477:70: error: expected primary-expression before ‘;’ token\n 477 | _avl_get_child(old_parent, which) = _avl_get_child(node, another);\n | ^\n/tmp/_my_pojcxcps6pp/b961af76-a4e2-4d14-823a-03dafc79d99f.cpp:485:35: error: expected primary-expression before ‘=’ token\n 485 | _avl_get_child(node, another) = old_parent;\n | ^\n/tmp/_my_pojcxcps6pp/b961af76-a4e2-4d14-823a-03dafc79d99f.cpp: In function ‘_avl_node_t* _avl_neighbour(avl_node_t, _avl_which_child_t)’:\n/tmp/_my_pojcxcps6pp/b961af76-a4e2-4d14-823a-03dafc79d99f.cpp:677:40: error: expected primary-expression before ‘)’ token\n 677 | if (_avl_get_child(node, direction)) {\n | ^\n/tmp/_my_pojcxcps6pp/b961af76-a4e2-4d14-823a-03dafc79d99f.cpp:683:47: error: expected primary-expression before ‘;’ token\n 683 | node = _avl_get_child(node, direction);\n | ^\n/tmp/_my_pojcxcps6pp/b961af76-a4e2-4d14-823a-03dafc79d99f.cpp:685:48: error: expected primary-expression before ‘)’ token\n 685 | while (_avl_get_child(node, !direction)) {\n | ^\n/tmp/_my_pojcxcps6pp/b961af76-a4e2-4d14-823a-03dafc79d99f.cpp:687:52: error: expected primary-expression before ‘;’ token\n 687 | node = _avl_get_child(node, !direction);\n | ^\n/tmp/_my_pojcxcps6pp/b961af76-a4e2-4d14-823a-03dafc79d99f.cpp:707:39: error: expected primary-expression before ‘==’ token\n 707 | while (_avl_which_child(node) == direction) {\n | ^~\n/tmp/_my_pojcxcps6pp/b961af76-a4e2-4d14-823a-03dafc79d99f.cpp: In function ‘void _avl_swap(avl_node_t, avl_node_t)’:\n/tmp/_my_pojcxcps6pp/b961af76-a4e2-4d14-823a-03dafc79d99f.cpp:749:13: error: ‘parent_node’ was not declared in this scope\n 749 | if (parent_node) { \\\n | ^~~~~~~~~~~\n/tmp/_my_pojcxcps6pp/b961af76-a4e2-4d14-823a-03dafc79d99f.cpp:751:52: error: expected primary-expression before ‘=’ token\n 751 | _avl_get_child((parent_node), (which)) = (child); \\\n | ^\n/tmp/_my_pojcxcps6pp/b961af76-a4e2-4d14-823a-03dafc79d99f.cpp:751:55: error: ‘child’ was not declared in this scope\n 751 | _avl_get_child((parent_node), (which)) = (child); \\\n | ^~~~~\nIn file included from /tmp/_my_pojcxcps6pp/b961af76-a4e2-4d14-823a-03dafc79d99f.cpp:253:\n/tmp/_my_pojcxcps6pp/b961af76-a4e2-4d14-823a-03dafc79d99f.cpp:755:20: error: ‘child’ was not declared in this scope\n 755 | assert(child); \\\n | ^~~~~\n/tmp/_my_pojcxcps6pp/b961af76-a4e2-4d14-823a-03dafc79d99f.cpp:761:13: error: ‘child’ was not declared in this scope\n 761 | if (child) (child)->parent = (parent_node); \\\n | ^~~~~\n/tmp/_my_pojcxcps6pp/b961af76-a4e2-4d14-823a-03dafc79d99f.cpp:761:39: error: ‘parent_node’ was not declared in this scope\n 761 | if (child) (child)->parent = (parent_node); \\\n | ^~~~~~~~~~~\n/tmp/_my_pojcxcps6pp/b961af76-a4e2-4d14-823a-03dafc79d99f.cpp: At global scope:\n/tmp/_my_pojcxcps6pp/b961af76-a4e2-4d14-823a-03dafc79d99f.cpp:769:5: error: expected unqualified-id before ‘if’\n 769 | if (a->parent == b) {\n | ^~\n/tmp/_my_pojcxcps6pp/b961af76-a4e2-4d14-823a-03dafc79d99f.cpp:777:34: error: ‘a’ was not declared in this scope\n 777 | _avl_which_child_t which_a = a->parent ? _avl_which_child(a) : LEFT,\n | ^\n/tmp/_my_pojcxcps6pp/b961af76-a4e2-4d14-823a-03dafc79d99f.cpp:783:5: error: expected unqualified-id before ‘if’\n 783 | if (a == b->parent) {\n | ^~\n/tmp/_my_pojcxcps6pp/b961af76-a4e2-4d14-823a-03dafc79d99f.cpp: In function ‘_avl_node_t* _avl_neighbour(avl_node_t, _avl_which_child_t)’:\n/tmp/_my_pojcxcps6pp/b961af76-a4e2-4d14-823a-03dafc79d99f.cpp:737:1: warning: control reaches end of non-void function [-Wreturn-type]\n 737 | }\n | ^\n"
],
"tcb_id": "维护全序集",
"query": "# 维护全序集\n## 题目描述\n\n\n如未特别说明,以下所有数据均为整数。\n\n维护一个多重集 $ S $ ,初始为空,有以下几种操作:\n\n1. 把 $ x $ 加入 $ S $\n2. 删除 $ S $ 中的一个 $ x $,保证删除的 $ x $ 一定存在\n3. 求 $ S $ 中第 $ k $ 小\n4. 求 $ S $ 中有多少个元素小于 $ x $\n5. 求 $ S $ 中小于 $ x $ 的最大数\n6. 求 $ S $ 中大于 $ x $ 的最小数\n\n操作共?$ n?$ 次。\n## 输入格式\n第一行一个整数?$ n $,表示共有?$ n $?次操作?。\n\n接下来?$ n $?行,每行为以下几种格式之一?:\n\n* `0?x`,把?$ x $?加入?$ S $\n* `1?x`,删除?$ S $?中的一个?$ x $,保证删除的数在?$ S $?中一定存在\n* `2?k`,求?$ S?$ 中第??$ k?$ 小的数,保证要求的数在?$ S $?中一定存在\n* `3?x`,求?$ S?$ 中有多少个数小于?$ x?$\n* `4?x`,求?$ S?$ 中小于?$ x?$ 的最大数,如果不存在,输出?$ -1?$\n* `5?x`,求?$ S?$ 中大于?$ x?$ 的最小数,如果不存在,输出?$ -1?$\n## 输出格式\n对于每次询问,输出单独一行表示答案。\n## 样例\n输入:\n5\n0 3\n0 4\n2 2\n1 4\n3 3\n输出:\n4\n0\n\n\n## 数据范围与提示\n$ 1 \\leq n \\leq 3 \\times 10 ^ 5, 0?\\leq x \\leq 10 ^ 9 $\n",
"sample": {
"input": "5\n0 3\n0 4\n2 2\n1 4\n3 3",
"output": "4\n0"
}
},
{
"code_id": -2,
"code": "#include<bits/stdc++.h>\n#include<sys/mman.h>\n#include<fcntl.h>\nusing namespace std;\nusing llt=long long;\nusing llf=long double;\nusing ull=unsigned long long;\n#define Ct const\n#define Il __always_inline\n#define For(i,a,b,c) for(int i=(a);i<=(b);i+=(c))\n#define For_(i,a,b,c) for(int i=(a);i>=(b);i-=(c))\n#define For_it(i,a,b) for(auto i=(a);i!=(b);++i)\n\nnamespace IO{\n#ifdef ONLINE_JUDGE\n\tint Fin=fileno(stdin); FILE* Fout=stdout;\n#elif defined(UN_FAST)\n\tFILE *Fin=freopen(\"in_out/in.in\",\"r\",stdin),*Fout=freopen(\"in_out/out.out\",\"w\",stdout);\n#else\n\tint Fin=open(\"in_out/in.in\",0); FILE *Fout=freopen(\"in_out/out.out\",\"w\",stdout);\n#endif // file\n#ifdef UN_FAST\n\tchar cc;\n\t#define G (cc=getchar())\n\t#define C cc\n#else\n\tconst char *I=(char*)mmap(0,1<<24,1,2,Fin,0)-1; \n\t#define G (*++I)\n\t#define C (*I)\n#endif // fast (mmap)\n#define P(x) putc_unlocked(x,Fout)\n\ttemplate<class T> Il void read(T &x){x=0;bool f=0; while(f|=G==45,C<48); while(x=x*10+(C&15),G>47); f?x=-x:0;}\n\ttemplate<class T> void write(T x){if(x<0) P('-'),x=-x; if(x/10) write(x/10); P('0'+x%10);}\n\tIl void read(char &c){while(G<33); c=C;} void read(char *s){char *p=s-1; while(G<33); while(*++p=C,G>32); *++p='\\0';}\n\tIl void read(string &s){s.clear(); while(G<33); while(s.push_back(C),G>32);}\n\ttemplate<class T=int> Il T read(){T a; return read(a),a;}\n\ttemplate<class T,class ...Argc> Il void read(T &x,Argc &...argc){read(x),read(argc...);}\n\tIl void write(const char &c){P(c);} Il void write(const char *s){for(const char *c=s;*c!='\\0';++c) P(*c);}\n\tIl void write(const string &s){for(const char &c:s) P(c);}\n\ttemplate<class T,class ...Argc> Il void write(const T &x,const Argc &...argc){write(x),write(argc...);}\n\ttemplate<class T> Il void Write(const T &x){write(x),P(' ');} Il void Write(const char &c){P(c); if(c>32) P(' ');}\n\ttemplate<class T,class ...Argc> Il void Write(const T &x,const Argc &...argc){Write(x),Write(argc...);}\n#undef G\n#undef C\n#undef P\n}using IO::read; using IO::write; using IO::Write;\n\nconstexpr int N=2e5+3,Inf=0x3f3f3f3f;\n\nint n,m,cl,cr,wt[N];\nint __cnt,__cnt2;\nstruct Graph{\n\tint hd[N],to[N<<1],nt[N<<1],col[N<<1],tot=1;\n\tIl void Add(Ct int &u,Ct int &v,Ct int &w){col[++tot]=w,to[tot]=v,nt[tot]=hd[u],hd[u]=tot;}\n#define For_to(i,u,v,g) for(int i=g.hd[u],v=g.to[i];i;i=g.nt[i],v=g.to[i])\n}g;\nclass PDIV{\nprivate:\n\tint sz[N],mav[N],rt,dis[N],dep[N],mdp[N],ans;\n\tbool vis[N];\n\tvoid Root(Ct int &u,Ct int &fa,int usz){\n\t\tsz[u]=1,mav[u]=0;\n\t\tFor_to(i,u,v,g) if(v!=fa&&!vis[v]) Root(v,u,usz),sz[u]+=sz[v],mav[u]=max(mav[u],sz[v]);\n\t\tmav[u]=max(mav[u],usz-sz[u]);\n\t\tif(mav[rt]>mav[u]) rt=u;\n\t}\n\tvoid Size(Ct int &u,Ct int &fa){sz[u]=1; For_to(i,u,v,g) if(v!=fa&&!vis[v]) Size(v,u),sz[u]+=sz[v];}\n\tvoid Getu(Ct int &u,Ct int &fa,Ct int &la){\n\t\tFor_to(i,u,v,g) if(v!=fa&&!vis[v]){\n\t\t\tdep[v]=dep[u]+1,dis[v]=dis[u]+(g.col[i]==la?0:wt[g.col[i]]);\n\t\t\tGetu(v,u,g.col[i]); mdp[u]=max(mdp[v]+1,mdp[u]);\n\t\t}\n\t}\n\t\n\tvector<int> ord,cld[N];\n\tclass SORT{\n\tprivate:\n\t\tPDIV *F;\n\t\tbool vis[N]; int ma[N];\n\tpublic:\n\t\tSORT(PDIV *_):F(_){};\n\t\tIl void operator()(){\n\t\t\tFor_to(i,F->rt,v,g) if(!F->vis[v]){\n\t\t\t\tint col=g.col[i];\n\t\t\t\tF->cld[col].push_back(v),ma[col]=max(ma[col],F->mdp[v]);\n\t\t\t\tif(!vis[col]) F->ord.push_back(col),vis[col]=1;\n\t\t\t}\n\t\t\tsort(F->ord.begin(),F->ord.end(),[this](Ct int &a,Ct int &b){return this->ma[a]<this->ma[b];});\n\t\t\tfor(Ct int &c:F->ord)\n\t\t\t\tsort(F->cld[c].begin(),F->cld[c].end(),[this](Ct int &a,Ct int &b){return this->F->mdp[a]<this->F->mdp[b];});\n\t\t\tFor_to(i,F->rt,v,g) if(!F->vis[v]) ma[g.col[i]]=vis[g.col[i]]=0;\n\t\t}\n\t}Sort=SORT(this);\n\n\tclass CALC{\n\tprivate:\n\t\tint mad[N],mas[N],lend,lens,posd,poss;\n\t\tqueue<pair<int,int>> que; PDIV *F;\n\t\tclass Mque{\n\t\tprivate: int que[N],*hd=que+1,*tl=que;\n\t\tpublic:\n\t\t\tIl bool Empty(){return hd>tl;} Il void Clear(){hd=que+1,tl=que;}\n\t\t\tIl void Push(Ct int &p,Ct int *pd){while(!Empty()&&pd[*tl]<=pd[p]) --tl,++__cnt; *++tl=p;}\n\t\t\tIl int Front(Ct int &lim){while(!Empty()&&*hd>lim) ++hd,++__cnt; return Empty()?N-1:*hd;}\n\t\t}qd,qs;\n\t\tIl int Get(Ct int &u,Ct int &col){\n\t\t\tint l=max(0,cl-F->dep[u]);\n\t\t\twhile(posd>=l) qd.Push(posd,mad),--posd;\n\t\t\twhile(poss>=l) qs.Push(poss,mas),--poss;\n\t\t\treturn max(mad[qd.Front(cr-F->dep[u])],mas[qs.Front(cr-F->dep[u])]-wt[col])+F->dis[u];\n\t\t}\n\tpublic:\n\t\tCALC(PDIV *_):F(_){memset(mad,-0x3f,sizeof(mad)),memset(mas,-0x3f,sizeof(mas)),mad[0]=0;}\n\t\tIl void Clr(){For(i,1,lend,1) mad[i]=-Inf; posd=lend=0;}\n\t\tIl void operator()(Ct int &nwc){\n\t\t\t__cnt=0;\n\t\t\tfor(int nw:F->cld[nwc]){\n\t\t\t\tque.emplace(nw,F->rt);\n\t\t\t\twhile(!que.empty()){\n\t\t\t\t\tauto tmp=que.front(); que.pop();\n\t\t\t\t\tint u=tmp.first,fa=tmp.second;\n\t\t\t\t\tF->ans=max(F->ans,Get(u,nwc));\n\t\t\t\t\tFor_to(i,u,v,g) if(!F->vis[v]&&fa!=v) que.emplace(v,u);\n\t\t\t\t\t++__cnt;\n\t\t\t\t}\n\t\t\t\tque.emplace(nw,F->rt);\n\t\t\t\twhile(!que.empty()){\n\t\t\t\t\tauto tmp=que.front(); que.pop();\n\t\t\t\t\tint u=tmp.first,fa=tmp.second;\n\t\t\t\t\tmas[F->dep[u]]=max(mas[F->dep[u]],F->dis[u]),lens=max(lens,F->dep[u]);\n\t\t\t\t\tFor_to(i,u,v,g) if(!F->vis[v]&&fa!=v) que.emplace(v,u);\n\t\t\t\t\t++__cnt;\n\t\t\t\t}\n\t\t\t\tposs=lens,qd.Clear(),qs.Clear();\n\t\t\t}\n\t\t\tlend=max(lend,lens),posd=lend;\n\t\t\tFor(i,1,lens,1) mad[i]=max(mas[i],mad[i]),mas[i]=-Inf; poss=lens=0;\n\t\t}\n\t}Calc=CALC(this);\n\n\tvoid Div(){\n\t\tvis[rt]=1;\n\t\tdis[rt]=dep[rt]=0,Getu(rt,0,0);\n\t\tSort();\n\t\tint pos=0;\n\t\tfor(Ct int &c:ord) Calc(c),cld[c].clear(); Calc.Clr(); ord.clear();\n\t\tSize(rt,0); int u=rt;\n\t\tFor_to(i,u,v,g) if(!vis[v]) rt=0,Root(v,u,sz[v]),Div();\n\t}\npublic:\n\tPDIV(){mav[0]=0x3f3f3f3f,ans=-Inf;}\n\tIl int operator()(){Root(1,0,n),Div(); return ans;}\n}Pdiv;\n\nint main(){\n\tread(n,m,cl,cr);\n\tFor(i,1,m,1) read(wt[i]);\n\tFor(i,1,n-1,1){int u,v,c; read(u,v,c); g.Add(u,v,c),g.Add(v,u,c);}\n\twrite(Pdiv());\n}",
"status": [
"RE"
],
"details": [
"RE: Testcase:0"
],
"tcb_id": "树的难题",
"query": "# 树的难题\n## 题目描述\n给你一棵 $n$ 个点的无根树。\r\n\r\n树上的每条边具有颜色。一共有 $m$ 种颜色,编号为 $1$ 到 $m$,第 $i$ 种颜色的权值为 $c_i$。\r\n\r\n对于一条树上的简单路径,路径上经过的所有边按顺序组成一个颜色序列,序列可以划分成若干个相同颜色段。定义路径权值为颜色序列上每个同颜色段的颜色权值之和。\r\n\r\n请你计算,经过边数在 $l$ 到 $r$ 之间的所有简单路径中,路径权值的最大值。\n## 输入格式\n第一行,四个整数 $n, m, l, r$。 \r\n第二行,$m$ 个整数 $c_1, c_2, \\ldots, c_m$,由空格隔开,依次表示每个颜色的权值。 \r\n接下来 $n-1$ 行,每行三个整数 $u, v, c$,表示点 $u$ 和点 $v$ 之间有一条颜色为 $c$ 的边。\n## 输出格式\n输出一行,一个整数,表示答案。\n## 样例\n### 样例 1\n输入:\n5 3 1 4\n-1 -5 -2\n1 2 1\n1 3 1\n2 4 2\n2 5 3\n输出:\n-1\n\n颜色权值均为负,最优路径为 $(1, 2)$ 或 $(1, 3)$。\n### 样例 2\n输入:\n8 4 3 4\n-7 9 6 1\n1 2 1\n1 3 2\n1 4 1\n2 5 1\n5 6 2\n3 7 1\n3 8 3\n输出:\n11\n\n最优路径为 $(3, 1, 2, 5, 6)$,其颜色序列为 $(2, 1, 1, 2)$。\n## 数据范围与提示\n$ n\\leq 2\times10^5, m\\leq n $",
"test": {
"input": "5 3 1 4\n-1 -5 -2\n1 2 1\n1 3 1\n2 4 2\n2 5 3",
"output": "-1"
}
}
]

Xet Storage Details

Size:
76.9 kB
·
Xet hash:
435f1b41fa6b1e61566cd5f502efa9f44eee677a7b7665f2054a2c28e2aeff96

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.