QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#82057 | #4059. 无处存储 | abcdefg | 100 ✓ | 1165ms | 63548kb | C++14 | 20.2kb | 2023-02-27 00:17:56 | 2023-02-27 00:19:03 |
Judging History
answer
#include <algorithm>
#include <cstdio>
#include <cstring>
namespace INPUT_SPACE {
const int S = (1 << 20) + 5;
char B[S], *H, *T;
inline int gc() {
if (H == T) T = (H = B) + fread(B, 1, S, stdin);
return (H == T) ? EOF : *H++;
}
inline unsigned int inn() {
unsigned int x, ch;
while ((ch = gc()) < '0' || ch > '9')
;
x = ch ^ '0';
while ((ch = gc()) >= '0' && ch <= '9') x = x * 10 + (ch ^ '0');
return x;
}
} // namespace INPUT_SPACE
using INPUT_SPACE::inn;
namespace GENERATE_VALUE_SPACE {
unsigned int _gen(unsigned int x, unsigned int A, unsigned int B, unsigned int C) {
return A * x * x + B * x + C;
}
void gen_value(unsigned int *a, int n, unsigned int A, unsigned int B, unsigned int C,
unsigned int a0) {
a[1] = _gen(a0, A, B, C);
for (int i = 2; i <= n; i++) a[i] = _gen(a[i - 1], A, B, C);
}
} // namespace GENERATE_VALUE_SPACE
using GENERATE_VALUE_SPACE::gen_value;
#define rep(i, a, b) for (int i = (a), ed##i = (b); i <= ed##i; ++i)
#define per(i, a, b) for (int i = (a), ed##i = (b); i >= ed##i; --i)
#define re(i, a) rep (i, 1, a)
#define fio(x) freopen(x ".in", "r", stdin), freopen(x ".out", "w", stdout)
unsigned int a[7000000 + 9];
const int POL_SIZE = 6.4e7;
unsigned char pol[POL_SIZE];
int n, q;
namespace st1 {
const int sz = 800;
unsigned *add = (unsigned *)pol, *sum = (unsigned *)(pol + sizeof(pol) / 2);
inline void swap(int &x, int &y) { x ^= y, y ^= x, x ^= y; }
inline void Add(int l, int r, unsigned v) {
if (l > r) swap(l, r);
if (l / sz == r / sz) {
rep (i, l, r)
a[i] += v;
sum[l / sz] += (r - l + 1) * v;
return;
}
rep (i, l, l - l % sz + sz - 1)
a[i] += v, sum[l / sz] += v;
rep (i, l / sz + 1, r / sz - 1)
sum[i] += v * sz, add[i] += v;
rep (i, r - r % sz, r)
a[i] += v, sum[r / sz] += v;
}
inline unsigned Ask(int l, int r) {
if (l > r) swap(l, r);
unsigned res = 0;
if (l / sz == r / sz) {
rep (i, l, r)
res += a[i];
return res + add[l / sz] * (r - l + 1);
}
rep (i, l, l - l % sz + sz - 1)
res += a[i] + add[i / sz];
// fprintf(stderr,"%d\n",res);
rep (i, l / sz + 1, r / sz - 1)
res += sum[i];
// fprintf(stderr,"%d\n",res);
rep (i, r - r % sz, r)
res += a[i] + add[i / sz];
return res;
}
void Main() {
// re(i,n)a[i]=inn();
unsigned int A = inn(), B = inn(), C = inn(), a0 = inn();
GENERATE_VALUE_SPACE::gen_value(a, n, A, B, C, a0);
unsigned int last_ans = 0;
re (i, n)
sum[i / sz] += a[i];
re (i, n - 1)
inn(); // read fa
for (int i = 1; i <= q; i++) {
int t = inn();
int P = last_ans & ((1 << 20) - 1);
// fprintf(stderr,"%d\n",t);
if (t == 0) {
int x = inn() ^ P, y = inn() ^ P;
unsigned int v = inn() ^ P;
Add(x, y, v);
} else {
int x = inn() ^ P, y = inn() ^ P;
// fprintf(stderr,"%d %d\n",x,y);
printf("%u\n", last_ans = Ask(x, y));
}
// return;
}
}
} // namespace st1
namespace st2 {
int *fa = (int *)pol;
unsigned char *visst = pol + sizeof(int[7000009]);
inline bool VisGet(int x) { return (visst[x / 8] >> (x % 8)) & 1; }
inline void VisSet(int x, bool y) {
(visst[x / 8]) &= ~(1 << (x % 8));
(visst[x / 8]) |= (int(y) << (x % 8));
}
inline void Add(int f, int t, unsigned v) {
for (int x = f; x; x = fa[x]) VisSet(x, 1), a[x] += v;
for (int y = t; y; y = fa[y]) {
if (VisGet(y)) {
for (int z = fa[y]; z; z = fa[z]) a[z] -= v;
break;
}
VisSet(y, 1);
a[y] += v;
}
for (int x = f; x; x = fa[x]) VisSet(x, 0);
for (int x = t; x; x = fa[x]) VisSet(x, 0);
}
inline unsigned Ask(int f, int t) {
unsigned res = 0;
for (int x = f; x; x = fa[x]) VisSet(x, 1), res += a[x];
for (int y = t; y; y = fa[y]) {
if (VisGet(y)) {
for (int z = fa[y]; z; z = fa[z]) res -= a[z];
break;
}
VisSet(y, 1);
res += a[y];
}
for (int x = f; x; x = fa[x]) VisSet(x, 0);
for (int x = t; x; x = fa[x]) VisSet(x, 0);
return res;
}
void Main() {
unsigned int A = inn(), B = inn(), C = inn(), a0 = inn();
GENERATE_VALUE_SPACE::gen_value(a, n, A, B, C, a0);
unsigned int last_ans = 0;
for (int i = 2; i <= n; i++) fa[i] = inn();
for (int i = 1; i <= q; i++) {
int t = inn();
int P = last_ans & ((1 << 20) - 1);
// fprintf(stderr,"%d\n",t);
if (t == 0) {
int x = inn() ^ P, y = inn() ^ P;
unsigned int v = inn() ^ P;
Add(x, y, v);
} else {
int x = inn() ^ P, y = inn() ^ P;
// fprintf(stderr,"%d %d\n",x,y);
printf("%u\n", last_ans = Ask(x, y));
}
// return;
}
}
} // namespace st2
namespace st3 {
struct SmallArray {
unsigned *st;
inline int operator[](int x) const {
x *= 23;
// fprintf(stderr,"%llu\n",((1ull*st[x/32]<<32)|st[x/32+1]));
// fprintf(stderr,"%d\n",(64-x%32-23));
return (((1ull * st[x / 32] << 32) | st[x / 32 + 1]) >> (64 - x % 32 - 23)) % (1 << 23);
}
inline void Set(int x, int v) {
x *= 23;
unsigned long long msk = ~(((1ull << 23) - 1) << (64 - x % 32 - 23));
// fprintf(stderr,"%llu %u\n",msk,msk>>32);
// fprintf(stderr,"%u\n",st[0]);
st[x / 32] &= msk >> 32;
// fprintf(stderr,"%u\n",st[0]);
st[x / 32 + 1] &= unsigned(msk);
msk = 1ull * v << (64 - x % 32 - 23);
st[x / 32] |= msk >> 32;
st[x / 32 + 1] |= unsigned(msk);
// fprintf(stderr,"%llu\n",*p);
// fprintf(stderr,"%u\n",st[0]);
// fprintf(stderr,"%u\n",st[1]);
}
} sa, sb;
const int sz = 800;
unsigned *add, *sum;
unsigned char *visst;
inline bool VisGet(int x) { return (visst[x / 8] >> (x % 8)) & 1; }
inline void VisSet(int x, bool y) {
(visst[x / 8]) &= ~(1 << (x % 8));
(visst[x / 8]) |= (int(y) << (x % 8));
}
inline void swap(int &x, int &y) { x ^= y, y ^= x, x ^= y; }
inline void BlAdd(int l, int r, unsigned v) {
if (l > r) swap(l, r);
if (l / sz == r / sz) {
rep (i, l, r)
a[i] += v;
sum[l / sz] += (r - l + 1) * v;
return;
}
rep (i, l, l - l % sz + sz - 1)
a[i] += v, sum[l / sz] += v;
rep (i, l / sz + 1, r / sz - 1)
sum[i] += v * sz, add[i] += v;
rep (i, r - r % sz, r)
a[i] += v, sum[r / sz] += v;
}
inline unsigned BlAsk(int l, int r) {
if (l > r) swap(l, r);
unsigned res = 0;
if (l / sz == r / sz) {
rep (i, l, r)
res += a[i];
return res + add[l / sz] * (r - l + 1);
}
rep (i, l, l - l % sz + sz - 1)
res += a[i] + add[i / sz];
// fprintf(stderr,"%d\n",res);
rep (i, l / sz + 1, r / sz - 1)
res += sum[i];
// fprintf(stderr,"%d\n",res);
rep (i, r - r % sz, r)
res += a[i] + add[i / sz];
return res;
}
inline int Tp(int x) { return VisGet(x) ? x : sa[x]; }
inline void Add(int f, int t, unsigned v) {
while (Tp(f) != Tp(t)) {
// fprintf(stderr, "f %d, t %d\n", f, t);
if (sb[Tp(f)] > sb[Tp(t)]) swap(f, t);
BlAdd(sb[Tp(t)], sb[t], v);
t = sa[Tp(t)];
}
if (sb[f] > sb[t]) swap(f, t);
BlAdd(sb[f], sb[t], v);
}
inline unsigned Ask(int f, int t) {
unsigned res = 0;
while (Tp(f) != Tp(t)) {
if (sb[Tp(f)] > sb[Tp(t)]) swap(f, t);
// fprintf(stderr, "f %d, t %d, Tp(f) %d, Tp(t) %d, df %d, dt %d\n", f, t,
// Tp(f), Tp(t), sb[Tp(f)],
// sb[Tp(t)]);
res += BlAsk(sb[Tp(t)], sb[t]);
t = sa[Tp(t)];
}
if (sb[f] > sb[t]) swap(f, t);
res += BlAsk(sb[f], sb[t]);
return res;
}
namespace ABC {
unsigned int _gen(unsigned int x, unsigned int A, unsigned int B, unsigned int C) {
return A * x * x + B * x + C;
}
void gen_value(unsigned int *a, int n, unsigned int A, unsigned int B, unsigned int C,
unsigned int a0) {
a[sb[1]] = _gen(a0, A, B, C);
for (int i = 2; i <= n; i++) a[sb[i]] = _gen(a[sb[i - 1]], A, B, C);
}
} // namespace ABC
void Main() {
// fprintf(stderr, "%zu\n", sizeof(pol));
// fprintf(stderr, "%d\n", 2 * ((n + 5) * 23 / 8) + (n / 8 + 5) + (2 * n / sz
// + 2) * 4 * 2); return;
sa.st = (unsigned *)pol;
sb.st = (unsigned *)((unsigned char *)pol + ((n + 5) * 23 / 8));
visst = (unsigned char *)sb.st + ((n + 5) * 23 / 8);
add = (unsigned *)((unsigned char *)visst + n / 8 + 5);
sum = (unsigned *)((unsigned char *)add + (2 * n / sz + 2) * 4);
unsigned int A = inn(), B = inn(), C = inn(), a0 = inn();
unsigned int last_ans = 0;
for (int i = 2; i <= n; i++) {
int x = inn();
sa.Set(i, x);
}
per (i, n, 1) {
// sz[i]+=1
// sz[fa[i]]+=sz[i]
sb.Set(i, sb[i] + 1);
sb.Set(sa[i], sb[sa[i]] + sb[i]);
}
re (i, n) {
if (sb[i] > 100) sb.Set(sa[i], i), VisSet(sa[i], 1);
}
re (i, n) {
if (!VisGet(sa[i])) sb.Set(sa[i], i), VisSet(sa[i], 1);
}
per (i, n, 1) {
if (sb[i] == 1) sb.Set(i, 0);
}
// now sb is heavy son
// fprintf(stderr, "YES\n");
rep (i, 2, n)
VisSet(i, sb[sa[i]] != i);
sb.Set(0, 0);
VisSet(1, 1);
int tim = 0;
re (i, n) {
if (!VisGet(i)) continue;
// fprintf(stderr, "i = %d\n", i);
int hs = 0;
for (int j = i; j; j = hs) {
hs = sb[j], sb.Set(j, ++tim);
if (i != j) sa.Set(j, i);
}
// fprintf(stderr, "i = %d\n", i);
}
// return;
// now sa=istp?fa:tp, sb=dfn
ABC::gen_value(a, n, A, B, C, a0);
// fprintf(stderr, "YES2\n");
re (i, n)
sum[i / sz] += a[i];
for (int i = 1; i <= q; i++) {
// fprintf(stderr, "i = %d\n", i);
int t = inn();
int P = last_ans & ((1 << 20) - 1);
// fprintf(stderr, "%d\n", t);
if (t == 0) {
int x = inn() ^ P, y = inn() ^ P;
// fprintf(stderr, "%d %d\n", x, y);
unsigned int v = inn() ^ P;
Add(x, y, v);
} else {
int x = inn() ^ P, y = inn() ^ P;
// fprintf(stderr, "%d %d\n", x, y);
printf("%u\n", last_ans = Ask(x, y));
// fprintf(stderr, "%u\n", last_ans);
}
// return;
}
}
} // namespace st3
namespace st4 {
template <size_t T>
struct SmallArray {
unsigned *st;
inline int operator[](int x) const {
x *= T;
return (((1ull * st[x / 32] << 32) | st[x / 32 + 1]) >> (64 - x % 32 - T)) % (1 << T);
}
inline void Set(int x, unsigned v) {
v %= 1 << T;
x *= T;
unsigned long long msk = ~(((1ull << T) - 1) << (64 - x % 32 - T));
st[x / 32] &= msk >> 32;
st[x / 32 + 1] &= unsigned(msk);
msk = 1ull * v << (64 - x % 32 - T);
st[x / 32] |= msk >> 32;
st[x / 32 + 1] |= unsigned(msk);
}
};
SmallArray<23> sa, sb;
SmallArray<20> a;
unsigned *add, *sum, *ops, *opx, *opy, *opz, *v, *vv, *fa, *imp, *use, *ra, *sumv, *b;
const int sz = 800;
unsigned char *visst;
inline bool VisGet(int x) { return (visst[x / 8] >> (x % 8)) & 1; }
inline void VisSet(int x, bool y) {
(visst[x / 8]) &= ~(1 << (x % 8));
(visst[x / 8]) |= (int(y) << (x % 8));
}
inline void swap(int &x, int &y) { x ^= y, y ^= x, x ^= y; }
inline void BlAdd(int l, int r, unsigned va, bool fl) {
if (!fl) {
if (l > r) swap(l, r);
if (l / sz == r / sz) {
rep (i, l, r)
a.Set(i, a[i] + va);
sum[l / sz] += (r - l + 1) * va;
return;
}
rep (i, l, l - l % sz + sz - 1)
a.Set(i, a[i] + va), sum[l / sz] += va;
rep (i, l / sz + 1, r / sz - 1)
sum[i] += va * sz, add[i] += va;
rep (i, r - r % sz, r)
a.Set(i, a[i] + va), sum[r / sz] += va;
return;
}
if (l > r) swap(l, r);
if (l / sz == r / sz) {
rep (i, l, r)
b[i] += va * vv[i], sum[i / sz] += va * vv[i];
return;
}
rep (i, l, l - l % sz + sz - 1)
b[i] += va * vv[i], sum[l / sz] += va * vv[i];
rep (i, l / sz + 1, r / sz - 1)
sum[i] += va * sumv[i], add[i] += va;
rep (i, r - r % sz, r)
b[i] += va * vv[i], sum[r / sz] += va * vv[i];
}
inline unsigned BlAsk(int l, int r, bool fl) {
if (!fl) {
if (l > r) swap(l, r);
unsigned res = 0;
if (l / sz == r / sz) {
rep (i, l, r)
res += a[i];
return res + add[l / sz] * (r - l + 1);
}
rep (i, l, l - l % sz + sz - 1)
res += a[i] + add[i / sz];
rep (i, l / sz + 1, r / sz - 1)
res += sum[i];
rep (i, r - r % sz, r)
res += a[i] + add[i / sz];
return res;
}
if (l > r) swap(l, r);
unsigned res = 0;
if (l / sz == r / sz) {
rep (i, l, r) {
// fprintf(stderr, "%d %d\n", i, b[i]);
res += b[i] + add[l / sz] * vv[i];
}
return res;
}
rep (i, l, l - l % sz + sz - 1)
res += b[i] + add[i / sz] * vv[i];
rep (i, l / sz + 1, r / sz - 1)
res += sum[i];
rep (i, r - r % sz, r)
res += b[i] + add[i / sz] * vv[i];
return res;
}
inline int Tp(int x) { return VisGet(x) ? x : sa[x]; }
inline void Add(int f, int t, unsigned v, bool b) {
while (Tp(f) != Tp(t)) {
// fprintf(stderr, "f %d, t %d\n", f, t);
if (sb[Tp(f)] > sb[Tp(t)]) swap(f, t);
BlAdd(sb[Tp(t)], sb[t], v, b);
t = sa[Tp(t)];
}
if (sb[f] > sb[t]) swap(f, t);
BlAdd(sb[f], sb[t], v, b);
}
inline unsigned Ask(int f, int t, bool b) {
unsigned res = 0;
while (Tp(f) != Tp(t)) {
if (sb[Tp(f)] > sb[Tp(t)]) swap(f, t);
// if (b)
// fprintf(stderr, "f %d, t %d, Tp(f) %d, Tp(t) %d, df %d, dt %d\n", f, t, Tp(f), Tp(t),
// sb[Tp(f)], sb[Tp(t)]);
res += BlAsk(sb[Tp(t)], sb[t], b);
t = sa[Tp(t)];
}
if (sb[f] > sb[t]) swap(f, t);
res += BlAsk(sb[f], sb[t], b);
return res;
}
namespace ABC {
unsigned int _gen(unsigned int x, unsigned int A, unsigned int B, unsigned int C) {
return A * x * x + B * x + C;
}
void gen_value(int n, unsigned int A, unsigned int B, unsigned int C, unsigned int a0) {
unsigned lst = 0;
lst = _gen(a0, A, B, C);
a.Set(sb[1], lst);
for (int i = 2; i <= n; i++) lst = _gen(lst, A, B, C), a.Set(sb[i], lst);
}
void gen_value(unsigned int *a, int n, unsigned int A, unsigned int B, unsigned int C,
unsigned int a0) {
a[1] = _gen(a0, A, B, C);
for (int i = 2; i <= n; i++) a[i] = _gen(a[i - 1], A, B, C);
}
} // namespace ABC
// 清空内存
inline void Clear() {
fseek(stdin, 0, SEEK_SET);
memset(INPUT_SPACE::B, 0, sizeof INPUT_SPACE::B);
INPUT_SPACE::H = INPUT_SPACE::T = 0;
}
inline void SP(int n) {
per (i, n, 1) {
// sz[i]+=1
// sz[fa[i]]+=sz[i]
sb.Set(i, sb[i] + 1);
sb.Set(sa[i], sb[sa[i]] + sb[i]);
}
re (i, n) {
if (sb[i] > 100) sb.Set(sa[i], i), VisSet(sa[i], 1);
}
re (i, n) {
if (!VisGet(sa[i])) sb.Set(sa[i], i), VisSet(sa[i], 1);
}
per (i, n, 1) {
if (sb[i] == 1) sb.Set(i, 0);
}
// now sb is heavy son
// fprintf(stderr, "YES\n");
rep (i, 2, n)
VisSet(i, sb[sa[i]] != i);
sb.Set(0, 0);
VisSet(1, 1);
int tim = 0;
re (i, n) {
if (!VisGet(i)) continue;
// fprintf(stderr, "i = %d\n", i);
int hs = 0;
for (int j = i; j; j = hs) {
hs = sb[j], sb.Set(j, ++tim);
if (i != j) sa.Set(j, i);
}
// fprintf(stderr, "i = %d\n", i);
}
// now sa=istp?fa:tp, sb=dfn
}
inline void Work1() {
ops = (unsigned *)pol;
opx = ops + 50005;
opy = opx + 50005;
opz = opy + 50005;
v = opz + 50005;
fa = v + 300005;
imp = fa + 300005;
use = imp + 300005;
visst = (unsigned char *)(use + 300005);
sa.st = (unsigned *)((unsigned char *)visst + n / 8 + 5);
sb.st = (unsigned *)((unsigned char *)sa.st + ((n + 5) * 23 / 8));
add = (unsigned *)((unsigned char *)sb.st + ((n + 5) * 23 / 8));
sum = (unsigned *)((unsigned char *)add + (2 * n / sz + 2) * 4);
a.st = (unsigned *)((unsigned char *)sum + (2 * n / sz + 2) * 4);
// fprintf(stderr, "%zd\n", (unsigned char *)a.st - (unsigned char *)pol);
unsigned int A = inn(), B = inn(), C = inn(), a0 = inn();
unsigned int last_ans = 0;
for (int i = 2; i <= n; i++) {
int x = inn();
sa.Set(i, x);
}
SP(n);
ABC::gen_value(n, A, B, C, a0);
// fprintf(stderr, "YES2\n");
re (i, n)
sum[i / sz] += a[i];
for (int i = 1; i <= q; i++) {
// fprintf(stderr, "i = %d\n", i);
int t = inn();
ops[i] = t;
int P = last_ans & ((1 << 20) - 1);
// fprintf(stderr, "%d\n", t);
if (t == 0) {
int x = inn() ^ P, y = inn() ^ P;
// fprintf(stderr, "%d %d\n", x, y);
unsigned int v = inn() ^ P;
opx[i] = x, opy[i] = y, opz[i] = v;
Add(x, y, v, 0);
} else {
int x = inn() ^ P, y = inn() ^ P;
// fprintf(stderr, "%d %d\n", x, y);
opx[i] = x, opy[i] = y;
last_ans = Ask(x, y, 0);
// printf("- %u\n", last_ans);
// fprintf(stderr, "%u\n", last_ans);
}
// return;
}
}
inline int Id(int x) {
auto it = std::lower_bound(use + 1, use + use[0] + 1, x);
if (it == use + use[0] + 1) return 0;
return (int)*it == x ? it - use : 0;
}
void Main() {
Work1();
// fprintf(stderr, "vis1: %d\n", VisGet(1));
Clear();
// fprintf(stderr, "vis1: %d\n", VisGet(1));
// fprintf(stderr, "vis1: %d\n", VisGet(1));
use[++use[0]] = 1;
// fprintf(stderr, "vis1: %d\n", VisGet(1));
// fprintf(stderr, "opx1: %d\n", opx[1]);
// fprintf(stderr, "lca: %d\n", Lca(5932174, 1910562));
int impsz = 0;
re (i, q)
imp[++impsz] = opx[i], imp[++impsz] = opy[i];
std::sort(imp + 1, imp + impsz + 1);
impsz = std::unique(imp + 1, imp + impsz + 1) - imp - 1;
inn(), inn(), inn();
unsigned int A = inn(), B = inn(), C = inn(), a0 = inn();
unsigned int last_ans = 0;
for (int i = 2; i <= n; i++) {
int x = inn();
sa.Set(i, x);
}
re (i, n)
VisSet(i, 0);
use[++use[0]] = 1;
VisSet(1, 1);
re (i, impsz) {
use[++use[0]] = imp[i];
if (imp[i] == 1) continue;
int j;
for (j = imp[i]; j && !VisGet(j); j = sa[j]) VisSet(j, 1);
use[++use[0]] = j;
}
std::sort(use + 1, use + use[0] + 1);
use[0] = std::unique(use + 1, use + use[0] + 1) - use - 1;
// fprintf(stderr, "usesz: %d\n", use[0]);
re (i, use[0])
if (use[i] != 1) {
use[++use[0]] = sa[use[i]];
// fprintf(stderr, "find: %d\n", use[i]);
// fprintf(stderr, "find1: %d\n", sa[use[i]]);
// if (use[i] == 259122) fprintf(stderr, "find1: %d\n", use[i]);
}
// fprintf(stderr, "usesz: %d\n", use[0]);
std::sort(use + 1, use + use[0] + 1);
use[0] = std::unique(use + 1, use + use[0] + 1) - use - 1;
// fprintf(stderr, "Yes\n");
ra = sb.st;
vv = ra + (n + 5);
sumv = vv + 300005;
sb.st = sumv + 300005;
add = (unsigned *)((unsigned char *)sb.st + (300005 * 23 / 8));
sum = (unsigned *)((unsigned char *)add + (2 * 300005 / sz + 2) * 4);
b = (unsigned *)((unsigned char *)sum + (2 * 300005 / sz + 2) * 4);
for (unsigned char *i = (unsigned char *)ra; i != (unsigned char *)(b + 300005); ++i) *i = 0;
ABC::gen_value(ra, n, A, B, C, a0);
re (i, n)
VisSet(i, 0);
// fprintf(stderr, "Yes\n");
re (ii, use[0]) {
int i = use[ii];
v[ii] = 1;
if (i == 1) continue;
for (fa[ii] = sa[i]; !Id(fa[ii]); fa[ii] = sa[fa[ii]]) ++v[ii], ra[i] += ra[fa[ii]];
fa[ii] = Id(fa[ii]);
}
re (i, use[0])
sa.Set(i, fa[i]);
SP(use[0]);
re (i, use[0])
b[sb[i]] = ra[use[i]], sum[sb[i] / sz] += b[sb[i]], vv[sb[i]] = v[i], sumv[sb[i] / sz] += v[i];
for (int i = 1; i <= q; i++) {
// fprintf(stderr, "i = %d\n", i);
int t = inn();
int P = last_ans & ((1 << 20) - 1);
// fprintf(stderr, "%d\n", t);
if (t == 0) {
int x = inn() ^ P, y = inn() ^ P;
// fprintf(stderr, "%d %d\n", x, y);
x = Id(x), y = Id(y);
if (!x) exit(-1);
// fprintf(stderr, "%d %d\n", x, y);
unsigned int v = inn() ^ P;
Add(x, y, v, 1);
} else {
int x = inn() ^ P, y = inn() ^ P;
// fprintf(stderr, "%d %d\n", x, y);
x = Id(x), y = Id(y);
if (!x) exit(-1);
// fprintf(stderr, "x y %d %d\n", x, y);
printf("%u\n", last_ans = Ask(x, y, 1));
}
// return;
}
}
} // namespace st4
int main() {
// fio("problemprovidercreep");
// fio("15");
int subtask_id = inn();
n = inn(), q = inn();
if (subtask_id <= 2) {
st2::Main();
return 0;
}
if (subtask_id >= 3 and subtask_id <= 16) {
st1::Main();
return 0;
}
if (subtask_id != 23 && subtask_id != 30 && subtask_id != 37 && subtask_id != 44) {
st3::Main();
return 0;
}
st4::Main();
return 0;
}
詳細信息
Subtask #1:
score: 2
Accepted
Test #1:
score: 2
Accepted
time: 14ms
memory: 5692kb
input:
1 3000 3000 104585880 694156206 633926329 466825101 1 1 3 4 2 6 5 7 8 10 11 9 12 13 15 16 17 14 18 19 21 22 20 23 25 26 27 28 24 29 31 30 33 32 34 35 36 38 37 39 40 42 41 44 45 43 47 46 49 50 51 48 53 52 55 56 54 57 58 59 60 62 63 64 65 66 61 68 67 70 71 69 73 74 72 75 76 77 79 78 80 82 81 84 85 83 ...
output:
1427397146 650198085 721688859 4258384878 887209466 3329396569 1991759671 4026270784 899104823 2246112063 3221717881 956365516 1349790784 1771302665 1569334497 706342085 3573588494 3969161600 836904478 507957547 3232549772 2077012038 1522169920 4242289704 3096293324 4261965707 1573506765 4220545115 ...
result:
ok 1456 numbers
Subtask #2:
score: 2
Accepted
Test #2:
score: 2
Accepted
time: 135ms
memory: 59160kb
input:
2 7000000 50000 130452841 691469363 294881855 114384663 1 2 1 3 4 4 7 1 7 7 11 10 7 14 5 5 16 8 9 17 21 9 8 6 6 17 27 15 10 10 14 8 27 20 20 25 29 17 23 17 2 9 7 23 3 20 13 19 14 9 33 44 36 48 5 34 48 55 58 54 28 46 13 20 59 17 58 66 31 55 17 27 65 33 21 23 27 22 37 28 9 11 29 62 45 56 34 74 42 82 2...
output:
3556148271 1338594626 4097686927 2331740060 877574392 3092730285 1220980789 1119878644 1769113520 1879104210 2151234686 3842464161 3877503260 2261668913 1517620837 2475194586 2473825220 3456654038 121430628 2393217162 1788113394 4197372295 748941277 1075419042 351121091 789084939 2291506354 38778147...
result:
ok 24787 numbers
Subtask #3:
score: 2
Accepted
Test #3:
score: 2
Accepted
time: 34ms
memory: 10724kb
input:
3 1000000 50000 396118271 5719204 205626250 96460839 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 8...
output:
3231108387 4051829856 1430455649 1982511367 638785546 3911364214 3371606902 3399075597 1637012635 17055700 3641853869 421062112 3428797713 205489974 1772759291 2321813495 1165163779 4004176880 387779599 3132824131 4175238781 3487399209 3261823848 4257125642 2040490914 865458133 4050584869 1230894420...
result:
ok 24759 numbers
Subtask #4:
score: 2
Accepted
Dependency #3:
100%
Accepted
Test #4:
score: 2
Accepted
time: 41ms
memory: 14800kb
input:
4 2000000 50000 182624709 831479751 43859310 715688095 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85...
output:
2447384580 2705505836 878523570 1346424958 2023441804 692450459 3500691905 1357934051 2708384463 3752425428 146166462 3084987888 3035252331 2414487330 4059739044 2374807638 1426808341 10544379 964438112 1778276048 947942632 804398428 865194497 2315190905 379767764 2284368808 18499250 1909224498 6948...
result:
ok 24874 numbers
Subtask #5:
score: 2
Accepted
Dependency #4:
100%
Accepted
Test #5:
score: 2
Accepted
time: 45ms
memory: 15452kb
input:
5 3000000 50000 334361877 965879095 207075537 239932736 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 8...
output:
3673848453 559251800 2009342270 3461528701 1929341620 3496834653 3002476990 2376122424 3738381196 2462970530 1525346467 2640285563 1156000660 1386837368 2586302173 636575398 488872076 2324896199 2771815968 3781490478 2533400653 598581042 4099571584 4138728951 3398617532 1171321386 2425670903 9780667...
result:
ok 24776 numbers
Subtask #6:
score: 2
Accepted
Dependency #5:
100%
Accepted
Test #6:
score: 2
Accepted
time: 89ms
memory: 18180kb
input:
6 4000000 50000 143940291 479066674 946572985 757990370 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 8...
output:
2643615089 2852351074 2786434494 2018450833 1464367054 2201940685 2085923102 1145334734 2403584380 1523096367 2743830954 3979056905 2892776897 4033960188 2579630666 421329427 3661716396 1012385129 3109207296 4274177672 3364947249 2548325159 1608111701 3643699430 2579387519 3710138589 2829110209 2119...
result:
ok 24784 numbers
Subtask #7:
score: 2
Accepted
Dependency #6:
100%
Accepted
Test #7:
score: 2
Accepted
time: 86ms
memory: 22092kb
input:
7 5000000 50000 170605337 16108905 603489614 30282748 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 ...
output:
684159072 4040517752 1766583204 951397149 1877749057 3475288538 1195893887 2466815618 284527847 1318065612 101678367 3801219872 3228500880 819929933 1381710699 108337987 97302099 2335760524 3371344669 1754183206 3635416408 2011669621 2327499447 514398722 391108617 3036014024 4087569415 3702498169 42...
result:
ok 24859 numbers
Subtask #8:
score: 2
Accepted
Dependency #7:
100%
Accepted
Test #8:
score: 2
Accepted
time: 97ms
memory: 27496kb
input:
8 6000000 50000 407856208 997812937 988311967 599148076 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 8...
output:
2537115154 3953542197 3070893246 2990880169 643464066 2570176711 3830742294 1406259191 398760230 3278699892 1561524085 3723611 3748683144 1654471007 700731140 2197399333 146954981 1659930930 1986365403 3103463544 778043699 3047794228 2479253021 2857980455 2867415910 4013732152 2659608137 1781099429 ...
result:
ok 24777 numbers
Subtask #9:
score: 3
Accepted
Dependency #8:
100%
Accepted
Test #9:
score: 3
Accepted
time: 102ms
memory: 29840kb
input:
9 7000000 50000 421526166 576827231 184551971 968568316 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 8...
output:
2939617815 1340060428 3838243095 2718114972 3184968354 3715391358 1789446137 4287347675 1000173437 1784648183 4215454973 1206157927 2817146771 3085405470 2290031162 2312287714 1294358754 1159431221 2705852582 1157968707 242938928 2053251123 1293592583 3246734460 4149798440 749405886 128195368 150914...
result:
ok 24796 numbers
Subtask #10:
score: 2
Accepted
Dependency #3:
100%
Accepted
Test #10:
score: 2
Accepted
time: 70ms
memory: 6456kb
input:
10 1000000 50000 187768199 84880183 500130052 493865631 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 8...
output:
1621199612 2193542798 3060844173 1620491176 2716095874 4256659218 3556700880 3198010043 3285810935 1779764156 479076640 2274087895 3046634036 3330862740 3492706020 1594776590 2568359528 2400189029 2552574291 1648867243 1996251676 2750830939 2564473512 2077601234 2036291855 3599396927 360373422 32860...
result:
ok 24840 numbers
Subtask #11:
score: 2
Accepted
Dependency #4:
100%
Accepted
Dependency #10:
100%
Accepted
Test #11:
score: 2
Accepted
time: 90ms
memory: 10328kb
input:
11 2000000 50000 436320197 98473602 730048106 963707093 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 8...
output:
3977650582 1396692297 30506946 4019860953 1668237179 3626591090 2173922363 3133074884 4167314707 111177399 1428438857 2166228206 3580442744 2941254270 3225576055 842434782 2570199205 3544126312 2556568156 434114775 4233967312 2778695085 928089295 529680013 1726085664 2360581903 677227981 1503345885 ...
result:
ok 24778 numbers
Subtask #12:
score: 2
Accepted
Dependency #5:
100%
Accepted
Dependency #11:
100%
Accepted
Test #12:
score: 2
Accepted
time: 111ms
memory: 14296kb
input:
12 3000000 50000 39579413 877140688 620994427 593376131 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 8...
output:
3851391242 2567010912 292652538 3579750723 1874187398 3147393067 2369299125 1055771304 2376697213 1993548843 3725458313 2949463883 3892039733 2616178110 2812456685 4128288326 177055868 581173256 1287772257 744378215 2421504276 2281243231 2192831671 1217785156 4145917039 168564466 809474340 394943244...
result:
ok 24801 numbers
Subtask #13:
score: 2
Accepted
Dependency #6:
100%
Accepted
Dependency #12:
100%
Accepted
Test #13:
score: 2
Accepted
time: 112ms
memory: 19720kb
input:
13 4000000 50000 806673359 271297329 553775508 874114256 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 ...
output:
744717758 3155255387 2095227311 1433764490 2175247719 3566911422 1416087077 4195507643 3442171485 3891366124 2704129916 2886135705 2675608624 1974010982 2231501006 2752673284 189482778 3366383466 796349108 4162727520 3912354811 793376081 2838164771 2539985592 423799458 1191309199 674185949 209878297...
result:
ok 24825 numbers
Subtask #14:
score: 2
Accepted
Dependency #7:
100%
Accepted
Dependency #13:
100%
Accepted
Test #14:
score: 2
Accepted
time: 127ms
memory: 23600kb
input:
14 5000000 50000 886687831 938908111 481153971 245060857 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 ...
output:
744290898 1031842151 1815925042 1637758630 554816309 4104575523 3661287905 937515273 3018392258 1285864556 3143946731 1810050105 339767900 678336948 777087585 3278503105 2472923175 2214521121 983085348 3311446382 2150057037 2242200264 627198922 1314836686 3650659169 2382981962 181301185 1738472728 2...
result:
ok 24804 numbers
Subtask #15:
score: 2
Accepted
Dependency #8:
100%
Accepted
Dependency #14:
100%
Accepted
Test #15:
score: 2
Accepted
time: 171ms
memory: 27420kb
input:
15 6000000 50000 955510995 922692911 386900322 265775530 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 ...
output:
561732782 2691714820 1976381508 4194697311 3717871564 733220329 2343358032 231891025 1123158055 1894791464 335399226 2805790980 609504677 4153010218 3538141216 2790172708 2865266868 522664355 537117203 2198406197 3858017333 1446998002 314902783 2399853369 2968240464 3402482549 1009296854 3290217610 ...
result:
ok 24819 numbers
Subtask #16:
score: 3
Accepted
Dependency #9:
100%
Accepted
Dependency #15:
100%
Accepted
Test #16:
score: 3
Accepted
time: 175ms
memory: 31916kb
input:
16 7000000 50000 783944699 196739524 363991614 529128410 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 ...
output:
3155229082 1894901593 2764556448 3318817980 469332505 3901473386 683391889 3946005590 2636270819 2157618069 446372264 4185333564 649627953 2897691873 1606924687 3975929871 2926322943 267734983 2092007451 1023068443 1598851227 1102970953 2844384756 2545198697 1290613825 1239464832 1175653747 30485567...
result:
ok 24812 numbers
Subtask #17:
score: 2
Accepted
Dependency #3:
100%
Accepted
Test #17:
score: 2
Accepted
time: 109ms
memory: 14412kb
input:
17 1000000 50000 344885619 157351803 423724603 867011818 1 1 3 2 5 4 6 7 9 10 8 12 13 11 15 14 17 16 19 18 21 20 22 23 24 25 26 27 29 30 31 32 33 34 28 35 37 38 36 40 41 39 43 44 45 46 47 42 49 50 48 51 52 54 53 55 57 58 56 60 61 62 63 64 59 66 65 68 69 70 71 67 72 74 75 76 73 77 78 79 81 80 83 82 8...
output:
2569119407 883513151 934930167 2149348282 3680802609 4001371156 514744714 3097045242 3373153562 1306671438 4227043267 1911692822 1439512698 115808554 4238694283 3275953284 4033617960 2269225136 4261586187 1212226048 144308090 1194692514 3115203170 3875730576 2388326413 4086722616 3155059562 24229450...
result:
ok 50000 numbers
Subtask #18:
score: 2
Accepted
Dependency #17:
100%
Accepted
Test #18:
score: 2
Accepted
time: 171ms
memory: 21832kb
input:
18 2000000 50000 809325756 95726186 947952353 292642116 1 2 3 4 5 1 6 8 7 9 11 10 12 13 14 15 17 18 16 20 21 22 23 19 24 26 25 27 28 30 31 29 33 34 32 35 37 38 39 40 36 41 43 42 45 44 46 48 49 47 50 52 53 54 51 56 57 55 59 60 61 62 58 64 65 66 67 68 63 69 70 72 73 74 75 71 76 78 77 80 79 81 82 84 85...
output:
3959669303 1217499215 2080489516 4022370126 3456818529 10491282 2303536177 2184141943 917532443 524845828 2179527626 1097600562 2000786812 3885849526 3424457503 2962120474 3415990178 1048619646 1126866292 3060086420 314124076 2453709761 1594008221 36974265 1118142077 952802758 1836773874 1256940180 ...
result:
ok 50000 numbers
Subtask #19:
score: 2
Accepted
Dependency #18:
100%
Accepted
Test #19:
score: 2
Accepted
time: 239ms
memory: 31492kb
input:
19 3000000 50000 412704184 89078021 169106409 967668419 1 1 2 4 3 6 5 7 8 10 9 12 13 11 15 16 14 18 17 20 19 22 21 23 25 24 27 28 29 26 30 31 33 34 35 36 32 37 38 39 41 42 43 44 45 46 40 48 47 50 51 49 53 54 55 56 57 52 58 59 60 61 63 62 65 66 67 68 69 70 64 71 72 74 73 76 75 77 79 80 81 82 83 78 85...
output:
362015420 2117674654 2586741755 4093802506 2347793219 2320535287 34939730 1363368547 1213931226 3742836238 3189931161 925522041 203389623 2416526596 1825092194 912818682 3679252561 1964627709 2876324838 2813409467 2084601926 4028496305 950151182 4135028924 2910923351 282361499 2148768873 2455650932 ...
result:
ok 50000 numbers
Subtask #20:
score: 2
Accepted
Dependency #19:
100%
Accepted
Test #20:
score: 2
Accepted
time: 308ms
memory: 41124kb
input:
20 4000000 50000 430794970 573363875 35958065 240098457 1 1 3 2 4 5 7 6 8 9 11 12 13 14 10 16 15 18 17 20 21 19 22 23 25 26 24 28 29 27 30 32 31 33 35 36 37 38 34 40 39 41 42 44 43 45 46 48 49 50 51 52 53 47 54 55 57 58 59 56 61 60 63 64 65 66 62 67 68 69 71 72 73 70 75 76 74 78 77 80 81 79 83 82 85...
output:
2850881824 922611492 4064171237 1975469431 2434894203 2382030758 1875349674 3752333556 1878949193 2708609242 2692663668 2211903711 27196320 1475676219 744525998 3446660955 213051572 3365507634 3841866579 368903566 2065813962 1413199035 501299105 533061357 741778278 1307388637 714108390 1714781900 33...
result:
ok 50000 numbers
Subtask #21:
score: 2
Accepted
Dependency #20:
100%
Accepted
Test #21:
score: 2
Accepted
time: 391ms
memory: 50784kb
input:
21 5000000 50000 431878685 643629538 705149833 954331612 1 1 2 4 5 3 7 6 8 9 11 12 13 14 10 16 15 18 17 19 21 22 20 23 25 26 24 28 27 29 30 31 32 33 35 34 37 36 39 40 41 38 43 42 45 44 47 48 49 46 51 50 53 52 54 55 56 58 59 60 57 62 61 64 65 66 67 63 69 68 71 70 72 73 75 76 74 77 79 80 81 82 83 78 8...
output:
1384159646 1270021841 268103987 801775577 670044003 326317722 2622632941 1766544299 4203419947 267944817 2047601387 3095552282 177301669 2754894941 769062914 3443251748 827276649 300816650 3436978028 1181580310 2252639874 827276649 2398318016 2504167031 1328235576 1302734504 3242392065 3349539059 17...
result:
ok 50000 numbers
Subtask #22:
score: 2
Accepted
Dependency #21:
100%
Accepted
Test #22:
score: 2
Accepted
time: 497ms
memory: 60344kb
input:
22 6000000 50000 889827958 457937339 729095819 484841029 1 1 3 2 4 5 6 7 9 8 11 12 13 14 15 10 17 18 16 19 20 22 21 23 24 26 25 28 29 30 27 31 32 34 33 36 37 35 39 40 41 42 38 43 45 44 47 46 48 49 51 52 53 54 50 55 57 58 56 60 61 59 63 62 64 65 66 67 69 68 70 72 71 74 75 73 76 77 78 79 81 80 82 83 8...
output:
1582129847 3736848145 1384267535 1924966451 3923700066 3586062562 2008400913 3212552276 2307402938 3449581690 3269280436 4056435084 3460521545 627217702 2216404864 3517044360 1667873386 2643629967 3510908067 2767900621 3913185405 565919868 2469343923 2737307861 1322126995 2756148703 338471328 183519...
result:
ok 50000 numbers
Subtask #23:
score: 3
Accepted
Dependency #22:
100%
Accepted
Test #23:
score: 3
Accepted
time: 1087ms
memory: 63380kb
input:
23 7000000 50000 211230969 678327211 168451044 789531586 1 2 1 3 5 4 6 7 9 8 11 12 13 10 15 16 17 14 18 19 21 20 22 24 23 26 25 28 27 30 29 31 33 32 35 34 37 36 38 39 40 42 43 44 45 46 47 41 49 48 50 51 53 52 54 55 57 58 56 59 61 60 63 62 65 64 67 66 69 68 70 71 72 74 75 73 77 78 76 79 80 82 83 81 8...
output:
1782561604 494157074 2433560342 2189544288 2437294722 678240822 2098027584 3499795072 1905863094 2266605928 3876532706 4179338318 111203610 420916754 2559452090 627347880 3193919800 2006843390 324474418 2622378262 1030718478 2150586536 1317994444 2603240740 847368218 3350647284 2717086610 2926971586...
result:
ok 50000 numbers
Subtask #24:
score: 2
Accepted
Dependency #3:
100%
Accepted
Test #24:
score: 2
Accepted
time: 90ms
memory: 12868kb
input:
24 1000000 50000 442711235 109861120 440513324 426209512 1 2 1 3 4 6 5 7 9 8 11 10 13 12 15 16 17 14 18 20 19 22 21 23 25 26 27 28 24 29 31 32 30 34 33 36 37 35 39 38 41 42 43 44 45 40 47 48 46 50 51 49 52 54 55 56 57 53 59 60 61 58 63 64 65 66 67 62 68 69 70 71 72 73 74 76 77 75 79 78 80 81 82 84 8...
output:
560401238 1236946722 20007591 4092952301 1143368468 2039225741 1899254369 1143368468 1879858296 2956147056 3324512208 1539915760 831473350 3095613338 831473350 2752264506 3522387586 2956147056 1219465756 1768033396 2070474880 1143368468 1201960582 1428433142 3097813946 3079499227 3860593956 75974031...
result:
ok 24776 numbers
Subtask #25:
score: 2
Accepted
Dependency #4:
100%
Accepted
Dependency #24:
100%
Accepted
Test #25:
score: 2
Accepted
time: 166ms
memory: 22952kb
input:
25 2000000 50000 387088618 188756179 657093050 243941127 1 1 2 4 5 3 6 8 7 9 11 12 10 13 15 16 14 17 19 18 20 21 23 22 24 26 27 28 25 30 31 29 33 32 35 34 37 38 36 40 39 41 42 43 44 45 46 48 47 49 50 51 53 52 55 56 57 58 54 59 61 60 62 63 64 65 67 68 66 69 71 72 70 74 75 76 77 73 79 80 78 82 83 81 8...
output:
3355837389 3925708580 684020826 2243950359 210424777 2797839293 1459655476 291212200 3128830922 533130358 3280840300 1567111768 2981204620 416705169 1657413536 3593299665 851392001 3639206124 1894574248 1076918575 251128149 570444835 2019951198 20128476 921946027 3019042077 1336570077 359306379 2956...
result:
ok 24788 numbers
Subtask #26:
score: 2
Accepted
Dependency #5:
100%
Accepted
Dependency #25:
100%
Accepted
Test #26:
score: 2
Accepted
time: 220ms
memory: 31464kb
input:
26 3000000 50000 324489887 692800739 83884687 246855408 1 2 3 1 5 4 6 7 9 8 10 11 13 12 14 16 15 17 18 19 21 20 22 24 23 25 27 28 26 29 31 32 30 33 34 35 37 36 38 39 40 42 43 41 44 45 46 48 49 47 51 50 52 54 55 53 56 58 59 60 61 62 57 63 64 65 67 66 68 69 71 72 73 74 70 75 76 77 79 80 78 82 83 84 81...
output:
3643049024 3755666270 3084562225 2238977676 3825837927 3561268122 2517955200 404215675 750299347 3076699 119437702 340582456 2250148296 3453504248 4034761367 4179477097 1753692050 3042474256 2973131643 2754200681 1915029253 88009898 701510927 3550701541 4013863675 1720935663 3636824577 287357384 256...
result:
ok 24830 numbers
Subtask #27:
score: 2
Accepted
Dependency #6:
100%
Accepted
Dependency #26:
100%
Accepted
Test #27:
score: 2
Accepted
time: 300ms
memory: 41128kb
input:
27 4000000 50000 20451612 362836145 354925769 248015047 1 1 2 4 5 3 7 6 9 10 11 12 8 13 15 14 17 16 18 20 21 22 19 24 23 25 26 27 28 30 31 29 32 34 35 36 37 38 39 33 40 42 41 43 44 45 46 48 47 50 51 52 53 49 55 54 56 58 59 57 60 62 61 63 65 66 67 68 64 69 70 72 73 71 75 76 74 78 79 80 81 82 77 84 83...
output:
3859873409 656165467 655668526 1345173803 635980829 1461479792 3788133859 2494807437 178811753 2417224062 2579109187 666997151 1100728310 444087665 3997367424 3991378332 4048833616 4096134845 3325286051 1888203793 1583205633 3966816922 2100035719 331561925 4282397343 2993126973 3711712894 767730647 ...
result:
ok 24787 numbers
Subtask #28:
score: 2
Accepted
Dependency #7:
100%
Accepted
Dependency #27:
100%
Accepted
Test #28:
score: 2
Accepted
time: 363ms
memory: 50784kb
input:
28 5000000 50000 456981497 836268154 763851659 870347750 1 2 3 1 4 5 7 8 6 9 11 12 10 14 13 15 17 16 19 18 21 22 20 24 25 26 27 28 23 30 31 32 33 29 35 36 37 34 38 39 41 40 43 44 45 42 46 47 49 48 51 50 52 53 55 54 57 56 58 59 61 60 62 63 64 66 67 65 68 69 71 70 73 74 75 76 77 72 78 80 79 82 83 81 8...
output:
2267759336 1164697584 2145338415 3705531346 1184379183 1164780767 3769674262 212520205 525002259 3472542929 2815450408 3543863416 3875573228 2719430852 877677391 3952829728 2887961009 392548790 1002943345 498946815 2630506579 605427827 3519351299 1896784806 1541059437 1658796893 2603119767 60962130 ...
result:
ok 24785 numbers
Subtask #29:
score: 2
Accepted
Dependency #8:
100%
Accepted
Dependency #28:
100%
Accepted
Test #29:
score: 2
Accepted
time: 417ms
memory: 60436kb
input:
29 6000000 50000 877213149 982259187 430825672 772424447 1 1 3 4 5 2 6 7 9 8 10 11 12 14 15 16 17 13 18 19 20 21 22 23 24 25 27 26 29 30 31 28 33 32 34 35 36 38 39 37 40 41 43 42 45 44 46 48 49 47 50 51 53 52 55 56 57 54 58 60 59 61 63 62 65 64 67 68 66 70 71 72 73 74 69 76 75 78 79 77 80 82 81 84 8...
output:
3428470520 342693470 2150229530 528279368 1325206604 886246882 246132840 16489426 2453052532 1425451865 760133492 3658731564 3826875332 3627418506 2855128646 3917447485 3124931892 1405000397 3600631033 2092640190 933274670 4044108273 2770892012 168069263 1201626159 2090752909 2902437122 2399827993 1...
result:
ok 24778 numbers
Subtask #30:
score: 3
Accepted
Dependency #9:
100%
Accepted
Dependency #29:
100%
Accepted
Test #30:
score: 3
Accepted
time: 940ms
memory: 62672kb
input:
30 7000000 50000 331682705 33871490 659118837 758690582 1 2 1 3 5 6 7 8 4 10 9 12 11 14 15 13 16 18 17 19 20 22 21 23 25 24 27 26 28 30 29 31 33 34 32 35 36 37 39 40 38 42 41 43 45 44 47 46 49 48 51 50 53 54 55 56 52 58 59 60 61 62 63 64 65 66 67 68 57 70 71 72 73 74 69 76 75 78 77 80 81 79 83 82 85...
output:
1202290766 2739954750 2151769065 2272329581 2383618429 2039507986 270875974 2507544226 2543685788 162567455 3427015343 98100935 2674436092 3811851221 3875968586 1110343090 3201180884 1115985236 3841005588 3811851221 4292413407 3508012711 1246991415 2984760635 1558048699 305821220 1705539995 13544853...
result:
ok 24869 numbers
Subtask #31:
score: 2
Accepted
Test #31:
score: 2
Accepted
time: 124ms
memory: 12588kb
input:
31 1000000 50000 180551098 612777692 293437064 961524410 1 1 2 4 5 6 3 7 9 8 10 12 13 11 15 16 17 14 19 20 18 21 22 24 25 23 26 28 29 30 27 32 31 34 33 36 37 38 39 40 41 42 35 43 44 45 47 48 49 50 51 52 53 46 54 56 57 58 55 59 61 60 63 64 65 62 66 67 69 68 70 71 73 72 75 74 76 77 79 78 80 81 83 84 8...
output:
3740414568 3740414568 3740414568 3740414568 3740414568 3776553682 364670674 564216005 3740414568 564216005 3740414568 1926698803 564216005 3740414568 3740414568 3740414568 3740414568 3360498489 3740414568 2300291340 1681459153 3740414568 3740414568 3740414568 1804307856 3740414568 3740414568 3740414...
result:
ok 24781 numbers
Subtask #32:
score: 2
Accepted
Dependency #31:
100%
Accepted
Test #32:
score: 2
Accepted
time: 183ms
memory: 21836kb
input:
32 2000000 50000 935850251 346739824 386103864 247997775 1 2 3 1 4 5 6 7 9 10 11 8 13 12 15 14 17 16 18 20 19 21 22 23 24 25 26 27 28 29 31 32 30 34 35 33 37 38 39 36 41 40 42 43 44 45 47 48 46 49 51 52 50 54 55 56 57 58 59 60 53 61 63 62 65 64 67 66 69 70 68 72 73 74 71 75 77 78 79 80 81 76 83 84 8...
output:
889304539 889304539 889304539 1874976614 889304539 1874976614 889304539 889304539 2753807028 889304539 889304539 889304539 889304539 889304539 889304539 1875332669 3167815795 1260473620 889304539 4204776618 889304539 280622348 3309447323 889304539 3628671525 889304539 889304539 889304539 889304539 4...
result:
ok 24769 numbers
Subtask #33:
score: 2
Accepted
Dependency #32:
100%
Accepted
Test #33:
score: 2
Accepted
time: 258ms
memory: 31488kb
input:
33 3000000 50000 202724492 600217403 656526512 968117055 1 2 1 3 4 5 6 7 9 8 11 10 13 12 14 16 17 15 18 19 21 22 23 20 24 26 25 27 29 30 28 32 31 34 33 35 36 38 37 39 40 42 41 44 43 46 45 48 47 50 51 52 49 54 53 55 57 58 56 59 60 62 61 63 65 66 67 64 69 68 71 70 73 72 74 76 77 78 75 79 80 81 83 82 8...
output:
1018420505 2290727649 654460513 2668157391 1263743393 572005191 1032710337 304611097 2878076097 2556345263 119001680 2164902769 3788481057 1921041121 2597889238 1436674052 1005810449 2290547777 2953305085 1944893863 1220778000 2070104823 2156585845 1412267255 1261789671 3199443225 2083614255 2160146...
result:
ok 24873 numbers
Subtask #34:
score: 2
Accepted
Dependency #33:
100%
Accepted
Test #34:
score: 2
Accepted
time: 328ms
memory: 41108kb
input:
34 4000000 50000 276354216 121238822 205228591 12495160 1 1 2 4 5 3 6 7 9 8 11 12 13 10 14 16 15 17 19 20 18 22 23 24 21 26 27 28 29 30 25 32 31 33 35 36 37 38 39 40 41 34 42 43 44 46 45 47 48 49 50 52 51 53 54 55 57 56 59 60 61 58 62 64 63 66 65 67 68 70 69 72 73 71 74 76 77 78 75 80 81 82 83 79 84...
output:
367619829 367619829 1927769482 367619829 367619829 367619829 367619829 1927769482 367619829 367619829 2146425617 2598094920 367619829 367619829 367619829 367619829 367619829 367619829 367619829 1762983983 1274250788 367619829 367619829 367619829 367619829 2261805717 2404900489 367619829 3637572258 3...
result:
ok 24781 numbers
Subtask #35:
score: 2
Accepted
Dependency #34:
100%
Accepted
Test #35:
score: 2
Accepted
time: 397ms
memory: 50796kb
input:
35 5000000 50000 192084661 69983011 106828851 598264850 1 2 3 1 5 6 7 4 9 10 8 11 13 14 15 12 17 18 16 20 19 22 21 23 24 26 27 25 29 28 30 31 33 32 34 36 35 37 39 38 41 40 43 42 45 44 47 46 48 49 50 52 53 51 54 55 57 58 59 56 60 62 63 64 65 66 61 67 69 68 70 71 73 74 72 76 77 75 79 78 80 81 82 83 84...
output:
1812809232 1346858751 3803033186 3402172200 4277284642 3097308629 3316792991 3886598861 627714871 958337661 1086901821 2201869245 2506048191 913476862 2485474487 221707149 3365511239 685857620 3821066724 3883144946 492451105 917011133 614591075 3229274220 2770957949 1585894987 1388744493 1664303924 ...
result:
ok 24775 numbers
Subtask #36:
score: 2
Accepted
Dependency #35:
100%
Accepted
Test #36:
score: 2
Accepted
time: 498ms
memory: 60748kb
input:
36 6000000 50000 100452010 396137390 217995543 660370051 1 1 3 4 2 5 6 7 8 10 11 12 13 14 9 15 16 18 17 19 20 22 23 21 25 24 26 27 29 28 30 31 33 34 35 32 36 38 37 40 41 42 39 44 45 46 43 47 48 50 51 49 52 53 54 55 56 57 59 60 61 58 62 64 65 66 67 63 68 70 71 69 72 73 74 76 77 75 78 80 81 79 82 84 8...
output:
2090778411 2090778411 2740166256 2090778411 2090778411 2090778411 2090778411 3827358983 4233144887 3377398523 2968840859 2090778411 233819348 2090778411 681933881 2090778411 2090778411 2541193594 1740566405 2090778411 1623311955 2090778411 2946064861 3624121576 2090778411 2584029134 2090778411 20907...
result:
ok 24763 numbers
Subtask #37:
score: 3
Accepted
Dependency #36:
100%
Accepted
Test #37:
score: 3
Accepted
time: 1043ms
memory: 62680kb
input:
37 7000000 50000 955057831 135040450 414228408 947927370 1 2 1 3 5 4 6 7 9 10 11 12 8 13 15 16 14 18 19 20 17 22 23 24 25 21 27 26 28 30 31 29 33 32 35 34 36 38 39 40 37 42 41 44 45 43 47 46 49 50 48 51 53 52 55 54 56 57 58 59 60 62 63 61 64 65 67 68 69 66 70 72 73 71 75 76 77 74 78 80 79 81 82 83 8...
output:
2973659272 2973659272 2973659272 2973659272 2973659272 2973659272 2993383444 2973659272 3439931476 2973659272 2973659272 2973659272 4123861643 2973659272 2973659272 265212588 2973659272 2973659272 2973659272 2973659272 2973659272 1023282335 2973659272 2973659272 2973659272 2973659272 1023282335 2973...
result:
ok 24804 numbers
Subtask #38:
score: 3
Accepted
Dependency #1:
100%
Accepted
Dependency #10:
100%
Accepted
Dependency #17:
100%
Accepted
Dependency #24:
100%
Accepted
Dependency #31:
100%
Accepted
Test #38:
score: 3
Accepted
time: 141ms
memory: 14380kb
input:
38 1000000 50000 947283053 693813685 443610370 957051502 1 2 3 1 5 6 7 8 9 10 4 12 13 11 14 15 17 16 18 20 21 22 23 19 25 26 24 27 28 29 31 32 30 33 35 34 36 37 39 40 38 42 41 44 43 46 45 48 47 50 51 52 53 49 54 56 55 58 57 60 59 61 63 62 64 65 67 66 69 70 71 68 73 74 75 72 76 77 79 78 80 82 81 84 8...
output:
3169641655 3228255929 1414141240 4230557183 710258305 635165018 3733972107 558683821 3215588648 1642822913 528812923 3272698396 3668203736 208974362 1486781432 3399822403 3794113723 2875237383 189848422 520805225 1784142246 3965382905 1676891460 2237537324 3450958738 2534863212 3536887419 3420778615...
result:
ok 24826 numbers
Subtask #39:
score: 3
Accepted
Dependency #11:
100%
Accepted
Dependency #18:
100%
Accepted
Dependency #25:
100%
Accepted
Dependency #32:
100%
Accepted
Dependency #38:
100%
Accepted
Test #39:
score: 3
Accepted
time: 213ms
memory: 23068kb
input:
39 2000000 50000 229384005 31702400 876745994 965256124 1 1 2 3 4 5 7 8 9 10 6 11 13 14 15 16 17 18 19 20 12 21 23 24 22 26 25 28 29 30 31 27 32 34 33 36 35 37 39 40 41 38 43 42 44 45 46 47 49 50 48 51 53 54 55 56 57 58 52 59 61 60 62 63 64 65 67 66 69 70 71 72 68 74 73 75 77 78 76 79 81 80 82 84 85...
output:
681771192 673661914 620142086 2409623126 1956406050 3377028794 3539000444 4043559176 1072609797 2174625827 2905426220 268625867 3190070986 2287023840 626532035 3051136910 639348762 4017203623 348488444 1230862830 4234730970 3128753384 246535758 1629537260 949547192 2438541012 1737109119 1140047960 3...
result:
ok 24806 numbers
Subtask #40:
score: 3
Accepted
Dependency #12:
100%
Accepted
Dependency #19:
100%
Accepted
Dependency #26:
100%
Accepted
Dependency #33:
100%
Accepted
Dependency #39:
100%
Accepted
Test #40:
score: 3
Accepted
time: 275ms
memory: 31456kb
input:
40 3000000 50000 273431495 120269032 973571869 541959441 1 1 2 4 5 3 7 8 9 10 11 6 12 14 13 16 15 18 19 20 21 17 22 23 25 26 24 28 27 30 29 31 33 32 34 36 37 35 39 40 38 41 43 42 45 46 47 44 48 49 51 50 53 54 52 56 55 57 59 58 61 60 63 64 62 66 65 67 69 70 68 71 72 73 75 76 77 74 79 78 80 82 81 84 8...
output:
139672138 2017234889 2242486752 1158677613 3734764795 2922456229 995723331 99573058 3903416359 2662357104 427047972 2188504907 2106234819 3925983861 3374435419 132855962 2563911128 2009292045 2324545434 3408186515 3954452808 4056860697 160033643 2845428939 2345616845 1487755950 1028304746 295251926 ...
result:
ok 24852 numbers
Subtask #41:
score: 3
Accepted
Dependency #13:
100%
Accepted
Dependency #20:
100%
Accepted
Dependency #27:
100%
Accepted
Dependency #34:
100%
Accepted
Dependency #40:
100%
Accepted
Test #41:
score: 3
Accepted
time: 351ms
memory: 41140kb
input:
41 4000000 50000 800954003 55778929 415291959 223405771 1 1 3 2 5 6 4 8 7 10 9 12 13 14 11 16 15 17 19 18 21 20 22 24 25 23 26 27 29 28 31 30 33 32 34 36 35 37 38 40 41 42 43 39 44 46 45 47 49 48 50 51 52 53 55 56 54 58 59 60 61 57 62 64 63 65 66 68 69 67 71 72 70 73 75 76 77 78 74 79 81 80 83 82 84...
output:
3108265271 3085277534 2021222205 1435682343 462475405 521861581 4093657387 1232126971 3604212220 682448768 1057276573 2533637089 3339926973 4127495107 562417117 446524942 3014154986 3466415634 2704005790 2485479086 538321161 1440427488 1382666937 3360279392 1876791179 2501826311 3039377670 232801186...
result:
ok 24766 numbers
Subtask #42:
score: 3
Accepted
Dependency #14:
100%
Accepted
Dependency #21:
100%
Accepted
Dependency #28:
100%
Accepted
Dependency #35:
100%
Accepted
Dependency #41:
100%
Accepted
Test #42:
score: 3
Accepted
time: 452ms
memory: 50788kb
input:
42 5000000 50000 115059162 231212044 581432201 14616195 1 2 3 4 5 1 6 7 8 9 10 11 13 12 14 15 16 18 19 20 17 22 23 21 25 24 26 27 29 28 31 32 33 34 35 30 36 38 37 39 40 42 41 44 43 45 46 48 47 49 50 52 51 53 55 56 57 54 59 58 60 62 63 61 64 66 65 67 69 70 71 68 73 74 72 75 77 76 79 78 81 82 83 80 84...
output:
2044285070 3218691525 3494508482 3494508482 2098304935 2098304935 2343483144 1605059882 4106664882 1115784228 471925755 2127133509 1056734147 3042804794 1389697035 856785720 249459661 3852125559 3333003951 3434256099 3395709689 3780974008 92356366 1228869536 4155738756 3687545041 158162073 188963676...
result:
ok 24777 numbers
Subtask #43:
score: 3
Accepted
Dependency #15:
100%
Accepted
Dependency #22:
100%
Accepted
Dependency #29:
100%
Accepted
Dependency #36:
100%
Accepted
Dependency #42:
100%
Accepted
Test #43:
score: 3
Accepted
time: 487ms
memory: 61696kb
input:
43 6000000 50000 46358511 159083658 189665712 860930428 1 2 3 1 5 6 4 8 9 7 11 12 13 10 14 16 15 18 17 19 20 22 21 23 25 26 24 28 27 30 31 29 32 33 34 35 37 38 39 40 36 42 43 41 44 45 47 48 46 49 50 52 53 51 54 55 56 58 57 59 60 61 63 62 65 66 67 64 69 68 70 71 73 72 75 74 77 76 79 80 81 78 82 83 85...
output:
1549768984 3705891661 289136725 4011243849 345070539 3234083285 2250969930 3195895415 4078073451 1732136190 1237253485 3280705078 302270861 2813255669 370058753 2554523040 2743103117 261753034 2017618664 1023085797 4223425819 1057181722 2007400993 1724539375 2607575843 3969787131 114764070 268854072...
result:
ok 24796 numbers
Subtask #44:
score: 3
Accepted
Dependency #2:
100%
Accepted
Dependency #16:
100%
Accepted
Dependency #23:
100%
Accepted
Dependency #30:
100%
Accepted
Dependency #37:
100%
Accepted
Dependency #43:
100%
Accepted
Test #44:
score: 3
Accepted
time: 1165ms
memory: 63548kb
input:
44 7000000 50000 870174372 966015416 410590157 119969191 1 2 3 4 1 6 5 8 9 7 10 12 11 14 13 16 17 18 19 20 15 21 22 24 23 26 27 28 29 25 30 32 31 33 34 35 37 38 39 40 36 42 41 44 45 43 46 48 49 50 47 52 53 54 51 55 57 56 59 60 61 62 58 63 64 66 65 67 69 70 71 72 68 73 74 76 75 77 78 80 81 82 79 83 8...
output:
990891018 3903302946 1775878248 2482087706 2527716231 1931243499 3663406112 1091213954 3692097541 2301419235 3832273446 548084093 1243077015 2927864947 530446523 1238837767 4157580805 2024296666 15928662 1548166956 1583559638 1191230836 3151586538 3737923911 4001509858 487461087 4221986447 128494029...
result:
ok 24780 numbers