Search is not available for this dataset
name
stringlengths
2
88
description
stringlengths
31
8.62k
public_tests
dict
private_tests
dict
solution_type
stringclasses
2 values
programming_language
stringclasses
5 values
solution
stringlengths
1
983k
1081_G. Mergesort Strikes Back
Chouti thought about his very first days in competitive programming. When he had just learned to write merge sort, he thought that the merge sort is too slow, so he restricted the maximum depth of recursion and modified the merge sort to the following: <image> Chouti found his idea dumb since obviously, this "merge s...
{ "input": [ "3 2 998244353\n", "9 3 998244353\n", "3 1 998244353\n", "9 4 998244353\n" ], "output": [ "665496236\n", "449209967\n", "499122178\n", "665496237\n" ] }
{ "input": [ "53812 4 967428361\n", "7 2 400166453\n", "75727 16 485722667\n", "65536 10 802338989\n", "65535 12 196344479\n", "5000 4 961162523\n", "13694 5 579788161\n", "99999 14 746231791\n", "14823 8 622667251\n", "65536 1 262776883\n", "65535 4 585040979\n", "1 2 ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const int MAXN = 2e5 + 51; map<int, int> mp; int n, kk, MOD, res, u, v, w, x; int invf[MAXN], pr[MAXN]; inline int read() { register int num = 0, neg = 1; register char ch = getchar(); while (!isdigit(ch) && ch != '-') { ch = getchar(); } if (ch == '-') { ...
1081_G. Mergesort Strikes Back
Chouti thought about his very first days in competitive programming. When he had just learned to write merge sort, he thought that the merge sort is too slow, so he restricted the maximum depth of recursion and modified the merge sort to the following: <image> Chouti found his idea dumb since obviously, this "merge s...
{ "input": [ "3 2 998244353\n", "9 3 998244353\n", "3 1 998244353\n", "9 4 998244353\n" ], "output": [ "665496236\n", "449209967\n", "499122178\n", "665496237\n" ] }
{ "input": [ "53812 4 967428361\n", "7 2 400166453\n", "75727 16 485722667\n", "65536 10 802338989\n", "65535 12 196344479\n", "5000 4 961162523\n", "13694 5 579788161\n", "99999 14 746231791\n", "14823 8 622667251\n", "65536 1 262776883\n", "65535 4 585040979\n", "1 2 ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const int N = 100005; int n, k, P; vector<int> pos; int cnt[N]; void solve(int l, int r, int k) { if (k <= 1 || l == r) { if (cnt[r - l + 1] == 0) pos.emplace_back(r - l + 1); cnt[r - l + 1]++; return; } int mid = (l + r) / 2; solve(l, mid, k - 1); sol...
1081_G. Mergesort Strikes Back
Chouti thought about his very first days in competitive programming. When he had just learned to write merge sort, he thought that the merge sort is too slow, so he restricted the maximum depth of recursion and modified the merge sort to the following: <image> Chouti found his idea dumb since obviously, this "merge s...
{ "input": [ "3 2 998244353\n", "9 3 998244353\n", "3 1 998244353\n", "9 4 998244353\n" ], "output": [ "665496236\n", "449209967\n", "499122178\n", "665496237\n" ] }
{ "input": [ "53812 4 967428361\n", "7 2 400166453\n", "75727 16 485722667\n", "65536 10 802338989\n", "65535 12 196344479\n", "5000 4 961162523\n", "13694 5 579788161\n", "99999 14 746231791\n", "14823 8 622667251\n", "65536 1 262776883\n", "65535 4 585040979\n", "1 2 ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 2; int mod, num1 = 0, num2 = 0, cnt1 = 0, cnt2 = 0, rev[N], sum[N]; void add(int &x, int y) { x += y; if (x >= mod) { x -= mod; } } void sub(int &x, int y) { x -= y; if (x < 0) { x += mod; } } int mul(int x, int y) { return (1ll * x *...
1081_G. Mergesort Strikes Back
Chouti thought about his very first days in competitive programming. When he had just learned to write merge sort, he thought that the merge sort is too slow, so he restricted the maximum depth of recursion and modified the merge sort to the following: <image> Chouti found his idea dumb since obviously, this "merge s...
{ "input": [ "3 2 998244353\n", "9 3 998244353\n", "3 1 998244353\n", "9 4 998244353\n" ], "output": [ "665496236\n", "449209967\n", "499122178\n", "665496237\n" ] }
{ "input": [ "53812 4 967428361\n", "7 2 400166453\n", "75727 16 485722667\n", "65536 10 802338989\n", "65535 12 196344479\n", "5000 4 961162523\n", "13694 5 579788161\n", "99999 14 746231791\n", "14823 8 622667251\n", "65536 1 262776883\n", "65535 4 585040979\n", "1 2 ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const int MAXN = 2e5 + 5; int n, k, mod, cnt[MAXN], inv[MAXN] = {0, 1}, sum[MAXN]; int a, b, ans; inline int read() { int x = 0; char ch = getchar(); while (!isdigit(ch)) ch = getchar(); while (isdigit(ch)) { x = x * 10 + ch - '0'; ch = getchar(); } retu...
1081_G. Mergesort Strikes Back
Chouti thought about his very first days in competitive programming. When he had just learned to write merge sort, he thought that the merge sort is too slow, so he restricted the maximum depth of recursion and modified the merge sort to the following: <image> Chouti found his idea dumb since obviously, this "merge s...
{ "input": [ "3 2 998244353\n", "9 3 998244353\n", "3 1 998244353\n", "9 4 998244353\n" ], "output": [ "665496236\n", "449209967\n", "499122178\n", "665496237\n" ] }
{ "input": [ "53812 4 967428361\n", "7 2 400166453\n", "75727 16 485722667\n", "65536 10 802338989\n", "65535 12 196344479\n", "5000 4 961162523\n", "13694 5 579788161\n", "99999 14 746231791\n", "14823 8 622667251\n", "65536 1 262776883\n", "65535 4 585040979\n", "1 2 ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 7; int n, k, p, sum, a[2], b[2], inv[N], res[N]; inline void adds(int u) { if (a[0] == 0) a[0] = u; else if (a[0] != u) a[1] = u; if (a[0] == u) b[0]++; if (a[1] == u) b[1]++; } inline void solve(int l, int r, int t) { if (t == 1 || l =...
1081_G. Mergesort Strikes Back
Chouti thought about his very first days in competitive programming. When he had just learned to write merge sort, he thought that the merge sort is too slow, so he restricted the maximum depth of recursion and modified the merge sort to the following: <image> Chouti found his idea dumb since obviously, this "merge s...
{ "input": [ "3 2 998244353\n", "9 3 998244353\n", "3 1 998244353\n", "9 4 998244353\n" ], "output": [ "665496236\n", "449209967\n", "499122178\n", "665496237\n" ] }
{ "input": [ "53812 4 967428361\n", "7 2 400166453\n", "75727 16 485722667\n", "65536 10 802338989\n", "65535 12 196344479\n", "5000 4 961162523\n", "13694 5 579788161\n", "99999 14 746231791\n", "14823 8 622667251\n", "65536 1 262776883\n", "65535 4 585040979\n", "1 2 ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; using ll = long long; template <class t, class u> void chmax(t& first, u second) { if (first < second) first = second; } template <class t, class u> void chmin(t& first, u second) { if (second < first) first = second; } template <class t> using vc = vector<t>; template ...
1081_G. Mergesort Strikes Back
Chouti thought about his very first days in competitive programming. When he had just learned to write merge sort, he thought that the merge sort is too slow, so he restricted the maximum depth of recursion and modified the merge sort to the following: <image> Chouti found his idea dumb since obviously, this "merge s...
{ "input": [ "3 2 998244353\n", "9 3 998244353\n", "3 1 998244353\n", "9 4 998244353\n" ], "output": [ "665496236\n", "449209967\n", "499122178\n", "665496237\n" ] }
{ "input": [ "53812 4 967428361\n", "7 2 400166453\n", "75727 16 485722667\n", "65536 10 802338989\n", "65535 12 196344479\n", "5000 4 961162523\n", "13694 5 579788161\n", "99999 14 746231791\n", "14823 8 622667251\n", "65536 1 262776883\n", "65535 4 585040979\n", "1 2 ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int md; inline void add(int &a, int b) { a += b; if (a >= md) a -= md; } inline void sub(int &a, int b) { a -= b; if (a < 0) a += md; } inline int mul(int a, int b) { return (int)((long long)a * b % md); } inline int power(int a, long long b) { int res = 1; whil...
1081_G. Mergesort Strikes Back
Chouti thought about his very first days in competitive programming. When he had just learned to write merge sort, he thought that the merge sort is too slow, so he restricted the maximum depth of recursion and modified the merge sort to the following: <image> Chouti found his idea dumb since obviously, this "merge s...
{ "input": [ "3 2 998244353\n", "9 3 998244353\n", "3 1 998244353\n", "9 4 998244353\n" ], "output": [ "665496236\n", "449209967\n", "499122178\n", "665496237\n" ] }
{ "input": [ "53812 4 967428361\n", "7 2 400166453\n", "75727 16 485722667\n", "65536 10 802338989\n", "65535 12 196344479\n", "5000 4 961162523\n", "13694 5 579788161\n", "99999 14 746231791\n", "14823 8 622667251\n", "65536 1 262776883\n", "65535 4 585040979\n", "1 2 ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; template <class T> T gi() { T x = 0; bool f = 0; char c = getchar(); while (c != '-' && (c < '0' || c > '9')) c = getchar(); if (c == '-') f = 1, c = getchar(); while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar(); return f ? -x : x; } const int N ...
1081_G. Mergesort Strikes Back
Chouti thought about his very first days in competitive programming. When he had just learned to write merge sort, he thought that the merge sort is too slow, so he restricted the maximum depth of recursion and modified the merge sort to the following: <image> Chouti found his idea dumb since obviously, this "merge s...
{ "input": [ "3 2 998244353\n", "9 3 998244353\n", "3 1 998244353\n", "9 4 998244353\n" ], "output": [ "665496236\n", "449209967\n", "499122178\n", "665496237\n" ] }
{ "input": [ "53812 4 967428361\n", "7 2 400166453\n", "75727 16 485722667\n", "65536 10 802338989\n", "65535 12 196344479\n", "5000 4 961162523\n", "13694 5 579788161\n", "99999 14 746231791\n", "14823 8 622667251\n", "65536 1 262776883\n", "65535 4 585040979\n", "1 2 ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; template <class T1, class T2> inline void chkmin(T1 &x, T2 y) { if (y < x) x = y; } template <class T1, class T2> inline void chkmax(T1 &x, T2 y) { if (y > x) x = y; } const int BUF_SIZE = 1 << 20; char buf[BUF_SIZE], *P1 = buf, *P2 = buf, obuf[BUF_SIZE], *PO = obuf; in...
1081_G. Mergesort Strikes Back
Chouti thought about his very first days in competitive programming. When he had just learned to write merge sort, he thought that the merge sort is too slow, so he restricted the maximum depth of recursion and modified the merge sort to the following: <image> Chouti found his idea dumb since obviously, this "merge s...
{ "input": [ "3 2 998244353\n", "9 3 998244353\n", "3 1 998244353\n", "9 4 998244353\n" ], "output": [ "665496236\n", "449209967\n", "499122178\n", "665496237\n" ] }
{ "input": [ "53812 4 967428361\n", "7 2 400166453\n", "75727 16 485722667\n", "65536 10 802338989\n", "65535 12 196344479\n", "5000 4 961162523\n", "13694 5 579788161\n", "99999 14 746231791\n", "14823 8 622667251\n", "65536 1 262776883\n", "65535 4 585040979\n", "1 2 ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int n, k, mod, cnt[100005], s[100005], inv[100005], L = 100005, R, ans; void divide(int l, int r, int h) { if (h <= 1 || l == r) { cnt[r - l + 1]++, L = min(L, r - l + 1), R = max(R, r - l + 1); return; } int mid = (l + r) >> 1; divide(l, mid, h - 1), divide...
1081_G. Mergesort Strikes Back
Chouti thought about his very first days in competitive programming. When he had just learned to write merge sort, he thought that the merge sort is too slow, so he restricted the maximum depth of recursion and modified the merge sort to the following: <image> Chouti found his idea dumb since obviously, this "merge s...
{ "input": [ "3 2 998244353\n", "9 3 998244353\n", "3 1 998244353\n", "9 4 998244353\n" ], "output": [ "665496236\n", "449209967\n", "499122178\n", "665496237\n" ] }
{ "input": [ "53812 4 967428361\n", "7 2 400166453\n", "75727 16 485722667\n", "65536 10 802338989\n", "65535 12 196344479\n", "5000 4 961162523\n", "13694 5 579788161\n", "99999 14 746231791\n", "14823 8 622667251\n", "65536 1 262776883\n", "65535 4 585040979\n", "1 2 ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int MOD; int inv(long long int n) { long long int r = 1; int e = MOD - 2; while (e > 0) { if (e & 1) r *= n, r %= MOD; e >>= 1; n *= n, n %= MOD; } return r; } map<int, int> occ; vector<pair<int, int> > v; int findSizes(int s, int h) { if ((h == 1) |...
1081_G. Mergesort Strikes Back
Chouti thought about his very first days in competitive programming. When he had just learned to write merge sort, he thought that the merge sort is too slow, so he restricted the maximum depth of recursion and modified the merge sort to the following: <image> Chouti found his idea dumb since obviously, this "merge s...
{ "input": [ "3 2 998244353\n", "9 3 998244353\n", "3 1 998244353\n", "9 4 998244353\n" ], "output": [ "665496236\n", "449209967\n", "499122178\n", "665496237\n" ] }
{ "input": [ "53812 4 967428361\n", "7 2 400166453\n", "75727 16 485722667\n", "65536 10 802338989\n", "65535 12 196344479\n", "5000 4 961162523\n", "13694 5 579788161\n", "99999 14 746231791\n", "14823 8 622667251\n", "65536 1 262776883\n", "65535 4 585040979\n", "1 2 ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const int mxN = 1e5; int n, k, q, l1, l2, c1, c2; long long iv[mxN + 1], pi[mxN + 1], ans; void ms(int l = 0, int r = n - 1, int h = k) { if (h < 2 || l == r) { if (!l1 || r - l + 1 == l1) { l1 = r - l + 1; ++c1; } else { l2 = r - l + 1; ++...
1081_G. Mergesort Strikes Back
Chouti thought about his very first days in competitive programming. When he had just learned to write merge sort, he thought that the merge sort is too slow, so he restricted the maximum depth of recursion and modified the merge sort to the following: <image> Chouti found his idea dumb since obviously, this "merge s...
{ "input": [ "3 2 998244353\n", "9 3 998244353\n", "3 1 998244353\n", "9 4 998244353\n" ], "output": [ "665496236\n", "449209967\n", "499122178\n", "665496237\n" ] }
{ "input": [ "53812 4 967428361\n", "7 2 400166453\n", "75727 16 485722667\n", "65536 10 802338989\n", "65535 12 196344479\n", "5000 4 961162523\n", "13694 5 579788161\n", "99999 14 746231791\n", "14823 8 622667251\n", "65536 1 262776883\n", "65535 4 585040979\n", "1 2 ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; template <class T> inline void in(T &x) { x = 0; char c = getchar(); bool f = 0; while (!isdigit(c)) f |= (c == '-'), c = getchar(); while (isdigit(c)) x = x * 10 + (c ^ '0'), c = getchar(); f ? x = -x : 0; } template <class T> inline void out(T x, const char c ...
1081_G. Mergesort Strikes Back
Chouti thought about his very first days in competitive programming. When he had just learned to write merge sort, he thought that the merge sort is too slow, so he restricted the maximum depth of recursion and modified the merge sort to the following: <image> Chouti found his idea dumb since obviously, this "merge s...
{ "input": [ "3 2 998244353\n", "9 3 998244353\n", "3 1 998244353\n", "9 4 998244353\n" ], "output": [ "665496236\n", "449209967\n", "499122178\n", "665496237\n" ] }
{ "input": [ "53812 4 967428361\n", "7 2 400166453\n", "75727 16 485722667\n", "65536 10 802338989\n", "65535 12 196344479\n", "5000 4 961162523\n", "13694 5 579788161\n", "99999 14 746231791\n", "14823 8 622667251\n", "65536 1 262776883\n", "65535 4 585040979\n", "1 2 ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; using ll = long long; using vi = vector<int>; using vvi = vector<vi>; using vll = vector<ll>; using vvll = vector<vll>; using vb = vector<bool>; using vs = vector<string>; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); int MOD; struct modnum { int v;...
1081_G. Mergesort Strikes Back
Chouti thought about his very first days in competitive programming. When he had just learned to write merge sort, he thought that the merge sort is too slow, so he restricted the maximum depth of recursion and modified the merge sort to the following: <image> Chouti found his idea dumb since obviously, this "merge s...
{ "input": [ "3 2 998244353\n", "9 3 998244353\n", "3 1 998244353\n", "9 4 998244353\n" ], "output": [ "665496236\n", "449209967\n", "499122178\n", "665496237\n" ] }
{ "input": [ "53812 4 967428361\n", "7 2 400166453\n", "75727 16 485722667\n", "65536 10 802338989\n", "65535 12 196344479\n", "5000 4 961162523\n", "13694 5 579788161\n", "99999 14 746231791\n", "14823 8 622667251\n", "65536 1 262776883\n", "65535 4 585040979\n", "1 2 ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int n, k, mo; int n1, n2, len, ans = 0; int Sum(int x, int y) { x += y; return (x >= mo) ? x - mo : x; } int Sub(int x, int y) { x -= y; return (x < 0) ? x + mo : x; } int Mul(int x, int y) { return (long long)x * y % mo; } int Pow(int x, int y = mo - 2) { int z =...
1081_G. Mergesort Strikes Back
Chouti thought about his very first days in competitive programming. When he had just learned to write merge sort, he thought that the merge sort is too slow, so he restricted the maximum depth of recursion and modified the merge sort to the following: <image> Chouti found his idea dumb since obviously, this "merge s...
{ "input": [ "3 2 998244353\n", "9 3 998244353\n", "3 1 998244353\n", "9 4 998244353\n" ], "output": [ "665496236\n", "449209967\n", "499122178\n", "665496237\n" ] }
{ "input": [ "53812 4 967428361\n", "7 2 400166453\n", "75727 16 485722667\n", "65536 10 802338989\n", "65535 12 196344479\n", "5000 4 961162523\n", "13694 5 579788161\n", "99999 14 746231791\n", "14823 8 622667251\n", "65536 1 262776883\n", "65535 4 585040979\n", "1 2 ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 10; int n, k, q, inv[N], sum[N]; map<int, int> cnt; void divide(int l, int r, int k) { if (l == r || k <= 1) { ++cnt[r - l + 1]; return; } int mid = (l + r) >> 1; divide(l, mid, k - 1); divide(mid + 1, r, k - 1); } int ans; int calc(int...
1081_G. Mergesort Strikes Back
Chouti thought about his very first days in competitive programming. When he had just learned to write merge sort, he thought that the merge sort is too slow, so he restricted the maximum depth of recursion and modified the merge sort to the following: <image> Chouti found his idea dumb since obviously, this "merge s...
{ "input": [ "3 2 998244353\n", "9 3 998244353\n", "3 1 998244353\n", "9 4 998244353\n" ], "output": [ "665496236\n", "449209967\n", "499122178\n", "665496237\n" ] }
{ "input": [ "53812 4 967428361\n", "7 2 400166453\n", "75727 16 485722667\n", "65536 10 802338989\n", "65535 12 196344479\n", "5000 4 961162523\n", "13694 5 579788161\n", "99999 14 746231791\n", "14823 8 622667251\n", "65536 1 262776883\n", "65535 4 585040979\n", "1 2 ...
CORRECT
cpp
#include <bits/stdc++.h> #pragma GCC optimize("O2,Ofast,inline,unroll-all-loops,-ffast-math") #pragma GCC target("popcnt") using namespace std; int n, k; long long inv[100010], sum[100010], p, ans = 0; map<int, int> M; template <class T> void read(T &x) { char ch = x = 0; bool fl = false; while (!isdigit(ch)) fl ...
1081_G. Mergesort Strikes Back
Chouti thought about his very first days in competitive programming. When he had just learned to write merge sort, he thought that the merge sort is too slow, so he restricted the maximum depth of recursion and modified the merge sort to the following: <image> Chouti found his idea dumb since obviously, this "merge s...
{ "input": [ "3 2 998244353\n", "9 3 998244353\n", "3 1 998244353\n", "9 4 998244353\n" ], "output": [ "665496236\n", "449209967\n", "499122178\n", "665496237\n" ] }
{ "input": [ "53812 4 967428361\n", "7 2 400166453\n", "75727 16 485722667\n", "65536 10 802338989\n", "65535 12 196344479\n", "5000 4 961162523\n", "13694 5 579788161\n", "99999 14 746231791\n", "14823 8 622667251\n", "65536 1 262776883\n", "65535 4 585040979\n", "1 2 ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; using ll = long long; using vi = vector<int>; using vvi = vector<vi>; using vll = vector<ll>; using vvll = vector<vll>; using vb = vector<bool>; using vs = vector<string>; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); int MOD; struct modnum { int v;...
1081_G. Mergesort Strikes Back
Chouti thought about his very first days in competitive programming. When he had just learned to write merge sort, he thought that the merge sort is too slow, so he restricted the maximum depth of recursion and modified the merge sort to the following: <image> Chouti found his idea dumb since obviously, this "merge s...
{ "input": [ "3 2 998244353\n", "9 3 998244353\n", "3 1 998244353\n", "9 4 998244353\n" ], "output": [ "665496236\n", "449209967\n", "499122178\n", "665496237\n" ] }
{ "input": [ "53812 4 967428361\n", "7 2 400166453\n", "75727 16 485722667\n", "65536 10 802338989\n", "65535 12 196344479\n", "5000 4 961162523\n", "13694 5 579788161\n", "99999 14 746231791\n", "14823 8 622667251\n", "65536 1 262776883\n", "65535 4 585040979\n", "1 2 ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; inline void proc_status() { ifstream t("/proc/self/status"); cerr << string(istreambuf_iterator<char>(t), istreambuf_iterator<char>()) << endl; } template <typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; } template <typename T> i...
1081_G. Mergesort Strikes Back
Chouti thought about his very first days in competitive programming. When he had just learned to write merge sort, he thought that the merge sort is too slow, so he restricted the maximum depth of recursion and modified the merge sort to the following: <image> Chouti found his idea dumb since obviously, this "merge s...
{ "input": [ "3 2 998244353\n", "9 3 998244353\n", "3 1 998244353\n", "9 4 998244353\n" ], "output": [ "665496236\n", "449209967\n", "499122178\n", "665496237\n" ] }
{ "input": [ "53812 4 967428361\n", "7 2 400166453\n", "75727 16 485722667\n", "65536 10 802338989\n", "65535 12 196344479\n", "5000 4 961162523\n", "13694 5 579788161\n", "99999 14 746231791\n", "14823 8 622667251\n", "65536 1 262776883\n", "65535 4 585040979\n", "1 2 ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 10; map<int, int> st; int n, h, mod, inv[maxn]; int qpow(int a, int b) { int ans = 1; for (; b; b >>= 1, a = 1ll * a * a % mod) if (b & 1) ans = 1ll * ans * a % mod; return ans; } void sol(int l, int r, int h) { if (r - l + 1 <= 1 || h <= ...
1081_G. Mergesort Strikes Back
Chouti thought about his very first days in competitive programming. When he had just learned to write merge sort, he thought that the merge sort is too slow, so he restricted the maximum depth of recursion and modified the merge sort to the following: <image> Chouti found his idea dumb since obviously, this "merge s...
{ "input": [ "3 2 998244353\n", "9 3 998244353\n", "3 1 998244353\n", "9 4 998244353\n" ], "output": [ "665496236\n", "449209967\n", "499122178\n", "665496237\n" ] }
{ "input": [ "53812 4 967428361\n", "7 2 400166453\n", "75727 16 485722667\n", "65536 10 802338989\n", "65535 12 196344479\n", "5000 4 961162523\n", "13694 5 579788161\n", "99999 14 746231791\n", "14823 8 622667251\n", "65536 1 262776883\n", "65535 4 585040979\n", "1 2 ...
CORRECT
cpp
#include <bits/stdc++.h> int q, I[200010]; long long inv(int a, int p) { return a == 1 ? 1 : (1 + p * (a - inv(p % a, a))) / a % p; } int f(int a, int b) { int s = 0; for (int i = 0; i < a + b - 1; i++) s = (s + ((i + 1 < a ? i + 1 : a) - (i - b + 1 > 0 ? i - b + 1 : 0)) * 1ll * i % q * I[i +...
1081_G. Mergesort Strikes Back
Chouti thought about his very first days in competitive programming. When he had just learned to write merge sort, he thought that the merge sort is too slow, so he restricted the maximum depth of recursion and modified the merge sort to the following: <image> Chouti found his idea dumb since obviously, this "merge s...
{ "input": [ "3 2 998244353\n", "9 3 998244353\n", "3 1 998244353\n", "9 4 998244353\n" ], "output": [ "665496236\n", "449209967\n", "499122178\n", "665496237\n" ] }
{ "input": [ "53812 4 967428361\n", "7 2 400166453\n", "75727 16 485722667\n", "65536 10 802338989\n", "65535 12 196344479\n", "5000 4 961162523\n", "13694 5 579788161\n", "99999 14 746231791\n", "14823 8 622667251\n", "65536 1 262776883\n", "65535 4 585040979\n", "1 2 ...
CORRECT
cpp
#include <bits/stdc++.h> const int N = 2e5 + 5; int n, k, mo, ans, inv[N], i, cnt[N], mn = N; void dfs(int l, int r, int h) { if (l == r || h <= 1) { ++cnt[r - l + 1]; mn = std::min(mn, r - l + 1); return; } int m = l + r >> 1; dfs(l, m, h - 1); dfs(m + 1, r, h - 1); } inline int calc(int x, int y...
1081_G. Mergesort Strikes Back
Chouti thought about his very first days in competitive programming. When he had just learned to write merge sort, he thought that the merge sort is too slow, so he restricted the maximum depth of recursion and modified the merge sort to the following: <image> Chouti found his idea dumb since obviously, this "merge s...
{ "input": [ "3 2 998244353\n", "9 3 998244353\n", "3 1 998244353\n", "9 4 998244353\n" ], "output": [ "665496236\n", "449209967\n", "499122178\n", "665496237\n" ] }
{ "input": [ "53812 4 967428361\n", "7 2 400166453\n", "75727 16 485722667\n", "65536 10 802338989\n", "65535 12 196344479\n", "5000 4 961162523\n", "13694 5 579788161\n", "99999 14 746231791\n", "14823 8 622667251\n", "65536 1 262776883\n", "65535 4 585040979\n", "1 2 ...
CORRECT
cpp
#include <bits/stdc++.h> char ch; bool fs; void re(int& x) { while (ch = getchar(), ch < 33) ; if (ch == '-') fs = 1, x = 0; else fs = 0, x = ch - 48; while (ch = getchar(), ch > 33) x = x * 10 + ch - 48; if (fs) x = -x; } using namespace std; int n, k, mod, ans, inv[200001], sum[200001]; map<int,...
1081_G. Mergesort Strikes Back
Chouti thought about his very first days in competitive programming. When he had just learned to write merge sort, he thought that the merge sort is too slow, so he restricted the maximum depth of recursion and modified the merge sort to the following: <image> Chouti found his idea dumb since obviously, this "merge s...
{ "input": [ "3 2 998244353\n", "9 3 998244353\n", "3 1 998244353\n", "9 4 998244353\n" ], "output": [ "665496236\n", "449209967\n", "499122178\n", "665496237\n" ] }
{ "input": [ "53812 4 967428361\n", "7 2 400166453\n", "75727 16 485722667\n", "65536 10 802338989\n", "65535 12 196344479\n", "5000 4 961162523\n", "13694 5 579788161\n", "99999 14 746231791\n", "14823 8 622667251\n", "65536 1 262776883\n", "65535 4 585040979\n", "1 2 ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; inline int read() { char c = getchar(); int x = 0; bool f = 0; for (; !isdigit(c); c = getchar()) f ^= !(c ^ 45); for (; isdigit(c); c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48); if (f) x = -x; return x; } int mod; struct modint { int x; modint(int o ...
1081_G. Mergesort Strikes Back
Chouti thought about his very first days in competitive programming. When he had just learned to write merge sort, he thought that the merge sort is too slow, so he restricted the maximum depth of recursion and modified the merge sort to the following: <image> Chouti found his idea dumb since obviously, this "merge s...
{ "input": [ "3 2 998244353\n", "9 3 998244353\n", "3 1 998244353\n", "9 4 998244353\n" ], "output": [ "665496236\n", "449209967\n", "499122178\n", "665496237\n" ] }
{ "input": [ "53812 4 967428361\n", "7 2 400166453\n", "75727 16 485722667\n", "65536 10 802338989\n", "65535 12 196344479\n", "5000 4 961162523\n", "13694 5 579788161\n", "99999 14 746231791\n", "14823 8 622667251\n", "65536 1 262776883\n", "65535 4 585040979\n", "1 2 ...
CORRECT
cpp
#include <bits/stdc++.h> const int N = 200010; int moder; int inv[N]; int cnt[N]; int pre[N]; int ans; void init() { inv[1] = 1; for (int i = 2; i < N; ++i) { inv[i] = moder - 1ll * (moder / i) * inv[moder % i] % moder; } for (int i = 1; i < N; ++i) { pre[i] = (pre[i - 1] + inv[2] - inv[i]) % moder; ...
1081_G. Mergesort Strikes Back
Chouti thought about his very first days in competitive programming. When he had just learned to write merge sort, he thought that the merge sort is too slow, so he restricted the maximum depth of recursion and modified the merge sort to the following: <image> Chouti found his idea dumb since obviously, this "merge s...
{ "input": [ "3 2 998244353\n", "9 3 998244353\n", "3 1 998244353\n", "9 4 998244353\n" ], "output": [ "665496236\n", "449209967\n", "499122178\n", "665496237\n" ] }
{ "input": [ "53812 4 967428361\n", "7 2 400166453\n", "75727 16 485722667\n", "65536 10 802338989\n", "65535 12 196344479\n", "5000 4 961162523\n", "13694 5 579788161\n", "99999 14 746231791\n", "14823 8 622667251\n", "65536 1 262776883\n", "65535 4 585040979\n", "1 2 ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; inline long long read() { long long x = 0, f = 1; char c = getchar(); while (c < '0' || c > '9') { if (c == '-') f = -1; c = getchar(); } while (c >= '0' && c <= '9') { x = (x << 1) + (x << 3) + c - '0'; c = getchar(); } return x * f; } const i...
1081_G. Mergesort Strikes Back
Chouti thought about his very first days in competitive programming. When he had just learned to write merge sort, he thought that the merge sort is too slow, so he restricted the maximum depth of recursion and modified the merge sort to the following: <image> Chouti found his idea dumb since obviously, this "merge s...
{ "input": [ "3 2 998244353\n", "9 3 998244353\n", "3 1 998244353\n", "9 4 998244353\n" ], "output": [ "665496236\n", "449209967\n", "499122178\n", "665496237\n" ] }
{ "input": [ "53812 4 967428361\n", "7 2 400166453\n", "75727 16 485722667\n", "65536 10 802338989\n", "65535 12 196344479\n", "5000 4 961162523\n", "13694 5 579788161\n", "99999 14 746231791\n", "14823 8 622667251\n", "65536 1 262776883\n", "65535 4 585040979\n", "1 2 ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; template <class T> inline void rd(T &x) { char ch; x = 0; bool fl = false; while (!isdigit(ch = getchar())) (ch == '-') && (fl = true); for (x = (ch ^ '0'); isdigit(ch = getchar()); x = x * 10 + (ch ^ '0')) ; (fl == true) && (x = -x); } template <class T> in...
1081_G. Mergesort Strikes Back
Chouti thought about his very first days in competitive programming. When he had just learned to write merge sort, he thought that the merge sort is too slow, so he restricted the maximum depth of recursion and modified the merge sort to the following: <image> Chouti found his idea dumb since obviously, this "merge s...
{ "input": [ "3 2 998244353\n", "9 3 998244353\n", "3 1 998244353\n", "9 4 998244353\n" ], "output": [ "665496236\n", "449209967\n", "499122178\n", "665496237\n" ] }
{ "input": [ "53812 4 967428361\n", "7 2 400166453\n", "75727 16 485722667\n", "65536 10 802338989\n", "65535 12 196344479\n", "5000 4 961162523\n", "13694 5 579788161\n", "99999 14 746231791\n", "14823 8 622667251\n", "65536 1 262776883\n", "65535 4 585040979\n", "1 2 ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int read() { int X = 0, w = 1; char c = getchar(); while (c < '0' || c > '9') { if (c == '-') w = -1; c = getchar(); } while (c >= '0' && c <= '9') X = X * 10 + c - '0', c = getchar(); return X * w; } const int N = 100000 + 10; int mod, inv2, inv4; int q...
1081_G. Mergesort Strikes Back
Chouti thought about his very first days in competitive programming. When he had just learned to write merge sort, he thought that the merge sort is too slow, so he restricted the maximum depth of recursion and modified the merge sort to the following: <image> Chouti found his idea dumb since obviously, this "merge s...
{ "input": [ "3 2 998244353\n", "9 3 998244353\n", "3 1 998244353\n", "9 4 998244353\n" ], "output": [ "665496236\n", "449209967\n", "499122178\n", "665496237\n" ] }
{ "input": [ "53812 4 967428361\n", "7 2 400166453\n", "75727 16 485722667\n", "65536 10 802338989\n", "65535 12 196344479\n", "5000 4 961162523\n", "13694 5 579788161\n", "99999 14 746231791\n", "14823 8 622667251\n", "65536 1 262776883\n", "65535 4 585040979\n", "1 2 ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const int N = 100005; int n, k, p, ans, inv4, cnt[N], inv[N]; void divide(int x, int k) { if (k == 1 || x == 1) return (void)(++cnt[x], ans = (ans + (long long)x * (x - 1) % p * inv4) % p); divide(x / 2, k - 1), divide(x - x / 2, k - 1); } inline i...
1081_G. Mergesort Strikes Back
Chouti thought about his very first days in competitive programming. When he had just learned to write merge sort, he thought that the merge sort is too slow, so he restricted the maximum depth of recursion and modified the merge sort to the following: <image> Chouti found his idea dumb since obviously, this "merge s...
{ "input": [ "3 2 998244353\n", "9 3 998244353\n", "3 1 998244353\n", "9 4 998244353\n" ], "output": [ "665496236\n", "449209967\n", "499122178\n", "665496237\n" ] }
{ "input": [ "53812 4 967428361\n", "7 2 400166453\n", "75727 16 485722667\n", "65536 10 802338989\n", "65535 12 196344479\n", "5000 4 961162523\n", "13694 5 579788161\n", "99999 14 746231791\n", "14823 8 622667251\n", "65536 1 262776883\n", "65535 4 585040979\n", "1 2 ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const int MAXN = 2E5 + 10; int P; template <typename T1, typename T2> void Inc(T1 &a, T2 b) { a += b; if (a >= P) a -= P; } template <typename T1, typename T2> void Dec(T1 &a, T2 b) { a -= b; if (a < 0) a += P; } template <typename T1, typename T2> T1 Add(T1 a, T2 b...
1081_G. Mergesort Strikes Back
Chouti thought about his very first days in competitive programming. When he had just learned to write merge sort, he thought that the merge sort is too slow, so he restricted the maximum depth of recursion and modified the merge sort to the following: <image> Chouti found his idea dumb since obviously, this "merge s...
{ "input": [ "3 2 998244353\n", "9 3 998244353\n", "3 1 998244353\n", "9 4 998244353\n" ], "output": [ "665496236\n", "449209967\n", "499122178\n", "665496237\n" ] }
{ "input": [ "53812 4 967428361\n", "7 2 400166453\n", "75727 16 485722667\n", "65536 10 802338989\n", "65535 12 196344479\n", "5000 4 961162523\n", "13694 5 579788161\n", "99999 14 746231791\n", "14823 8 622667251\n", "65536 1 262776883\n", "65535 4 585040979\n", "1 2 ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const long long N = 2e5 + 5; long long read() { long long s = 0; char c = getchar(), lc = '+'; while (c < '0' || '9' < c) lc = c, c = getchar(); while ('0' <= c && c <= '9') s = s * 10 + c - '0', c = getchar(); return lc == '-' ? -s : s; } void write(long long x) ...
1081_G. Mergesort Strikes Back
Chouti thought about his very first days in competitive programming. When he had just learned to write merge sort, he thought that the merge sort is too slow, so he restricted the maximum depth of recursion and modified the merge sort to the following: <image> Chouti found his idea dumb since obviously, this "merge s...
{ "input": [ "3 2 998244353\n", "9 3 998244353\n", "3 1 998244353\n", "9 4 998244353\n" ], "output": [ "665496236\n", "449209967\n", "499122178\n", "665496237\n" ] }
{ "input": [ "53812 4 967428361\n", "7 2 400166453\n", "75727 16 485722667\n", "65536 10 802338989\n", "65535 12 196344479\n", "5000 4 961162523\n", "13694 5 579788161\n", "99999 14 746231791\n", "14823 8 622667251\n", "65536 1 262776883\n", "65535 4 585040979\n", "1 2 ...
CORRECT
cpp
#include <bits/stdc++.h> #pragma GCC optimize(2) #pragma GCC optimize(3) #pragma GCC optimize("Ofast") using namespace std; namespace ywy { unordered_map<int, int> mp; long long inv[200001], ans = 0; int p; inline void solve(int a, int b) { long long cjr = a; cjr *= b; cjr %= p; cjr *= mp[a]; cjr %= p; cjr ...
1081_G. Mergesort Strikes Back
Chouti thought about his very first days in competitive programming. When he had just learned to write merge sort, he thought that the merge sort is too slow, so he restricted the maximum depth of recursion and modified the merge sort to the following: <image> Chouti found his idea dumb since obviously, this "merge s...
{ "input": [ "3 2 998244353\n", "9 3 998244353\n", "3 1 998244353\n", "9 4 998244353\n" ], "output": [ "665496236\n", "449209967\n", "499122178\n", "665496237\n" ] }
{ "input": [ "53812 4 967428361\n", "7 2 400166453\n", "75727 16 485722667\n", "65536 10 802338989\n", "65535 12 196344479\n", "5000 4 961162523\n", "13694 5 579788161\n", "99999 14 746231791\n", "14823 8 622667251\n", "65536 1 262776883\n", "65535 4 585040979\n", "1 2 ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; template <class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; } template <class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; } long long P; const int maxn = 110000; long long rec[maxn]; long long deg(long long x, long long d) { if (d...
1081_G. Mergesort Strikes Back
Chouti thought about his very first days in competitive programming. When he had just learned to write merge sort, he thought that the merge sort is too slow, so he restricted the maximum depth of recursion and modified the merge sort to the following: <image> Chouti found his idea dumb since obviously, this "merge s...
{ "input": [ "3 2 998244353\n", "9 3 998244353\n", "3 1 998244353\n", "9 4 998244353\n" ], "output": [ "665496236\n", "449209967\n", "499122178\n", "665496237\n" ] }
{ "input": [ "53812 4 967428361\n", "7 2 400166453\n", "75727 16 485722667\n", "65536 10 802338989\n", "65535 12 196344479\n", "5000 4 961162523\n", "13694 5 579788161\n", "99999 14 746231791\n", "14823 8 622667251\n", "65536 1 262776883\n", "65535 4 585040979\n", "1 2 ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; using pii = pair<int, int>; using ll = long long; const int N = 100005; int n, kk, P; ll ans, inv[N], sum[N]; map<int, int> cnt; ll qpow(ll a, ll b) { ll ret = 1; while (b) { if (b & 1) ret = ret * a % P; a = a * a % P; b >>= 1; } return ret; } void proc...
1081_G. Mergesort Strikes Back
Chouti thought about his very first days in competitive programming. When he had just learned to write merge sort, he thought that the merge sort is too slow, so he restricted the maximum depth of recursion and modified the merge sort to the following: <image> Chouti found his idea dumb since obviously, this "merge s...
{ "input": [ "3 2 998244353\n", "9 3 998244353\n", "3 1 998244353\n", "9 4 998244353\n" ], "output": [ "665496236\n", "449209967\n", "499122178\n", "665496237\n" ] }
{ "input": [ "53812 4 967428361\n", "7 2 400166453\n", "75727 16 485722667\n", "65536 10 802338989\n", "65535 12 196344479\n", "5000 4 961162523\n", "13694 5 579788161\n", "99999 14 746231791\n", "14823 8 622667251\n", "65536 1 262776883\n", "65535 4 585040979\n", "1 2 ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; inline int read() { int x = 0; char ch = getchar(); while (ch < '0' || ch > '9') ch = getchar(); while ('0' <= ch && ch <= '9') x = x * 10 + ch - '0', ch = getchar(); return x; } int n, k, mod; long long inv[N], sum[N], ans; map<long long, l...
1081_G. Mergesort Strikes Back
Chouti thought about his very first days in competitive programming. When he had just learned to write merge sort, he thought that the merge sort is too slow, so he restricted the maximum depth of recursion and modified the merge sort to the following: <image> Chouti found his idea dumb since obviously, this "merge s...
{ "input": [ "3 2 998244353\n", "9 3 998244353\n", "3 1 998244353\n", "9 4 998244353\n" ], "output": [ "665496236\n", "449209967\n", "499122178\n", "665496237\n" ] }
{ "input": [ "53812 4 967428361\n", "7 2 400166453\n", "75727 16 485722667\n", "65536 10 802338989\n", "65535 12 196344479\n", "5000 4 961162523\n", "13694 5 579788161\n", "99999 14 746231791\n", "14823 8 622667251\n", "65536 1 262776883\n", "65535 4 585040979\n", "1 2 ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; long long mod, inv2; vector<pair<long long, long long> > vec; long long inv[20000005], ans, sum; long long calc(long long len) { return len * (len - 1) % mod * inv2 % mod; } void merge(long long l, long long r, long long h) { if (h == 1 || l == r) { long long len = r ...
1081_G. Mergesort Strikes Back
Chouti thought about his very first days in competitive programming. When he had just learned to write merge sort, he thought that the merge sort is too slow, so he restricted the maximum depth of recursion and modified the merge sort to the following: <image> Chouti found his idea dumb since obviously, this "merge s...
{ "input": [ "3 2 998244353\n", "9 3 998244353\n", "3 1 998244353\n", "9 4 998244353\n" ], "output": [ "665496236\n", "449209967\n", "499122178\n", "665496237\n" ] }
{ "input": [ "53812 4 967428361\n", "7 2 400166453\n", "75727 16 485722667\n", "65536 10 802338989\n", "65535 12 196344479\n", "5000 4 961162523\n", "13694 5 579788161\n", "99999 14 746231791\n", "14823 8 622667251\n", "65536 1 262776883\n", "65535 4 585040979\n", "1 2 ...
CORRECT
cpp
#include <bits/stdc++.h> std::map<long long, long long> mp; long long p, inv[200005], sum[200005]; inline long long read() { register long long x = 0, f = 1; register char s = getchar(); while (s > '9' || s < '0') { if (s == '-') f = -1; s = getchar(); } while (s >= '0' && s <= '9') { x = x * 10 +...
1081_G. Mergesort Strikes Back
Chouti thought about his very first days in competitive programming. When he had just learned to write merge sort, he thought that the merge sort is too slow, so he restricted the maximum depth of recursion and modified the merge sort to the following: <image> Chouti found his idea dumb since obviously, this "merge s...
{ "input": [ "3 2 998244353\n", "9 3 998244353\n", "3 1 998244353\n", "9 4 998244353\n" ], "output": [ "665496236\n", "449209967\n", "499122178\n", "665496237\n" ] }
{ "input": [ "53812 4 967428361\n", "7 2 400166453\n", "75727 16 485722667\n", "65536 10 802338989\n", "65535 12 196344479\n", "5000 4 961162523\n", "13694 5 579788161\n", "99999 14 746231791\n", "14823 8 622667251\n", "65536 1 262776883\n", "65535 4 585040979\n", "1 2 ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 10; int n, k, mod, ans; int inv[N], sum[N]; map<int, int> cnt; map<int, int>::iterator it1, it2; int read() { int ret = 0, f = 1; char c = getchar(); while (!isdigit(c)) { if (c == '-') f = 0; c = getchar(); } while (isdigit(c)) ret = r...
1081_G. Mergesort Strikes Back
Chouti thought about his very first days in competitive programming. When he had just learned to write merge sort, he thought that the merge sort is too slow, so he restricted the maximum depth of recursion and modified the merge sort to the following: <image> Chouti found his idea dumb since obviously, this "merge s...
{ "input": [ "3 2 998244353\n", "9 3 998244353\n", "3 1 998244353\n", "9 4 998244353\n" ], "output": [ "665496236\n", "449209967\n", "499122178\n", "665496237\n" ] }
{ "input": [ "53812 4 967428361\n", "7 2 400166453\n", "75727 16 485722667\n", "65536 10 802338989\n", "65535 12 196344479\n", "5000 4 961162523\n", "13694 5 579788161\n", "99999 14 746231791\n", "14823 8 622667251\n", "65536 1 262776883\n", "65535 4 585040979\n", "1 2 ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const int N = 2e6 + 10; int mod = 1e9 + 7; long long power(long long a, long long b) { long long res = 1; while (b) { if (b & 1) res = res * a % mod; a = a * a % mod; b >>= 1; } return res; } long long INV(long long a) { return power(a, mod - 2); } mt199...
1081_G. Mergesort Strikes Back
Chouti thought about his very first days in competitive programming. When he had just learned to write merge sort, he thought that the merge sort is too slow, so he restricted the maximum depth of recursion and modified the merge sort to the following: <image> Chouti found his idea dumb since obviously, this "merge s...
{ "input": [ "3 2 998244353\n", "9 3 998244353\n", "3 1 998244353\n", "9 4 998244353\n" ], "output": [ "665496236\n", "449209967\n", "499122178\n", "665496237\n" ] }
{ "input": [ "53812 4 967428361\n", "7 2 400166453\n", "75727 16 485722667\n", "65536 10 802338989\n", "65535 12 196344479\n", "5000 4 961162523\n", "13694 5 579788161\n", "99999 14 746231791\n", "14823 8 622667251\n", "65536 1 262776883\n", "65535 4 585040979\n", "1 2 ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 10; int n, k, mod, ans; int inv[N], sum[N]; map<int, int> cnt; map<int, int>::iterator it1, it2; int read() { int ret = 0, f = 1; char c = getchar(); while (!isdigit(c)) { if (c == '-') f = 0; c = getchar(); } while (isdigit(c)) ret = r...
1081_G. Mergesort Strikes Back
Chouti thought about his very first days in competitive programming. When he had just learned to write merge sort, he thought that the merge sort is too slow, so he restricted the maximum depth of recursion and modified the merge sort to the following: <image> Chouti found his idea dumb since obviously, this "merge s...
{ "input": [ "3 2 998244353\n", "9 3 998244353\n", "3 1 998244353\n", "9 4 998244353\n" ], "output": [ "665496236\n", "449209967\n", "499122178\n", "665496237\n" ] }
{ "input": [ "53812 4 967428361\n", "7 2 400166453\n", "75727 16 485722667\n", "65536 10 802338989\n", "65535 12 196344479\n", "5000 4 961162523\n", "13694 5 579788161\n", "99999 14 746231791\n", "14823 8 622667251\n", "65536 1 262776883\n", "65535 4 585040979\n", "1 2 ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int MOD; int inv[200005]; void gen_inv(int maxa) { inv[1] = 1; for (int i = 2; i <= maxa; i++) inv[i] = MOD - 1LL * inv[MOD % i] * (MOD / i) % MOD; } int getans(int u, int v) { int ans = 0; for (int i = 2; i <= u + v; i++) ans = (ans + 1LL * (min(u, i - 1) -...
1081_G. Mergesort Strikes Back
Chouti thought about his very first days in competitive programming. When he had just learned to write merge sort, he thought that the merge sort is too slow, so he restricted the maximum depth of recursion and modified the merge sort to the following: <image> Chouti found his idea dumb since obviously, this "merge s...
{ "input": [ "3 2 998244353\n", "9 3 998244353\n", "3 1 998244353\n", "9 4 998244353\n" ], "output": [ "665496236\n", "449209967\n", "499122178\n", "665496237\n" ] }
{ "input": [ "53812 4 967428361\n", "7 2 400166453\n", "75727 16 485722667\n", "65536 10 802338989\n", "65535 12 196344479\n", "5000 4 961162523\n", "13694 5 579788161\n", "99999 14 746231791\n", "14823 8 622667251\n", "65536 1 262776883\n", "65535 4 585040979\n", "1 2 ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; template <typename T> void read(T &x) { x = 0; bool f = 0; char c = getchar(); for (; !isdigit(c); c = getchar()) if (c == '-') f = 1; for (; isdigit(c); c = getchar()) x = x * 10 + (c ^ 48); if (f) x = -x; } template <typename F> inline void write(F x, char...
1081_G. Mergesort Strikes Back
Chouti thought about his very first days in competitive programming. When he had just learned to write merge sort, he thought that the merge sort is too slow, so he restricted the maximum depth of recursion and modified the merge sort to the following: <image> Chouti found his idea dumb since obviously, this "merge s...
{ "input": [ "3 2 998244353\n", "9 3 998244353\n", "3 1 998244353\n", "9 4 998244353\n" ], "output": [ "665496236\n", "449209967\n", "499122178\n", "665496237\n" ] }
{ "input": [ "53812 4 967428361\n", "7 2 400166453\n", "75727 16 485722667\n", "65536 10 802338989\n", "65535 12 196344479\n", "5000 4 961162523\n", "13694 5 579788161\n", "99999 14 746231791\n", "14823 8 622667251\n", "65536 1 262776883\n", "65535 4 585040979\n", "1 2 ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const int N = 100005; int n, k, mod, ans, inv[N], s[N]; map<int, int> c; int ksm(int a, int b) { int r = 1; while (b) { if (b & 1) r = 1ll * r * a % mod; a = 1ll * a * a % mod; b >>= 1; } return r; } void pre(int l, int r, int k) { if (k <= 1 || l == r...
1081_G. Mergesort Strikes Back
Chouti thought about his very first days in competitive programming. When he had just learned to write merge sort, he thought that the merge sort is too slow, so he restricted the maximum depth of recursion and modified the merge sort to the following: <image> Chouti found his idea dumb since obviously, this "merge s...
{ "input": [ "3 2 998244353\n", "9 3 998244353\n", "3 1 998244353\n", "9 4 998244353\n" ], "output": [ "665496236\n", "449209967\n", "499122178\n", "665496237\n" ] }
{ "input": [ "53812 4 967428361\n", "7 2 400166453\n", "75727 16 485722667\n", "65536 10 802338989\n", "65535 12 196344479\n", "5000 4 961162523\n", "13694 5 579788161\n", "99999 14 746231791\n", "14823 8 622667251\n", "65536 1 262776883\n", "65535 4 585040979\n", "1 2 ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e5 + 5; char buf[1 << 12], *pp1 = buf, *pp2 = buf, nc; int ny; inline char gc() { return pp1 == pp2 && (pp2 = (pp1 = buf) + fread(buf, 1, 1 << 12, stdin), pp1 == pp2) ? EOF : *pp1++; } inline int read() { int ...
1081_G. Mergesort Strikes Back
Chouti thought about his very first days in competitive programming. When he had just learned to write merge sort, he thought that the merge sort is too slow, so he restricted the maximum depth of recursion and modified the merge sort to the following: <image> Chouti found his idea dumb since obviously, this "merge s...
{ "input": [ "3 2 998244353\n", "9 3 998244353\n", "3 1 998244353\n", "9 4 998244353\n" ], "output": [ "665496236\n", "449209967\n", "499122178\n", "665496237\n" ] }
{ "input": [ "53812 4 967428361\n", "7 2 400166453\n", "75727 16 485722667\n", "65536 10 802338989\n", "65535 12 196344479\n", "5000 4 961162523\n", "13694 5 579788161\n", "99999 14 746231791\n", "14823 8 622667251\n", "65536 1 262776883\n", "65535 4 585040979\n", "1 2 ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 7; long long MOD, f[N]; long long qpow(long long x, long long y) { long long z = 1; while (y > 0) { if (y % 2) z = z * x % MOD; x = x * x % MOD; y /= 2; } return z; } map<int, int> ma; pair<int, int> a[10]; void dfs(int x, int k) { ...
1081_G. Mergesort Strikes Back
Chouti thought about his very first days in competitive programming. When he had just learned to write merge sort, he thought that the merge sort is too slow, so he restricted the maximum depth of recursion and modified the merge sort to the following: <image> Chouti found his idea dumb since obviously, this "merge s...
{ "input": [ "3 2 998244353\n", "9 3 998244353\n", "3 1 998244353\n", "9 4 998244353\n" ], "output": [ "665496236\n", "449209967\n", "499122178\n", "665496237\n" ] }
{ "input": [ "53812 4 967428361\n", "7 2 400166453\n", "75727 16 485722667\n", "65536 10 802338989\n", "65535 12 196344479\n", "5000 4 961162523\n", "13694 5 579788161\n", "99999 14 746231791\n", "14823 8 622667251\n", "65536 1 262776883\n", "65535 4 585040979\n", "1 2 ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const int N = 220000; map<int, int> H; int inv[N]; void build(int st, int en, int k) { if (k == 1) { int len = en - st + 1; if (H.count(len)) H[len]++; else H[len] = 1; return; } if (st == en) return; int mid = st + en >> 1; build(st, m...
1081_G. Mergesort Strikes Back
Chouti thought about his very first days in competitive programming. When he had just learned to write merge sort, he thought that the merge sort is too slow, so he restricted the maximum depth of recursion and modified the merge sort to the following: <image> Chouti found his idea dumb since obviously, this "merge s...
{ "input": [ "3 2 998244353\n", "9 3 998244353\n", "3 1 998244353\n", "9 4 998244353\n" ], "output": [ "665496236\n", "449209967\n", "499122178\n", "665496237\n" ] }
{ "input": [ "53812 4 967428361\n", "7 2 400166453\n", "75727 16 485722667\n", "65536 10 802338989\n", "65535 12 196344479\n", "5000 4 961162523\n", "13694 5 579788161\n", "99999 14 746231791\n", "14823 8 622667251\n", "65536 1 262776883\n", "65535 4 585040979\n", "1 2 ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; long long n, m, mod, sum[200005], inv[200005], ans, s1, s2, num1, num2; void split(long long l, long long r, long long dep) { if (l > r) return; if (dep == 1 || l == r) { if (!s1) s1 = r - l + 1; if (s1 == r - l + 1) num1++; else { if (!s2) s2 = ...
1081_G. Mergesort Strikes Back
Chouti thought about his very first days in competitive programming. When he had just learned to write merge sort, he thought that the merge sort is too slow, so he restricted the maximum depth of recursion and modified the merge sort to the following: <image> Chouti found his idea dumb since obviously, this "merge s...
{ "input": [ "3 2 998244353\n", "9 3 998244353\n", "3 1 998244353\n", "9 4 998244353\n" ], "output": [ "665496236\n", "449209967\n", "499122178\n", "665496237\n" ] }
{ "input": [ "53812 4 967428361\n", "7 2 400166453\n", "75727 16 485722667\n", "65536 10 802338989\n", "65535 12 196344479\n", "5000 4 961162523\n", "13694 5 579788161\n", "99999 14 746231791\n", "14823 8 622667251\n", "65536 1 262776883\n", "65535 4 585040979\n", "1 2 ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const int maxn = 200100; int mod, n, h; inline void Add(int &a, int b) { a = a + b >= mod ? a + b - mod : a + b; } int inv[maxn], sum[maxn]; inline int Qsum(int l, int r) { return (sum[r] - sum[l - 1] + mod) % mod; } int cnt[maxn], S, L; int ans; inline void getblock(int l,...
1081_G. Mergesort Strikes Back
Chouti thought about his very first days in competitive programming. When he had just learned to write merge sort, he thought that the merge sort is too slow, so he restricted the maximum depth of recursion and modified the merge sort to the following: <image> Chouti found his idea dumb since obviously, this "merge s...
{ "input": [ "3 2 998244353\n", "9 3 998244353\n", "3 1 998244353\n", "9 4 998244353\n" ], "output": [ "665496236\n", "449209967\n", "499122178\n", "665496237\n" ] }
{ "input": [ "53812 4 967428361\n", "7 2 400166453\n", "75727 16 485722667\n", "65536 10 802338989\n", "65535 12 196344479\n", "5000 4 961162523\n", "13694 5 579788161\n", "99999 14 746231791\n", "14823 8 622667251\n", "65536 1 262776883\n", "65535 4 585040979\n", "1 2 ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const int N = 100005; int inv[N], n, k, mo, ans; map<int, int> mp; void get(int n, int k) { if (k == 1 || n == 1) mp[n]++; else get(n / 2, k - 1), get(n - n / 2, k - 1); } int calc(int x, int y) { int ans = 1ll * x * y % mo * (mo + 1) / 2 % mo; for (int i = ...
1081_G. Mergesort Strikes Back
Chouti thought about his very first days in competitive programming. When he had just learned to write merge sort, he thought that the merge sort is too slow, so he restricted the maximum depth of recursion and modified the merge sort to the following: <image> Chouti found his idea dumb since obviously, this "merge s...
{ "input": [ "3 2 998244353\n", "9 3 998244353\n", "3 1 998244353\n", "9 4 998244353\n" ], "output": [ "665496236\n", "449209967\n", "499122178\n", "665496237\n" ] }
{ "input": [ "53812 4 967428361\n", "7 2 400166453\n", "75727 16 485722667\n", "65536 10 802338989\n", "65535 12 196344479\n", "5000 4 961162523\n", "13694 5 579788161\n", "99999 14 746231791\n", "14823 8 622667251\n", "65536 1 262776883\n", "65535 4 585040979\n", "1 2 ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const int MOD = (int)1e9 + 7; const int MAXN = (int)1e5 + 3; const int infint = (int)1e9 + 3; const long long inf = (long long)1e12; int n, k, q; vector<int> v; int add(int a, int b) { int c = a + b; if (c >= q) c -= q; if (c < 0) c += q; return c; } int mul(int a, ...
1081_G. Mergesort Strikes Back
Chouti thought about his very first days in competitive programming. When he had just learned to write merge sort, he thought that the merge sort is too slow, so he restricted the maximum depth of recursion and modified the merge sort to the following: <image> Chouti found his idea dumb since obviously, this "merge s...
{ "input": [ "3 2 998244353\n", "9 3 998244353\n", "3 1 998244353\n", "9 4 998244353\n" ], "output": [ "665496236\n", "449209967\n", "499122178\n", "665496237\n" ] }
{ "input": [ "53812 4 967428361\n", "7 2 400166453\n", "75727 16 485722667\n", "65536 10 802338989\n", "65535 12 196344479\n", "5000 4 961162523\n", "13694 5 579788161\n", "99999 14 746231791\n", "14823 8 622667251\n", "65536 1 262776883\n", "65535 4 585040979\n", "1 2 ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; long long MOD; long long powmod(long long a, long long n) { if (n == 0) return 1; if (n % 2) return (a * powmod(a, n - 1)) % MOD; long long c = powmod(a, n / 2); return (c * c) % MOD; } long long inv(long long a) { return powmod(a, MOD - 2); } long long fact[110000]...
1081_G. Mergesort Strikes Back
Chouti thought about his very first days in competitive programming. When he had just learned to write merge sort, he thought that the merge sort is too slow, so he restricted the maximum depth of recursion and modified the merge sort to the following: <image> Chouti found his idea dumb since obviously, this "merge s...
{ "input": [ "3 2 998244353\n", "9 3 998244353\n", "3 1 998244353\n", "9 4 998244353\n" ], "output": [ "665496236\n", "449209967\n", "499122178\n", "665496237\n" ] }
{ "input": [ "53812 4 967428361\n", "7 2 400166453\n", "75727 16 485722667\n", "65536 10 802338989\n", "65535 12 196344479\n", "5000 4 961162523\n", "13694 5 579788161\n", "99999 14 746231791\n", "14823 8 622667251\n", "65536 1 262776883\n", "65535 4 585040979\n", "1 2 ...
CORRECT
cpp
#include <bits/stdc++.h> template <typename T> inline void read(T &x) { x = 0; char c = getchar(); while (!isdigit(c)) c = getchar(); while (isdigit(c)) x = x * 10 + (c ^ 48), c = getchar(); } using namespace std; int n, K, P; long long inv[201000], isum[201000]; inline void init() { inv[1] = 1; for (int i ...
1081_G. Mergesort Strikes Back
Chouti thought about his very first days in competitive programming. When he had just learned to write merge sort, he thought that the merge sort is too slow, so he restricted the maximum depth of recursion and modified the merge sort to the following: <image> Chouti found his idea dumb since obviously, this "merge s...
{ "input": [ "3 2 998244353\n", "9 3 998244353\n", "3 1 998244353\n", "9 4 998244353\n" ], "output": [ "665496236\n", "449209967\n", "499122178\n", "665496237\n" ] }
{ "input": [ "53812 4 967428361\n", "7 2 400166453\n", "75727 16 485722667\n", "65536 10 802338989\n", "65535 12 196344479\n", "5000 4 961162523\n", "13694 5 579788161\n", "99999 14 746231791\n", "14823 8 622667251\n", "65536 1 262776883\n", "65535 4 585040979\n", "1 2 ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; int n, k, mod, c[N], inv[N], s[N]; void dfs(int d, int l, int r) { if (d <= 1 || l == r) { ++c[r - l + 1]; return; } int m = (l + r) >> 1; dfs(d - 1, l, m); dfs(d - 1, m + 1, r); } int solve(int n, int m) { int res = (long long)inv...
1081_G. Mergesort Strikes Back
Chouti thought about his very first days in competitive programming. When he had just learned to write merge sort, he thought that the merge sort is too slow, so he restricted the maximum depth of recursion and modified the merge sort to the following: <image> Chouti found his idea dumb since obviously, this "merge s...
{ "input": [ "3 2 998244353\n", "9 3 998244353\n", "3 1 998244353\n", "9 4 998244353\n" ], "output": [ "665496236\n", "449209967\n", "499122178\n", "665496237\n" ] }
{ "input": [ "53812 4 967428361\n", "7 2 400166453\n", "75727 16 485722667\n", "65536 10 802338989\n", "65535 12 196344479\n", "5000 4 961162523\n", "13694 5 579788161\n", "99999 14 746231791\n", "14823 8 622667251\n", "65536 1 262776883\n", "65535 4 585040979\n", "1 2 ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; inline char gc() { static char buf[100000], *p1 = buf, *p2 = buf; return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2) ? EOF : *p1++; } inline long long read() { long long x = 0; char ch = getchar(); bool positive...
1081_G. Mergesort Strikes Back
Chouti thought about his very first days in competitive programming. When he had just learned to write merge sort, he thought that the merge sort is too slow, so he restricted the maximum depth of recursion and modified the merge sort to the following: <image> Chouti found his idea dumb since obviously, this "merge s...
{ "input": [ "3 2 998244353\n", "9 3 998244353\n", "3 1 998244353\n", "9 4 998244353\n" ], "output": [ "665496236\n", "449209967\n", "499122178\n", "665496237\n" ] }
{ "input": [ "53812 4 967428361\n", "7 2 400166453\n", "75727 16 485722667\n", "65536 10 802338989\n", "65535 12 196344479\n", "5000 4 961162523\n", "13694 5 579788161\n", "99999 14 746231791\n", "14823 8 622667251\n", "65536 1 262776883\n", "65535 4 585040979\n", "1 2 ...
CORRECT
cpp
#include <bits/stdc++.h> const int MAXN = 100010; int mod = 998244353; void reduce(int& x) { x += x >> 31 & mod; } int mul(int a, int b) { return (long long)a * b % mod; } int pow(int a, int b, int res = 1) { for (; b; b >>= 1, a = mul(a, a)) if (b & 1) res = mul(res, a); return res; } void mma(int& x, int y, i...
1081_G. Mergesort Strikes Back
Chouti thought about his very first days in competitive programming. When he had just learned to write merge sort, he thought that the merge sort is too slow, so he restricted the maximum depth of recursion and modified the merge sort to the following: <image> Chouti found his idea dumb since obviously, this "merge s...
{ "input": [ "3 2 998244353\n", "9 3 998244353\n", "3 1 998244353\n", "9 4 998244353\n" ], "output": [ "665496236\n", "449209967\n", "499122178\n", "665496237\n" ] }
{ "input": [ "53812 4 967428361\n", "7 2 400166453\n", "75727 16 485722667\n", "65536 10 802338989\n", "65535 12 196344479\n", "5000 4 961162523\n", "13694 5 579788161\n", "99999 14 746231791\n", "14823 8 622667251\n", "65536 1 262776883\n", "65535 4 585040979\n", "1 2 ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 10; int n, k, P, inv[N], ans, f[2], c[2]; inline void upd(int &x, int y) { ((x += y) > P) && (x -= P); } void sol(int l, int r, int k) { if (!k || l == r) { int len = r - l + 1; c[len & 1] = len; f[len & 1]++; return; } int mid = (l...
1081_G. Mergesort Strikes Back
Chouti thought about his very first days in competitive programming. When he had just learned to write merge sort, he thought that the merge sort is too slow, so he restricted the maximum depth of recursion and modified the merge sort to the following: <image> Chouti found his idea dumb since obviously, this "merge s...
{ "input": [ "3 2 998244353\n", "9 3 998244353\n", "3 1 998244353\n", "9 4 998244353\n" ], "output": [ "665496236\n", "449209967\n", "499122178\n", "665496237\n" ] }
{ "input": [ "53812 4 967428361\n", "7 2 400166453\n", "75727 16 485722667\n", "65536 10 802338989\n", "65535 12 196344479\n", "5000 4 961162523\n", "13694 5 579788161\n", "99999 14 746231791\n", "14823 8 622667251\n", "65536 1 262776883\n", "65535 4 585040979\n", "1 2 ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int n, m, M, I2; map<int, int> cnt; long long inv[200050]; void divide(int m, int l, int r) { if (m == 1 || l == r) ++cnt[r - l + 1]; else { int mid = (l + r) >> 1; divide(m - 1, l, mid); divide(m - 1, mid + 1, r); } } long long pw(long long a, long lo...
1081_G. Mergesort Strikes Back
Chouti thought about his very first days in competitive programming. When he had just learned to write merge sort, he thought that the merge sort is too slow, so he restricted the maximum depth of recursion and modified the merge sort to the following: <image> Chouti found his idea dumb since obviously, this "merge s...
{ "input": [ "3 2 998244353\n", "9 3 998244353\n", "3 1 998244353\n", "9 4 998244353\n" ], "output": [ "665496236\n", "449209967\n", "499122178\n", "665496237\n" ] }
{ "input": [ "53812 4 967428361\n", "7 2 400166453\n", "75727 16 485722667\n", "65536 10 802338989\n", "65535 12 196344479\n", "5000 4 961162523\n", "13694 5 579788161\n", "99999 14 746231791\n", "14823 8 622667251\n", "65536 1 262776883\n", "65535 4 585040979\n", "1 2 ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 5; int n, k, q, A[N], num[2], Min, mod, ans, I4; namespace { int add(int x) { return (x >= mod) ? x - mod : x; } int sub(int x) { return (x < 0) ? x + mod : x; } void Add(int &x, int y) { x = add(x + y); } void Sub(int &x, int y) { x = sub(x - y); } int ...
1081_G. Mergesort Strikes Back
Chouti thought about his very first days in competitive programming. When he had just learned to write merge sort, he thought that the merge sort is too slow, so he restricted the maximum depth of recursion and modified the merge sort to the following: <image> Chouti found his idea dumb since obviously, this "merge s...
{ "input": [ "3 2 998244353\n", "9 3 998244353\n", "3 1 998244353\n", "9 4 998244353\n" ], "output": [ "665496236\n", "449209967\n", "499122178\n", "665496237\n" ] }
{ "input": [ "53812 4 967428361\n", "7 2 400166453\n", "75727 16 485722667\n", "65536 10 802338989\n", "65535 12 196344479\n", "5000 4 961162523\n", "13694 5 579788161\n", "99999 14 746231791\n", "14823 8 622667251\n", "65536 1 262776883\n", "65535 4 585040979\n", "1 2 ...
CORRECT
cpp
#include <bits/stdc++.h> std::map<long long, long long> mp; long long p, inv[200005], sum[200005]; inline long long read() { register long long x = 0, f = 1; register char s = getchar(); while (s > '9' || s < '0') { if (s == '-') f = -1; s = getchar(); } while (s >= '0' && s <= '9') { x = x * 10 +...
1081_G. Mergesort Strikes Back
Chouti thought about his very first days in competitive programming. When he had just learned to write merge sort, he thought that the merge sort is too slow, so he restricted the maximum depth of recursion and modified the merge sort to the following: <image> Chouti found his idea dumb since obviously, this "merge s...
{ "input": [ "3 2 998244353\n", "9 3 998244353\n", "3 1 998244353\n", "9 4 998244353\n" ], "output": [ "665496236\n", "449209967\n", "499122178\n", "665496237\n" ] }
{ "input": [ "53812 4 967428361\n", "7 2 400166453\n", "75727 16 485722667\n", "65536 10 802338989\n", "65535 12 196344479\n", "5000 4 961162523\n", "13694 5 579788161\n", "99999 14 746231791\n", "14823 8 622667251\n", "65536 1 262776883\n", "65535 4 585040979\n", "1 2 ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; using uint = unsigned int; using ll = long long; using ull = unsigned long long; template <class T> using V = vector<T>; template <class T> using VV = V<V<T>>; constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); } uint MD; struct ModInt { using M = ModInt; ...
1081_G. Mergesort Strikes Back
Chouti thought about his very first days in competitive programming. When he had just learned to write merge sort, he thought that the merge sort is too slow, so he restricted the maximum depth of recursion and modified the merge sort to the following: <image> Chouti found his idea dumb since obviously, this "merge s...
{ "input": [ "3 2 998244353\n", "9 3 998244353\n", "3 1 998244353\n", "9 4 998244353\n" ], "output": [ "665496236\n", "449209967\n", "499122178\n", "665496237\n" ] }
{ "input": [ "53812 4 967428361\n", "7 2 400166453\n", "75727 16 485722667\n", "65536 10 802338989\n", "65535 12 196344479\n", "5000 4 961162523\n", "13694 5 579788161\n", "99999 14 746231791\n", "14823 8 622667251\n", "65536 1 262776883\n", "65535 4 585040979\n", "1 2 ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const int inf = 1e9; const long long Inf = 1e18; const int N = 1e5 + 10; int n, k, mod, inv[N], sinv[N], ans = 0; int gi() { int x = 0, o = 1; char ch = getchar(); while ((ch < '0' || ch > '9') && ch != '-') ch = getchar(); if (ch == '-') o = -1, ch = getchar(); w...
1081_G. Mergesort Strikes Back
Chouti thought about his very first days in competitive programming. When he had just learned to write merge sort, he thought that the merge sort is too slow, so he restricted the maximum depth of recursion and modified the merge sort to the following: <image> Chouti found his idea dumb since obviously, this "merge s...
{ "input": [ "3 2 998244353\n", "9 3 998244353\n", "3 1 998244353\n", "9 4 998244353\n" ], "output": [ "665496236\n", "449209967\n", "499122178\n", "665496237\n" ] }
{ "input": [ "53812 4 967428361\n", "7 2 400166453\n", "75727 16 485722667\n", "65536 10 802338989\n", "65535 12 196344479\n", "5000 4 961162523\n", "13694 5 579788161\n", "99999 14 746231791\n", "14823 8 622667251\n", "65536 1 262776883\n", "65535 4 585040979\n", "1 2 ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int inv[100010], s[100010], num[100010], n, k, MOD, ans; void work(int l, int r, int h) { if (h <= 1 || l == r) { num[r - l + 1]++; return; } int mid = (l + r) >> 1; work(l, mid, h - 1); work(mid + 1, r, h - 1); } int basic(int x) { return 1ll * x * (x - 1...
1081_G. Mergesort Strikes Back
Chouti thought about his very first days in competitive programming. When he had just learned to write merge sort, he thought that the merge sort is too slow, so he restricted the maximum depth of recursion and modified the merge sort to the following: <image> Chouti found his idea dumb since obviously, this "merge s...
{ "input": [ "3 2 998244353\n", "9 3 998244353\n", "3 1 998244353\n", "9 4 998244353\n" ], "output": [ "665496236\n", "449209967\n", "499122178\n", "665496237\n" ] }
{ "input": [ "53812 4 967428361\n", "7 2 400166453\n", "75727 16 485722667\n", "65536 10 802338989\n", "65535 12 196344479\n", "5000 4 961162523\n", "13694 5 579788161\n", "99999 14 746231791\n", "14823 8 622667251\n", "65536 1 262776883\n", "65535 4 585040979\n", "1 2 ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int get() { char ch; while (ch = getchar(), (ch < '0' || ch > '9') && ch != '-') ; if (ch == '-') { int s = 0; while (ch = getchar(), ch >= '0' && ch <= '9') s = s * 10 + ch - '0'; return -s; } int s = ch - '0'; while (ch = getchar(), ch >= '0' &...
1081_G. Mergesort Strikes Back
Chouti thought about his very first days in competitive programming. When he had just learned to write merge sort, he thought that the merge sort is too slow, so he restricted the maximum depth of recursion and modified the merge sort to the following: <image> Chouti found his idea dumb since obviously, this "merge s...
{ "input": [ "3 2 998244353\n", "9 3 998244353\n", "3 1 998244353\n", "9 4 998244353\n" ], "output": [ "665496236\n", "449209967\n", "499122178\n", "665496237\n" ] }
{ "input": [ "53812 4 967428361\n", "7 2 400166453\n", "75727 16 485722667\n", "65536 10 802338989\n", "65535 12 196344479\n", "5000 4 961162523\n", "13694 5 579788161\n", "99999 14 746231791\n", "14823 8 622667251\n", "65536 1 262776883\n", "65535 4 585040979\n", "1 2 ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; map<int, int> mp; int n, k, q; void dfs(int l, int r, int dep) { if (dep <= 1 || l == r) { mp[r - l + 1]++; return; } int mid = (l + r) >> 1; dfs(l, mid, dep - 1); dfs(mid + 1, r, dep - 1); } int ADD(int x, int y) { return (x += y) >= q ? x - q : x; } int ...
1081_G. Mergesort Strikes Back
Chouti thought about his very first days in competitive programming. When he had just learned to write merge sort, he thought that the merge sort is too slow, so he restricted the maximum depth of recursion and modified the merge sort to the following: <image> Chouti found his idea dumb since obviously, this "merge s...
{ "input": [ "3 2 998244353\n", "9 3 998244353\n", "3 1 998244353\n", "9 4 998244353\n" ], "output": [ "665496236\n", "449209967\n", "499122178\n", "665496237\n" ] }
{ "input": [ "53812 4 967428361\n", "7 2 400166453\n", "75727 16 485722667\n", "65536 10 802338989\n", "65535 12 196344479\n", "5000 4 961162523\n", "13694 5 579788161\n", "99999 14 746231791\n", "14823 8 622667251\n", "65536 1 262776883\n", "65535 4 585040979\n", "1 2 ...
CORRECT
cpp
#include <bits/stdc++.h> const int MAXN = 1e5 + 20; int n, k, M; int inv[MAXN], pre_inv[MAXN]; void math_pre() { inv[1] = 1; for (int i = 2; i <= ((n < 4) ? 4 : n); ++i) inv[i] = 1ll * (M - M / i) * inv[M % i] % M; for (int i = 1; i <= n; ++i) pre_inv[i] = (pre_inv[i - 1] + inv[i]) % M; } struct map { stati...
1081_G. Mergesort Strikes Back
Chouti thought about his very first days in competitive programming. When he had just learned to write merge sort, he thought that the merge sort is too slow, so he restricted the maximum depth of recursion and modified the merge sort to the following: <image> Chouti found his idea dumb since obviously, this "merge s...
{ "input": [ "3 2 998244353\n", "9 3 998244353\n", "3 1 998244353\n", "9 4 998244353\n" ], "output": [ "665496236\n", "449209967\n", "499122178\n", "665496237\n" ] }
{ "input": [ "53812 4 967428361\n", "7 2 400166453\n", "75727 16 485722667\n", "65536 10 802338989\n", "65535 12 196344479\n", "5000 4 961162523\n", "13694 5 579788161\n", "99999 14 746231791\n", "14823 8 622667251\n", "65536 1 262776883\n", "65535 4 585040979\n", "1 2 ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; int n, k, p, inv[N], res[2][2]; vector<int> segs, tmp; void dfs(int l, int r, int k) { if (l == r || k == 1) { segs.emplace_back(r - l + 1); tmp.emplace_back(r - l + 1); return; } int mid = (l + r) >> 1; dfs(l, mid, k - 1); dfs(m...
1081_G. Mergesort Strikes Back
Chouti thought about his very first days in competitive programming. When he had just learned to write merge sort, he thought that the merge sort is too slow, so he restricted the maximum depth of recursion and modified the merge sort to the following: <image> Chouti found his idea dumb since obviously, this "merge s...
{ "input": [ "3 2 998244353\n", "9 3 998244353\n", "3 1 998244353\n", "9 4 998244353\n" ], "output": [ "665496236\n", "449209967\n", "499122178\n", "665496237\n" ] }
{ "input": [ "53812 4 967428361\n", "7 2 400166453\n", "75727 16 485722667\n", "65536 10 802338989\n", "65535 12 196344479\n", "5000 4 961162523\n", "13694 5 579788161\n", "99999 14 746231791\n", "14823 8 622667251\n", "65536 1 262776883\n", "65535 4 585040979\n", "1 2 ...
CORRECT
cpp
#include <bits/stdc++.h> const int Maxn = 100000; int n, k, Mod; int sum[Maxn + 5]; int inv[Maxn + 5]; void init() { inv[1] = 1; for (int i = 2; i <= Maxn; i++) { inv[i] = 1ll * (Mod - Mod / i) * inv[Mod % i] % Mod; } for (int i = 1; i <= Maxn; i++) { sum[i] = (sum[i - 1] + inv[i]) % Mod; } } int cnt[...
1081_G. Mergesort Strikes Back
Chouti thought about his very first days in competitive programming. When he had just learned to write merge sort, he thought that the merge sort is too slow, so he restricted the maximum depth of recursion and modified the merge sort to the following: <image> Chouti found his idea dumb since obviously, this "merge s...
{ "input": [ "3 2 998244353\n", "9 3 998244353\n", "3 1 998244353\n", "9 4 998244353\n" ], "output": [ "665496236\n", "449209967\n", "499122178\n", "665496237\n" ] }
{ "input": [ "53812 4 967428361\n", "7 2 400166453\n", "75727 16 485722667\n", "65536 10 802338989\n", "65535 12 196344479\n", "5000 4 961162523\n", "13694 5 579788161\n", "99999 14 746231791\n", "14823 8 622667251\n", "65536 1 262776883\n", "65535 4 585040979\n", "1 2 ...
CORRECT
cpp
#include <bits/stdc++.h> #pragma GCC optimize("Ofast") using namespace std; template <typename T> void dprintln(const T &t) { cout << t << endl; } template <typename T, typename... Args> void dprintln(const T &t, const Args &...rest) { cout << t << ' '; dprintln(rest...); } template <typename T> void println(cons...
1081_G. Mergesort Strikes Back
Chouti thought about his very first days in competitive programming. When he had just learned to write merge sort, he thought that the merge sort is too slow, so he restricted the maximum depth of recursion and modified the merge sort to the following: <image> Chouti found his idea dumb since obviously, this "merge s...
{ "input": [ "3 2 998244353\n", "9 3 998244353\n", "3 1 998244353\n", "9 4 998244353\n" ], "output": [ "665496236\n", "449209967\n", "499122178\n", "665496237\n" ] }
{ "input": [ "53812 4 967428361\n", "7 2 400166453\n", "75727 16 485722667\n", "65536 10 802338989\n", "65535 12 196344479\n", "5000 4 961162523\n", "13694 5 579788161\n", "99999 14 746231791\n", "14823 8 622667251\n", "65536 1 262776883\n", "65535 4 585040979\n", "1 2 ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; int i, j, n, k, mo, rev[N], a[N], num, d[N], s[N], l, r; long long ans; void work(int l, int r, int k) { if (k <= 1 || l == r) { a[++num] = r - l + 1; return; } int m = (l + r) >> 1; work(l, m, k - 1), work(m + 1, r, k - 1); } int calc...
1081_G. Mergesort Strikes Back
Chouti thought about his very first days in competitive programming. When he had just learned to write merge sort, he thought that the merge sort is too slow, so he restricted the maximum depth of recursion and modified the merge sort to the following: <image> Chouti found his idea dumb since obviously, this "merge s...
{ "input": [ "3 2 998244353\n", "9 3 998244353\n", "3 1 998244353\n", "9 4 998244353\n" ], "output": [ "665496236\n", "449209967\n", "499122178\n", "665496237\n" ] }
{ "input": [ "53812 4 967428361\n", "7 2 400166453\n", "75727 16 485722667\n", "65536 10 802338989\n", "65535 12 196344479\n", "5000 4 961162523\n", "13694 5 579788161\n", "99999 14 746231791\n", "14823 8 622667251\n", "65536 1 262776883\n", "65535 4 585040979\n", "1 2 ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const int N = 200005; int n, k, mod, q1, q2, ans; int inv[N], cnt[N]; void solve(int l, int r, int d) { if (d == 1 || l == r) { int len = r - l + 1; q1&& q1 != len ? q2 = len : q1 = len; ans = (ans + 1ll * len * (len - 1) / 2 % mod * (mod + 1) / 2) % mod; ...
1081_G. Mergesort Strikes Back
Chouti thought about his very first days in competitive programming. When he had just learned to write merge sort, he thought that the merge sort is too slow, so he restricted the maximum depth of recursion and modified the merge sort to the following: <image> Chouti found his idea dumb since obviously, this "merge s...
{ "input": [ "3 2 998244353\n", "9 3 998244353\n", "3 1 998244353\n", "9 4 998244353\n" ], "output": [ "665496236\n", "449209967\n", "499122178\n", "665496237\n" ] }
{ "input": [ "53812 4 967428361\n", "7 2 400166453\n", "75727 16 485722667\n", "65536 10 802338989\n", "65535 12 196344479\n", "5000 4 961162523\n", "13694 5 579788161\n", "99999 14 746231791\n", "14823 8 622667251\n", "65536 1 262776883\n", "65535 4 585040979\n", "1 2 ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const long long N = 1e6 + 5; long long n, k, gs, ans, mod, len[N], jc[N], inv[N], sum[N], ycl[2005][2005]; inline long long read() { long long res = 0, f = 1; char c = getchar(); while (!isdigit(c)) { if (c == '-') f = -1; c = getchar(); } while (isdigit(c...
1081_G. Mergesort Strikes Back
Chouti thought about his very first days in competitive programming. When he had just learned to write merge sort, he thought that the merge sort is too slow, so he restricted the maximum depth of recursion and modified the merge sort to the following: <image> Chouti found his idea dumb since obviously, this "merge s...
{ "input": [ "3 2 998244353\n", "9 3 998244353\n", "3 1 998244353\n", "9 4 998244353\n" ], "output": [ "665496236\n", "449209967\n", "499122178\n", "665496237\n" ] }
{ "input": [ "53812 4 967428361\n", "7 2 400166453\n", "75727 16 485722667\n", "65536 10 802338989\n", "65535 12 196344479\n", "5000 4 961162523\n", "13694 5 579788161\n", "99999 14 746231791\n", "14823 8 622667251\n", "65536 1 262776883\n", "65535 4 585040979\n", "1 2 ...
CORRECT
cpp
#include <bits/stdc++.h> long long n, k, q, t1, t2, cnt1, cnt2, inv4, inv2, inv[200001]; long long ans; inline long long mul(const long long &a, const long long &b) { return 1ll * a * b % q; } inline long long qsm(long long a, long long b) { long long ans = 1; while (b) { if (b & 1) ans = mul(ans, a); a =...
1081_G. Mergesort Strikes Back
Chouti thought about his very first days in competitive programming. When he had just learned to write merge sort, he thought that the merge sort is too slow, so he restricted the maximum depth of recursion and modified the merge sort to the following: <image> Chouti found his idea dumb since obviously, this "merge s...
{ "input": [ "3 2 998244353\n", "9 3 998244353\n", "3 1 998244353\n", "9 4 998244353\n" ], "output": [ "665496236\n", "449209967\n", "499122178\n", "665496237\n" ] }
{ "input": [ "53812 4 967428361\n", "7 2 400166453\n", "75727 16 485722667\n", "65536 10 802338989\n", "65535 12 196344479\n", "5000 4 961162523\n", "13694 5 579788161\n", "99999 14 746231791\n", "14823 8 622667251\n", "65536 1 262776883\n", "65535 4 585040979\n", "1 2 ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; void Freopen() { freopen( "title" ".in", "r", stdin); freopen( "title" ".out", "w", stdout); } int read() { int g = 0, f = 1; char ch = getchar(); while (ch < '0' || '9' < ch) { if (ch == '-') f = -1; ch = getchar(); }...
1081_G. Mergesort Strikes Back
Chouti thought about his very first days in competitive programming. When he had just learned to write merge sort, he thought that the merge sort is too slow, so he restricted the maximum depth of recursion and modified the merge sort to the following: <image> Chouti found his idea dumb since obviously, this "merge s...
{ "input": [ "3 2 998244353\n", "9 3 998244353\n", "3 1 998244353\n", "9 4 998244353\n" ], "output": [ "665496236\n", "449209967\n", "499122178\n", "665496237\n" ] }
{ "input": [ "53812 4 967428361\n", "7 2 400166453\n", "75727 16 485722667\n", "65536 10 802338989\n", "65535 12 196344479\n", "5000 4 961162523\n", "13694 5 579788161\n", "99999 14 746231791\n", "14823 8 622667251\n", "65536 1 262776883\n", "65535 4 585040979\n", "1 2 ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int n, K, P, inv[200003], cnt[200003], mn = 1e9, ans; void solve(int l, int r, int dep) { if (dep == 1 || l == r) { ++cnt[r - l + 1], mn = min(mn, r - l + 1); return; } int mid = (l + r) >> 1; solve(l, mid, dep - 1), solve(mid + 1, r, dep - 1); } int calc(in...
1081_G. Mergesort Strikes Back
Chouti thought about his very first days in competitive programming. When he had just learned to write merge sort, he thought that the merge sort is too slow, so he restricted the maximum depth of recursion and modified the merge sort to the following: <image> Chouti found his idea dumb since obviously, this "merge s...
{ "input": [ "3 2 998244353\n", "9 3 998244353\n", "3 1 998244353\n", "9 4 998244353\n" ], "output": [ "665496236\n", "449209967\n", "499122178\n", "665496237\n" ] }
{ "input": [ "53812 4 967428361\n", "7 2 400166453\n", "75727 16 485722667\n", "65536 10 802338989\n", "65535 12 196344479\n", "5000 4 961162523\n", "13694 5 579788161\n", "99999 14 746231791\n", "14823 8 622667251\n", "65536 1 262776883\n", "65535 4 585040979\n", "1 2 ...
CORRECT
cpp
#include <bits/stdc++.h> #pragma GCC optimize "-O3" using namespace std; long long MOD; long long pw(long long a, long long b) { long long ans = 1; while (b) { while (!(b & 1)) b >>= 1, a = (a * a) % MOD; ans = (ans * a) % MOD, --b; } return ans; } map<int, int> mm; void run(int n, int k) { if (n <= 0...
1081_G. Mergesort Strikes Back
Chouti thought about his very first days in competitive programming. When he had just learned to write merge sort, he thought that the merge sort is too slow, so he restricted the maximum depth of recursion and modified the merge sort to the following: <image> Chouti found his idea dumb since obviously, this "merge s...
{ "input": [ "3 2 998244353\n", "9 3 998244353\n", "3 1 998244353\n", "9 4 998244353\n" ], "output": [ "665496236\n", "449209967\n", "499122178\n", "665496237\n" ] }
{ "input": [ "53812 4 967428361\n", "7 2 400166453\n", "75727 16 485722667\n", "65536 10 802338989\n", "65535 12 196344479\n", "5000 4 961162523\n", "13694 5 579788161\n", "99999 14 746231791\n", "14823 8 622667251\n", "65536 1 262776883\n", "65535 4 585040979\n", "1 2 ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; void read(int &x) { char ch; int fu = 1; while ((ch = getchar()) <= 32) ; x = 0; if (ch == '-') fu = -1; else x = ch - 48; while ((ch = getchar()) > 32) x = x * 10 + ch - 48; x *= fu; } void read(long long &x) { char ch; int fu = 1; while (...
1081_G. Mergesort Strikes Back
Chouti thought about his very first days in competitive programming. When he had just learned to write merge sort, he thought that the merge sort is too slow, so he restricted the maximum depth of recursion and modified the merge sort to the following: <image> Chouti found his idea dumb since obviously, this "merge s...
{ "input": [ "3 2 998244353\n", "9 3 998244353\n", "3 1 998244353\n", "9 4 998244353\n" ], "output": [ "665496236\n", "449209967\n", "499122178\n", "665496237\n" ] }
{ "input": [ "53812 4 967428361\n", "7 2 400166453\n", "75727 16 485722667\n", "65536 10 802338989\n", "65535 12 196344479\n", "5000 4 961162523\n", "13694 5 579788161\n", "99999 14 746231791\n", "14823 8 622667251\n", "65536 1 262776883\n", "65535 4 585040979\n", "1 2 ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int n, k, p, to[210000], pre[210000], ans, inv[2100000], inv2; vector<int> V; int Pow(int x, int y) { int ans = 1; for (int i = 1; i <= y; i *= 2, x = 1LL * x * x % p) if (i & y) ans = 1LL * ans * x % p; return ans; } void dfs(int l, int r, int h) { if (l < r) {...
1081_G. Mergesort Strikes Back
Chouti thought about his very first days in competitive programming. When he had just learned to write merge sort, he thought that the merge sort is too slow, so he restricted the maximum depth of recursion and modified the merge sort to the following: <image> Chouti found his idea dumb since obviously, this "merge s...
{ "input": [ "3 2 998244353\n", "9 3 998244353\n", "3 1 998244353\n", "9 4 998244353\n" ], "output": [ "665496236\n", "449209967\n", "499122178\n", "665496237\n" ] }
{ "input": [ "53812 4 967428361\n", "7 2 400166453\n", "75727 16 485722667\n", "65536 10 802338989\n", "65535 12 196344479\n", "5000 4 961162523\n", "13694 5 579788161\n", "99999 14 746231791\n", "14823 8 622667251\n", "65536 1 262776883\n", "65535 4 585040979\n", "1 2 ...
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; template <typename T> void read(T &x) { x = 0; bool f = 0; char c = getchar(); for (; !isdigit(c); c = getchar()) if (c == '-') f = 1; for (; isdigit(c); c = getchar()) x = x * 10 + (c ^ 48); if (f) x = -x; } template <typename F> inline void write(F x, char...
1081_G. Mergesort Strikes Back
Chouti thought about his very first days in competitive programming. When he had just learned to write merge sort, he thought that the merge sort is too slow, so he restricted the maximum depth of recursion and modified the merge sort to the following: <image> Chouti found his idea dumb since obviously, this "merge s...
{ "input": [ "3 2 998244353\n", "9 3 998244353\n", "3 1 998244353\n", "9 4 998244353\n" ], "output": [ "665496236\n", "449209967\n", "499122178\n", "665496237\n" ] }
{ "input": [ "53812 4 967428361\n", "7 2 400166453\n", "75727 16 485722667\n", "65536 10 802338989\n", "65535 12 196344479\n", "5000 4 961162523\n", "13694 5 579788161\n", "99999 14 746231791\n", "14823 8 622667251\n", "65536 1 262776883\n", "65535 4 585040979\n", "1 2 ...
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; map<int, int> mp; int n, k, mod, inv2; int ans = 0; inline void add(int& a, int b) { a += b; if (a >= mod) a -= mod; if (a < 0) a += mod; } inline int ksm(int a, int b) { int ans = 1; for (; b; b >>= 1, a = (long long)a * a % mod) if (b & 1) ans = (long long)a...
1081_G. Mergesort Strikes Back
Chouti thought about his very first days in competitive programming. When he had just learned to write merge sort, he thought that the merge sort is too slow, so he restricted the maximum depth of recursion and modified the merge sort to the following: <image> Chouti found his idea dumb since obviously, this "merge s...
{ "input": [ "3 2 998244353\n", "9 3 998244353\n", "3 1 998244353\n", "9 4 998244353\n" ], "output": [ "665496236\n", "449209967\n", "499122178\n", "665496237\n" ] }
{ "input": [ "53812 4 967428361\n", "7 2 400166453\n", "75727 16 485722667\n", "65536 10 802338989\n", "65535 12 196344479\n", "5000 4 961162523\n", "13694 5 579788161\n", "99999 14 746231791\n", "14823 8 622667251\n", "65536 1 262776883\n", "65535 4 585040979\n", "1 2 ...
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 10; int cnt[maxn], mod; int Pow(int x, int p) { int r = 1; while (p) { if (p & 1) r = (long long)x * r % mod; p >>= 1; x = (long long)x * x % mod; } return r; } void dfs(int n, int k) { if (n == 1 || k == 1) { cnt[n]++; r...
1081_G. Mergesort Strikes Back
Chouti thought about his very first days in competitive programming. When he had just learned to write merge sort, he thought that the merge sort is too slow, so he restricted the maximum depth of recursion and modified the merge sort to the following: <image> Chouti found his idea dumb since obviously, this "merge s...
{ "input": [ "3 2 998244353\n", "9 3 998244353\n", "3 1 998244353\n", "9 4 998244353\n" ], "output": [ "665496236\n", "449209967\n", "499122178\n", "665496237\n" ] }
{ "input": [ "53812 4 967428361\n", "7 2 400166453\n", "75727 16 485722667\n", "65536 10 802338989\n", "65535 12 196344479\n", "5000 4 961162523\n", "13694 5 579788161\n", "99999 14 746231791\n", "14823 8 622667251\n", "65536 1 262776883\n", "65535 4 585040979\n", "1 2 ...
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; void Freopen() { freopen( "title" ".in", "r", stdin); freopen( "title" ".out", "w", stdout); } int read() { int g = 0, f = 1; char ch = getchar(); while (ch < '0' || '9' < ch) { if (ch == '-') f = -1; ch = getchar(); }...
1081_G. Mergesort Strikes Back
Chouti thought about his very first days in competitive programming. When he had just learned to write merge sort, he thought that the merge sort is too slow, so he restricted the maximum depth of recursion and modified the merge sort to the following: <image> Chouti found his idea dumb since obviously, this "merge s...
{ "input": [ "3 2 998244353\n", "9 3 998244353\n", "3 1 998244353\n", "9 4 998244353\n" ], "output": [ "665496236\n", "449209967\n", "499122178\n", "665496237\n" ] }
{ "input": [ "53812 4 967428361\n", "7 2 400166453\n", "75727 16 485722667\n", "65536 10 802338989\n", "65535 12 196344479\n", "5000 4 961162523\n", "13694 5 579788161\n", "99999 14 746231791\n", "14823 8 622667251\n", "65536 1 262776883\n", "65535 4 585040979\n", "1 2 ...
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int read() { int x = 0, sgn = 1; char ch = getchar(); for (; !isdigit(ch); ch = getchar()) if (ch == '-') sgn = -1; for (; isdigit(ch); ch = getchar()) x = (x << 1) + (x << 3) + (ch ^ 48); return x * sgn; } const int N = 1e5 + 10; int n, k, mod; long long sum[...
1081_G. Mergesort Strikes Back
Chouti thought about his very first days in competitive programming. When he had just learned to write merge sort, he thought that the merge sort is too slow, so he restricted the maximum depth of recursion and modified the merge sort to the following: <image> Chouti found his idea dumb since obviously, this "merge s...
{ "input": [ "3 2 998244353\n", "9 3 998244353\n", "3 1 998244353\n", "9 4 998244353\n" ], "output": [ "665496236\n", "449209967\n", "499122178\n", "665496237\n" ] }
{ "input": [ "53812 4 967428361\n", "7 2 400166453\n", "75727 16 485722667\n", "65536 10 802338989\n", "65535 12 196344479\n", "5000 4 961162523\n", "13694 5 579788161\n", "99999 14 746231791\n", "14823 8 622667251\n", "65536 1 262776883\n", "65535 4 585040979\n", "1 2 ...
IN-CORRECT
cpp
#include<bits/stdc++.h> #define For(i,x,y) for (register int i=(x);i<=(y);i++) #define FOR(i,x,y) for (register int i=(x);i<(y);i++) #define Dow(i,x,y) for (register int i=(x);i>=(y);i--) #define Debug(v) for (auto i:v) printf("%lld ",i);puts("") #define mp make_pair #define fi first #define se second #define pb push_b...
1081_G. Mergesort Strikes Back
Chouti thought about his very first days in competitive programming. When he had just learned to write merge sort, he thought that the merge sort is too slow, so he restricted the maximum depth of recursion and modified the merge sort to the following: <image> Chouti found his idea dumb since obviously, this "merge s...
{ "input": [ "3 2 998244353\n", "9 3 998244353\n", "3 1 998244353\n", "9 4 998244353\n" ], "output": [ "665496236\n", "449209967\n", "499122178\n", "665496237\n" ] }
{ "input": [ "53812 4 967428361\n", "7 2 400166453\n", "75727 16 485722667\n", "65536 10 802338989\n", "65535 12 196344479\n", "5000 4 961162523\n", "13694 5 579788161\n", "99999 14 746231791\n", "14823 8 622667251\n", "65536 1 262776883\n", "65535 4 585040979\n", "1 2 ...
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const int mxN = 1e5; int n, k, q, l1, l2, c1, c2; long long iv[mxN + 1], pi[mxN + 1], ans; void ms(int l = 0, int r = n - 1, int h = k) { if (h < 2 || l == r) { if (!l1 || r - l + 1 == l1) { l1 = r - l + 1; ++c1; } else { l2 = r - l + 1; ++...
1081_G. Mergesort Strikes Back
Chouti thought about his very first days in competitive programming. When he had just learned to write merge sort, he thought that the merge sort is too slow, so he restricted the maximum depth of recursion and modified the merge sort to the following: <image> Chouti found his idea dumb since obviously, this "merge s...
{ "input": [ "3 2 998244353\n", "9 3 998244353\n", "3 1 998244353\n", "9 4 998244353\n" ], "output": [ "665496236\n", "449209967\n", "499122178\n", "665496237\n" ] }
{ "input": [ "53812 4 967428361\n", "7 2 400166453\n", "75727 16 485722667\n", "65536 10 802338989\n", "65535 12 196344479\n", "5000 4 961162523\n", "13694 5 579788161\n", "99999 14 746231791\n", "14823 8 622667251\n", "65536 1 262776883\n", "65535 4 585040979\n", "1 2 ...
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; using ull = uint64_t; using ll = int64_t; using ld = long double; int mod; ll pw(ll a, int b) { if (!b) { return 1; } ll v = pw(a, b / 2); v = (v * v) % mod; if (b & 1) { v = (v * a) % mod; } return v; } ll ans = 0; ll norm(ll x) { x %= mod; if (x ...
1081_G. Mergesort Strikes Back
Chouti thought about his very first days in competitive programming. When he had just learned to write merge sort, he thought that the merge sort is too slow, so he restricted the maximum depth of recursion and modified the merge sort to the following: <image> Chouti found his idea dumb since obviously, this "merge s...
{ "input": [ "3 2 998244353\n", "9 3 998244353\n", "3 1 998244353\n", "9 4 998244353\n" ], "output": [ "665496236\n", "449209967\n", "499122178\n", "665496237\n" ] }
{ "input": [ "53812 4 967428361\n", "7 2 400166453\n", "75727 16 485722667\n", "65536 10 802338989\n", "65535 12 196344479\n", "5000 4 961162523\n", "13694 5 579788161\n", "99999 14 746231791\n", "14823 8 622667251\n", "65536 1 262776883\n", "65535 4 585040979\n", "1 2 ...
IN-CORRECT
cpp
#include <bits/stdc++.h> const int MAXN = 1e5 + 20; int n, k, M; int inv[MAXN], pre_inv[MAXN]; void math_pre() { inv[1] = 1; for (int i = 2; i <= n; ++i) inv[i] = 1ll * (M - M / i) * inv[M % i] % M; for (int i = 1; i <= n; ++i) pre_inv[i] = (pre_inv[i - 1] + inv[i]) % M; } struct map { static const int MAXMap =...
1081_G. Mergesort Strikes Back
Chouti thought about his very first days in competitive programming. When he had just learned to write merge sort, he thought that the merge sort is too slow, so he restricted the maximum depth of recursion and modified the merge sort to the following: <image> Chouti found his idea dumb since obviously, this "merge s...
{ "input": [ "3 2 998244353\n", "9 3 998244353\n", "3 1 998244353\n", "9 4 998244353\n" ], "output": [ "665496236\n", "449209967\n", "499122178\n", "665496237\n" ] }
{ "input": [ "53812 4 967428361\n", "7 2 400166453\n", "75727 16 485722667\n", "65536 10 802338989\n", "65535 12 196344479\n", "5000 4 961162523\n", "13694 5 579788161\n", "99999 14 746231791\n", "14823 8 622667251\n", "65536 1 262776883\n", "65535 4 585040979\n", "1 2 ...
IN-CORRECT
cpp
#include <bits/stdc++.h> int n, k, q, t1, t2, cnt1, cnt2, inv4, inv2, inv[100001]; long long ans; inline int mul(const int &a, const int &b) { return 1ll * a * b % q; } inline int qsm(int a, int b) { int ans = 1; while (b) { if (b & 1) ans = mul(ans, a); a = mul(a, a); b >>= 1; } return ans; } void ...
1081_G. Mergesort Strikes Back
Chouti thought about his very first days in competitive programming. When he had just learned to write merge sort, he thought that the merge sort is too slow, so he restricted the maximum depth of recursion and modified the merge sort to the following: <image> Chouti found his idea dumb since obviously, this "merge s...
{ "input": [ "3 2 998244353\n", "9 3 998244353\n", "3 1 998244353\n", "9 4 998244353\n" ], "output": [ "665496236\n", "449209967\n", "499122178\n", "665496237\n" ] }
{ "input": [ "53812 4 967428361\n", "7 2 400166453\n", "75727 16 485722667\n", "65536 10 802338989\n", "65535 12 196344479\n", "5000 4 961162523\n", "13694 5 579788161\n", "99999 14 746231791\n", "14823 8 622667251\n", "65536 1 262776883\n", "65535 4 585040979\n", "1 2 ...
IN-CORRECT
cpp
#include <bits/stdc++.h> int q, I[200010]; long long inv(int a, int p) { return a == 1 ? 1 : (1 + p * (a - inv(p % a, a))) / a % p; } int f(int a, int b) { int s = 0; for (int i = 0; i < a + b - 1; i++) s = (s + ((i + 1 < a ? i + 1 : a) - (i - b + 1 > 0 ? i - b + 1 : 0)) * 1ll * i % q * I[i +...
1081_G. Mergesort Strikes Back
Chouti thought about his very first days in competitive programming. When he had just learned to write merge sort, he thought that the merge sort is too slow, so he restricted the maximum depth of recursion and modified the merge sort to the following: <image> Chouti found his idea dumb since obviously, this "merge s...
{ "input": [ "3 2 998244353\n", "9 3 998244353\n", "3 1 998244353\n", "9 4 998244353\n" ], "output": [ "665496236\n", "449209967\n", "499122178\n", "665496237\n" ] }
{ "input": [ "53812 4 967428361\n", "7 2 400166453\n", "75727 16 485722667\n", "65536 10 802338989\n", "65535 12 196344479\n", "5000 4 961162523\n", "13694 5 579788161\n", "99999 14 746231791\n", "14823 8 622667251\n", "65536 1 262776883\n", "65535 4 585040979\n", "1 2 ...
IN-CORRECT
cpp
#include <bits/stdc++.h> const int MAXN = 100007; long long MOD; inline long long FST(long long base, int times) { long long ret = 1; while (times) { if (times & 1) ret = ret * base % MOD; times >>= 1; base = base * base % MOD; } return ret; } int seg[MAXN], tot_seg; long long inv[MAXN], invS[MAXN];...
1081_G. Mergesort Strikes Back
Chouti thought about his very first days in competitive programming. When he had just learned to write merge sort, he thought that the merge sort is too slow, so he restricted the maximum depth of recursion and modified the merge sort to the following: <image> Chouti found his idea dumb since obviously, this "merge s...
{ "input": [ "3 2 998244353\n", "9 3 998244353\n", "3 1 998244353\n", "9 4 998244353\n" ], "output": [ "665496236\n", "449209967\n", "499122178\n", "665496237\n" ] }
{ "input": [ "53812 4 967428361\n", "7 2 400166453\n", "75727 16 485722667\n", "65536 10 802338989\n", "65535 12 196344479\n", "5000 4 961162523\n", "13694 5 579788161\n", "99999 14 746231791\n", "14823 8 622667251\n", "65536 1 262776883\n", "65535 4 585040979\n", "1 2 ...
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const long long N = 1e6 + 5; long long n, k, gs, ans, mod, len[N], jc[N], inv[N], sum[N], ycl[2005][2005]; inline long long read() { long long res = 0, f = 1; char c = getchar(); while (!isdigit(c)) { if (c == '-') f = -1; c = getchar(); } while (isdigit(c...
1081_G. Mergesort Strikes Back
Chouti thought about his very first days in competitive programming. When he had just learned to write merge sort, he thought that the merge sort is too slow, so he restricted the maximum depth of recursion and modified the merge sort to the following: <image> Chouti found his idea dumb since obviously, this "merge s...
{ "input": [ "3 2 998244353\n", "9 3 998244353\n", "3 1 998244353\n", "9 4 998244353\n" ], "output": [ "665496236\n", "449209967\n", "499122178\n", "665496237\n" ] }
{ "input": [ "53812 4 967428361\n", "7 2 400166453\n", "75727 16 485722667\n", "65536 10 802338989\n", "65535 12 196344479\n", "5000 4 961162523\n", "13694 5 579788161\n", "99999 14 746231791\n", "14823 8 622667251\n", "65536 1 262776883\n", "65535 4 585040979\n", "1 2 ...
IN-CORRECT
cpp
#include <bits/stdc++.h> #include <ext/pb_ds/priority_queue.hpp> #define priority_queue __gnu_pbds::priority_queue typedef long long LL; typedef long double LD; typedef unsigned int ui; typedef unsigned long long ul; #define ri register int #define pb push_back #define fi first #define se second #define mid ((l + r) >>...
1081_G. Mergesort Strikes Back
Chouti thought about his very first days in competitive programming. When he had just learned to write merge sort, he thought that the merge sort is too slow, so he restricted the maximum depth of recursion and modified the merge sort to the following: <image> Chouti found his idea dumb since obviously, this "merge s...
{ "input": [ "3 2 998244353\n", "9 3 998244353\n", "3 1 998244353\n", "9 4 998244353\n" ], "output": [ "665496236\n", "449209967\n", "499122178\n", "665496237\n" ] }
{ "input": [ "53812 4 967428361\n", "7 2 400166453\n", "75727 16 485722667\n", "65536 10 802338989\n", "65535 12 196344479\n", "5000 4 961162523\n", "13694 5 579788161\n", "99999 14 746231791\n", "14823 8 622667251\n", "65536 1 262776883\n", "65535 4 585040979\n", "1 2 ...
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const int N = 100005; const int MOD = 998244353; int n, k; vector<int> pos; int cnt[N]; void solve(int l, int r, int k) { if (k <= 1 || l == r) { if (cnt[r - l + 1] == 0) pos.push_back(r - l + 1); cnt[r - l + 1]++; return; } int mid = (l + r) / 2; solve(...
1081_G. Mergesort Strikes Back
Chouti thought about his very first days in competitive programming. When he had just learned to write merge sort, he thought that the merge sort is too slow, so he restricted the maximum depth of recursion and modified the merge sort to the following: <image> Chouti found his idea dumb since obviously, this "merge s...
{ "input": [ "3 2 998244353\n", "9 3 998244353\n", "3 1 998244353\n", "9 4 998244353\n" ], "output": [ "665496236\n", "449209967\n", "499122178\n", "665496237\n" ] }
{ "input": [ "53812 4 967428361\n", "7 2 400166453\n", "75727 16 485722667\n", "65536 10 802338989\n", "65535 12 196344479\n", "5000 4 961162523\n", "13694 5 579788161\n", "99999 14 746231791\n", "14823 8 622667251\n", "65536 1 262776883\n", "65535 4 585040979\n", "1 2 ...
IN-CORRECT
cpp
#include <bits/stdc++.h> const int MAXN = 100010; int mod = 998244353; void reduce(int& x) { x += x >> 31 & mod; } int mul(int a, int b) { return (long long)a * b % mod; } int pow(int a, int b, int res = 1) { for (; b; b >>= 1, a = mul(a, a)) if (b & 1) res = mul(res, a); return res; } void mma(int& x, int y, i...
1081_G. Mergesort Strikes Back
Chouti thought about his very first days in competitive programming. When he had just learned to write merge sort, he thought that the merge sort is too slow, so he restricted the maximum depth of recursion and modified the merge sort to the following: <image> Chouti found his idea dumb since obviously, this "merge s...
{ "input": [ "3 2 998244353\n", "9 3 998244353\n", "3 1 998244353\n", "9 4 998244353\n" ], "output": [ "665496236\n", "449209967\n", "499122178\n", "665496237\n" ] }
{ "input": [ "53812 4 967428361\n", "7 2 400166453\n", "75727 16 485722667\n", "65536 10 802338989\n", "65535 12 196344479\n", "5000 4 961162523\n", "13694 5 579788161\n", "99999 14 746231791\n", "14823 8 622667251\n", "65536 1 262776883\n", "65535 4 585040979\n", "1 2 ...
IN-CORRECT
cpp
#include <bits/stdc++.h> const int MAXN = 100007; long long MOD; inline long long FST(long long base, int times) { long long ret = 1; while (times) { if (times & 1) ret = ret * base % MOD; times >>= 1; base = base * base % MOD; } return ret; } long long seg[MAXN], tot_seg; long long inv[MAXN], invS[...
1081_G. Mergesort Strikes Back
Chouti thought about his very first days in competitive programming. When he had just learned to write merge sort, he thought that the merge sort is too slow, so he restricted the maximum depth of recursion and modified the merge sort to the following: <image> Chouti found his idea dumb since obviously, this "merge s...
{ "input": [ "3 2 998244353\n", "9 3 998244353\n", "3 1 998244353\n", "9 4 998244353\n" ], "output": [ "665496236\n", "449209967\n", "499122178\n", "665496237\n" ] }
{ "input": [ "53812 4 967428361\n", "7 2 400166453\n", "75727 16 485722667\n", "65536 10 802338989\n", "65535 12 196344479\n", "5000 4 961162523\n", "13694 5 579788161\n", "99999 14 746231791\n", "14823 8 622667251\n", "65536 1 262776883\n", "65535 4 585040979\n", "1 2 ...
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; map<int, int> mp; int n, k, mod, inv2; int ans = 0; inline void add(int& a, int b) { a += b; if (a >= mod) a -= mod; if (a < 0) a += mod; } inline int ksm(int a, int b) { int ans = 1; for (; b; b >>= 1, a = (long long)a * a % mod) if (b & 1) ans = (long long)a...
1081_G. Mergesort Strikes Back
Chouti thought about his very first days in competitive programming. When he had just learned to write merge sort, he thought that the merge sort is too slow, so he restricted the maximum depth of recursion and modified the merge sort to the following: <image> Chouti found his idea dumb since obviously, this "merge s...
{ "input": [ "3 2 998244353\n", "9 3 998244353\n", "3 1 998244353\n", "9 4 998244353\n" ], "output": [ "665496236\n", "449209967\n", "499122178\n", "665496237\n" ] }
{ "input": [ "53812 4 967428361\n", "7 2 400166453\n", "75727 16 485722667\n", "65536 10 802338989\n", "65535 12 196344479\n", "5000 4 961162523\n", "13694 5 579788161\n", "99999 14 746231791\n", "14823 8 622667251\n", "65536 1 262776883\n", "65535 4 585040979\n", "1 2 ...
IN-CORRECT
cpp
#include <bits/stdc++.h> const int MN = 200000 + 5; using namespace std; template <typename T> inline T& IN(T& in) { in = 0; char c = getchar(); int f = 1; while (!isdigit(c)) { if (c == '-') f = -1; c = getchar(); } while (isdigit(c)) in = in * 10 + c - '0', c = getchar(); return in *= f; } int n...
1081_G. Mergesort Strikes Back
Chouti thought about his very first days in competitive programming. When he had just learned to write merge sort, he thought that the merge sort is too slow, so he restricted the maximum depth of recursion and modified the merge sort to the following: <image> Chouti found his idea dumb since obviously, this "merge s...
{ "input": [ "3 2 998244353\n", "9 3 998244353\n", "3 1 998244353\n", "9 4 998244353\n" ], "output": [ "665496236\n", "449209967\n", "499122178\n", "665496237\n" ] }
{ "input": [ "53812 4 967428361\n", "7 2 400166453\n", "75727 16 485722667\n", "65536 10 802338989\n", "65535 12 196344479\n", "5000 4 961162523\n", "13694 5 579788161\n", "99999 14 746231791\n", "14823 8 622667251\n", "65536 1 262776883\n", "65535 4 585040979\n", "1 2 ...
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int MOD; int inv[200005]; void gen_inv(int maxa) { inv[1] = 1; for (int i = 2; i <= maxa; i++) inv[i] = MOD - 1LL * inv[MOD % i] * (MOD / i) % MOD; } int getans(int u, int v) { int ans = 0; for (int i = 2; i <= u + v; i++) ans = (ans + 1LL * (min(u, i - 1) -...
1081_G. Mergesort Strikes Back
Chouti thought about his very first days in competitive programming. When he had just learned to write merge sort, he thought that the merge sort is too slow, so he restricted the maximum depth of recursion and modified the merge sort to the following: <image> Chouti found his idea dumb since obviously, this "merge s...
{ "input": [ "3 2 998244353\n", "9 3 998244353\n", "3 1 998244353\n", "9 4 998244353\n" ], "output": [ "665496236\n", "449209967\n", "499122178\n", "665496237\n" ] }
{ "input": [ "53812 4 967428361\n", "7 2 400166453\n", "75727 16 485722667\n", "65536 10 802338989\n", "65535 12 196344479\n", "5000 4 961162523\n", "13694 5 579788161\n", "99999 14 746231791\n", "14823 8 622667251\n", "65536 1 262776883\n", "65535 4 585040979\n", "1 2 ...
IN-CORRECT
cpp
#include <bits/stdc++.h> using std::cerr; using std::endl; const int N = 1e5 + 10; int n, K, P, inv[N], sum[N], ans; std::map<int, int> map; void divide(int l, int r, int dep) { if (l == r || dep == K) { return ++map[r - l + 1], void(); } int mid = (l + r) >> 1; divide(l, mid, dep + 1); divide(mid + 1, r,...
1081_G. Mergesort Strikes Back
Chouti thought about his very first days in competitive programming. When he had just learned to write merge sort, he thought that the merge sort is too slow, so he restricted the maximum depth of recursion and modified the merge sort to the following: <image> Chouti found his idea dumb since obviously, this "merge s...
{ "input": [ "3 2 998244353\n", "9 3 998244353\n", "3 1 998244353\n", "9 4 998244353\n" ], "output": [ "665496236\n", "449209967\n", "499122178\n", "665496237\n" ] }
{ "input": [ "53812 4 967428361\n", "7 2 400166453\n", "75727 16 485722667\n", "65536 10 802338989\n", "65535 12 196344479\n", "5000 4 961162523\n", "13694 5 579788161\n", "99999 14 746231791\n", "14823 8 622667251\n", "65536 1 262776883\n", "65535 4 585040979\n", "1 2 ...
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 7; long long MOD, f[N]; long long qpow(long long x, long long y) { long long z = 1; while (y > 0) { if (y % 2) z = z * x % MOD; x = x * x % MOD; y /= 2; } return z; } map<int, int> ma; pair<int, int> a[10]; void dfs(int x, int k) { ...
1081_G. Mergesort Strikes Back
Chouti thought about his very first days in competitive programming. When he had just learned to write merge sort, he thought that the merge sort is too slow, so he restricted the maximum depth of recursion and modified the merge sort to the following: <image> Chouti found his idea dumb since obviously, this "merge s...
{ "input": [ "3 2 998244353\n", "9 3 998244353\n", "3 1 998244353\n", "9 4 998244353\n" ], "output": [ "665496236\n", "449209967\n", "499122178\n", "665496237\n" ] }
{ "input": [ "53812 4 967428361\n", "7 2 400166453\n", "75727 16 485722667\n", "65536 10 802338989\n", "65535 12 196344479\n", "5000 4 961162523\n", "13694 5 579788161\n", "99999 14 746231791\n", "14823 8 622667251\n", "65536 1 262776883\n", "65535 4 585040979\n", "1 2 ...
IN-CORRECT
cpp
//~ while (clock()<=69*CLOCKS_PER_SEC) //~ #pragma comment(linker, "/stack:200000000") //~ #pragma GCC optimize("O3") //~ #pragma GCC optimize("Ofast") //~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") //~ #pragma GCC optimize("unroll-loops") #include<bits/stdc++.h> #include <ext/pb_ds/a...