QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#294324 | #5186. 本质不同逆序对 | NOI_AK_ME | AC ✓ | 960ms | 46988kb | C++23 | 6.9kb | 2023-12-30 12:08:02 | 2023-12-30 12:08:03 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
namespace io {
const int SIZE = (1 << 18) + 1;
char ibuf[SIZE], *iS, *iT, obuf[SIZE], *oS = obuf, *oT = oS + SIZE - 1;
#define getchar() (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, SIZE, stdin), (iS == iT ? EOF : *iS++)) : *iS++)
inline void flush() {
fwrite(obuf, 1, oS - obuf, stdout);
oS = obuf;
}
inline void putchar(char x) {
*oS++ = x;
if (oS == oT)
flush();
}
template <class Int>
inline void in(Int &n) {
Int X = 0;
char ch = 0;
bool sign = 0;
while (!isdigit(ch))
sign |= ch == '-', ch = getchar();
while (isdigit(ch))
X = (X << 3) + (X << 1) + (ch ^ 48), ch = getchar();
n = (sign ? -X : X);
}
template <class Int, class... Args>
inline void in(Int &head, Args &...args) {
in(head), in(args...);
}
template <class Int>
inline void out(Int n) {
static unsigned char stack[100], top = 0;
if (n < 0)
putchar('-'), n = -n;
if (!n)
putchar('0');
while (n)
stack[++top] = n % 10 + '0', n /= 10;
while (top)
putchar(stack[top--]);
}
inline void out(const char *s) {
while (*s)
putchar(*s++);
}
struct Flusher {
~Flusher() {
flush();
}
} flusher;
} // namespace io
using io::in;
using io::out;
using io::putchar;
#define space putchar(' ')
#define enter putchar('\n')
typedef long long LL;
constexpr int maxn = 100010, maxm = 500010, maxb1 = 330, maxb2 = 20;
struct QUES {
int l, r, id, bel;
LL ans;
inline bool operator<(const QUES &q) {
return bel != q.bel ? bel < q.bel : bel & 1 ? r < q.r : r > q.r;
}
} Q[maxm];
vector<tuple<int, int, int>> v1[maxn], v2[maxn];
LL ANS[maxm];
int n, m, len, B, B1, B2, Num1, Num2;
int a[maxn], belong1[maxn], belong2[maxn], End1[maxb1], EndB[maxb2];
int last[maxn], pre[maxn], suc[maxn];
int tmp[maxn], val[maxn], id[maxn];
int sum1[maxb2][maxb2], sum2[maxb1][maxb2], sum3[maxb2][maxb1], sum4[maxb1][maxb1], sum5[maxn];
inline void insert(int x) {
const int y = val[x], xBEL1 = belong1[x], xBEL2 = belong2[x], yBEL1 = belong1[y], yBEL2 = belong2[y];
for (int i = xBEL2 + 1; i <= Num2; i++)
for (int j = yBEL2 + 1; j <= Num2; j++)
sum1[i][j]++;
for (int i = xBEL1 + 1; i <= EndB[xBEL2]; i++)
for (int j = yBEL2 + 1; j <= Num2; j++)
sum2[i][j]++;
for (int i = xBEL2 + 1; i <= Num2; i++)
for (int j = yBEL1 + 1; j <= EndB[yBEL2]; j++)
sum3[i][j]++;
for (int i = xBEL1 + 1; i <= EndB[xBEL2]; i++)
for (int j = yBEL1 + 1; j <= EndB[yBEL2]; j++)
sum4[i][j]++;
for (int i = x + 1; i <= End1[xBEL1]; i++)
(val[i] > y) && sum5[i]++;
for (int i = y + 1; i <= End1[yBEL1]; i++)
(id[i] > End1[xBEL1]) && sum5[id[i]]++;
}
inline void erase(int x) {
const int y = val[x], xBEL1 = belong1[x], xBEL2 = belong2[x], yBEL1 = belong1[y], yBEL2 = belong2[y];
for (int i = xBEL2 + 1; i <= Num2; i++)
for (int j = yBEL2 + 1; j <= Num2; j++)
sum1[i][j]--;
for (int i = xBEL1 + 1; i <= EndB[xBEL2]; i++)
for (int j = yBEL2 + 1; j <= Num2; j++)
sum2[i][j]--;
for (int i = xBEL2 + 1; i <= Num2; i++)
for (int j = yBEL1 + 1; j <= EndB[yBEL2]; j++)
sum3[i][j]--;
for (int i = xBEL1 + 1; i <= EndB[xBEL2]; i++)
for (int j = yBEL1 + 1; j <= EndB[yBEL2]; j++)
sum4[i][j]--;
for (int i = x + 1; i <= End1[xBEL1]; i++)
(val[i] > y) && sum5[i]--;
for (int i = y + 1; i <= End1[yBEL1]; i++)
(id[i] > End1[xBEL1]) && sum5[id[i]]--;
}
inline int query(int x) {
const int y = val[x], xBEL1 = belong1[x], xBEL2 = belong2[x], yBEL1 = belong1[y], yBEL2 = belong2[y];
return sum1[xBEL2][yBEL2] + sum2[xBEL1][yBEL2] + sum3[xBEL2][yBEL1] + sum4[xBEL1][yBEL1] + sum5[x];
}
inline void solve1() {
for (int i = 1; i <= n; i++)
tmp[a[i]]++;
for (int i = 1; i <= n; i++)
tmp[i] += tmp[i - 1];
for (int i = 1; i <= n; i++)
id[val[i] = tmp[a[i]]--] = i;
long long sum;
for (int i = n, L, R, ID; i; i--) {
suc[i] &&(erase(suc[i]), 0);
insert(i);
for (auto &it : v1[i]) {
tie(L, R, ID) = it, sum = 0;
for (int j = L; j <= R; j++)
sum += query(j) - (pre[j] > i ? query(pre[j]) : 0);
ID > 0 ? Q[ID].ans += sum : Q[-ID].ans -= sum;
}
}
}
inline void solve2() {
memset(tmp, 0, sizeof(tmp)), memset(sum1, 0, sizeof(sum1)), memset(sum2, 0, sizeof(sum2)),
memset(sum3, 0, sizeof(sum3)), memset(sum4, 0, sizeof(sum4)), memset(sum5, 0, sizeof(sum5));
for (int i = 1; i <= n; i++)
tmp[a[i]]++;
for (int i = 1; i <= n; i++)
tmp[i] += tmp[i - 1];
for (int i = 1; i <= n; i++)
id[val[i] = tmp[a[i]]--] = i;
#define R_ n + 1 -
long long sum;
for (int i = 1, L, R, ID; i <= n; i++) {
pre[i] &&(erase(R_ pre[i]), 0);
insert(R_ i);
for (auto &it : v2[i]) {
tie(L, R, ID) = it, sum = 0;
for (int j = L; j <= R; j++)
sum += query(R_ j) - (suc[j] && suc[j] < i ? query(R_ suc[j]) : 0);
ID > 0 ? Q[ID].ans += sum : Q[-ID].ans -= sum;
}
}
}
int main() {
in(n), B = __builtin_pow(n, 0.25) + 1, B1 = B * B, B2 = B1 * B;
for (int i = 1; i <= n; i++)
in(a[i]), a[i] = R_ a[i], belong1[i] = (i - 1) / B1 + 1, belong2[i] = (i - 1) / B2 + 1, //
pre[i] = last[a[i]], last[a[i]] = i;
memset(last, 0, sizeof(last));
for (int i = n; i; i--)
suc[i] = last[a[i]], last[a[i]] = i;
Num1 = belong1[n], Num2 = belong2[n];
for (int i = 1; i <= Num1; i++)
End1[i] = i == Num1 ? n : i * B1;
for (int i = 1; i <= Num2; i++)
EndB[i] = i == Num2 ? Num1 : i * B;
in(m), len = n / __builtin_sqrt(m);
for (int i = 1; i <= m; i++)
in(Q[i].l, Q[i].r), Q[i].id = i, Q[i].bel = (Q[i].l - 1) / len + 1;
sort(Q + 1, Q + m + 1);
for (int i = 1, l = 1, r = 1; i <= m; i++) {
const int L = Q[i].l, R = Q[i].r;
if (r < R)
v1[l].emplace_back(r + 1, R, i), r = R;
if (l > L)
v2[r].emplace_back(L, l - 1, i), l = L;
if (r > R)
v1[l].emplace_back(R + 1, r, -i), r = R;
if (l < L)
v2[r].emplace_back(l, L - 1, -i), l = L;
}
solve1();
reverse(a + 1, a + n + 1);
for (int i = 1; i <= n; i++)
a[i] = R_ a[i];
solve2();
for (int i = 1; i <= m; i++)
Q[i].ans += Q[i - 1].ans;
for (int i = 1; i <= m; i++)
ANS[Q[i].id] = Q[i].ans;
for (int i = 1; i <= m; i++)
out(ANS[i]), enter;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 18568kb
input:
1000 97 190 576 418 355 344 781 921 548 152 854 269 98 167 630 358 98 939 593 868 689 469 504 251 280 428 198 915 697 34 96 183 225 255 663 2 666 352 992 352 807 11 126 814 514 607 298 433 195 580 328 307 129 210 709 317 69 920 372 461 837 832 990 316 109 512 932 801 918 738 164 24 803 621 814 183 1...
output:
129734 3050 5334 3039 716 4515 83452 15368 15074 1684 14765 30991 44 177 8789 9404 13118 10710 60527 8597 36258 8740 894 41328 3267 6088 35429 3105 115784 3928 50212 41931 11238 7876 2477 5606 7967 36154 33244 7979 87671 19722 65146 981 1621 3416 53 13908 56 52723 41711 1505 842 23141 34524 9399 183...
result:
ok 1000 lines
Test #2:
score: 0
Accepted
time: 697ms
memory: 46888kb
input:
100000 14 94 66 59 1 16 87 44 50 43 79 58 97 28 96 94 12 58 19 88 67 21 74 53 51 60 52 18 45 51 66 98 64 7 13 13 98 85 18 3 38 66 49 26 8 84 13 43 41 15 43 4 16 22 4 43 75 11 64 39 31 44 14 71 63 15 32 10 69 66 52 52 93 27 70 100 83 58 19 50 54 82 95 47 19 6 15 48 61 99 46 84 76 23 35 95 61 33 8 8 8...
output:
4950 4950 4950 4950 4950 4950 4950 4950 4950 4950 4950 4950 4950 4950 4950 4950 4950 4950 4950 4950 4950 4950 4950 4950 4950 4950 4950 4950 4950 4950 4950 4950 4950 4950 4937 4950 4950 4950 4950 4936 4950 4950 4950 4950 4950 4950 4950 4937 4950 4950 4950 4950 4950 4950 4950 4950 4950 4950 4950 4950 ...
result:
ok 500000 lines
Test #3:
score: 0
Accepted
time: 537ms
memory: 46952kb
input:
100000 26667 66074 78768 1312 1129 9121 56389 73242 65893 83961 46264 74722 13132 47203 62521 93190 78433 76660 17024 6150 76323 82828 77801 56792 15226 5848 56397 54767 16376 41192 38176 43614 21471 97925 68084 1165 45308 54862 23256 13239 34417 17311 55610 14790 86092 39369 37314 46023 54940 57176...
output:
2497448228 1012413832 42929122 359187756 19420996 144959930 192419744 75301184 138712802 371217264 171053896 159650932 609721920 1277907851 94049848 326881361 366428559 5381609 65047924 5290614 35118543 237823337 22115666 421226136 1278075906 123163468 528838861 507638399 912287577 7850548 131350669...
result:
ok 500000 lines
Test #4:
score: 0
Accepted
time: 831ms
memory: 46836kb
input:
100000 170 27 780 616 309 522 535 707 429 63 472 999 741 81 876 497 636 813 4 19 608 761 97 839 684 453 961 669 181 565 915 734 71 492 603 283 377 390 789 152 609 706 606 171 704 516 106 73 932 990 33 973 328 83 896 141 352 434 320 468 797 267 460 920 703 72 50 999 444 5 52 264 217 284 605 497 15 63...
output:
499500 499500 499246 499500 499500 499500 499500 499500 341634 499500 499500 499500 499500 499500 499494 499500 499500 499500 499500 499500 499500 496827 498943 499500 499500 499500 499500 499500 499500 499499 499500 499500 499500 328941 499500 499500 499487 499498 499500 497516 499500 499500 492528...
result:
ok 500000 lines
Test #5:
score: 0
Accepted
time: 703ms
memory: 46836kb
input:
100000 86 79 43 61 4 26 74 1 23 48 91 62 90 53 4 4 45 12 92 35 82 92 27 79 52 34 97 40 68 34 19 79 97 18 100 21 92 98 59 47 65 73 58 84 2 63 94 57 43 88 9 28 26 17 31 4 58 12 80 50 4 24 72 40 25 8 99 61 58 7 5 20 73 76 5 2 88 83 66 30 12 64 80 53 94 21 68 86 90 66 74 62 87 6 86 70 21 50 26 93 42 99 ...
output:
4950 4950 4950 1746 4950 4950 4950 4950 4950 4950 4950 4950 4950 4950 4950 4950 4950 4950 4950 4950 4945 4950 4950 4950 4950 4950 4950 4950 4950 4950 4950 4950 4950 4950 4950 4950 4950 4950 4950 4950 4950 4950 4950 4950 4950 4950 4950 4950 4950 4950 4950 4950 4950 4950 4950 4950 4950 4950 4950 4950 ...
result:
ok 500000 lines
Test #6:
score: 0
Accepted
time: 814ms
memory: 46988kb
input:
100000 83307 53652 82499 15407 94650 47347 9562 15070 23752 76507 62712 55887 9567 20853 22505 41179 55335 45516 15527 85232 51865 13366 31251 29183 19321 22256 93892 56622 41078 3761 56002 16333 22916 99768 47570 98226 16348 41 66130 9752 83986 16422 43124 64274 45681 78918 55903 73768 33364 63041 ...
output:
1317359323 418403546 1078491046 782393774 111969297 379767201 283969333 774285350 787859882 32373328 307906184 845462362 543984692 644026602 65634953 201498273 132838309 498243145 117599010 266010108 218484537 540275366 309431502 280027239 139842883 3166044 300690032 306921053 690871458 469001131 93...
result:
ok 500000 lines
Test #7:
score: 0
Accepted
time: 850ms
memory: 46948kb
input:
100000 43 959 620 446 413 35 142 241 968 165 139 471 158 199 888 845 752 243 391 42 850 519 617 844 433 44 263 790 264 384 803 34 756 350 991 585 507 566 888 652 880 987 351 284 114 774 562 861 485 235 487 688 506 539 851 292 922 86 268 862 251 427 763 105 759 328 339 323 980 975 817 711 432 189 927...
output:
499500 499500 499500 476362 35123 499399 499500 496614 499500 499500 499495 499500 499500 499500 499500 499500 499500 499500 499500 499500 499500 499500 421090 338609 499500 499500 32240 499500 499500 499500 499500 150252 499500 499500 499500 499500 499496 455612 94653 499500 499500 499500 499500 49...
result:
ok 500000 lines
Test #8:
score: 0
Accepted
time: 653ms
memory: 46924kb
input:
100000 6 15 5 2 6 6 19 4 20 2 7 4 11 3 8 19 2 5 10 15 1 11 18 11 19 15 12 17 5 1 15 13 13 10 15 10 15 6 3 7 14 3 12 19 16 16 10 20 15 3 14 12 11 13 12 3 18 20 13 5 7 10 6 12 3 15 1 20 14 10 15 5 10 20 4 8 16 11 9 19 7 18 12 14 8 12 12 6 10 18 10 7 14 18 16 15 15 15 13 18 16 15 18 12 2 20 20 14 8 11 ...
output:
190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 110 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190 ...
result:
ok 500000 lines
Test #9:
score: 0
Accepted
time: 475ms
memory: 44160kb
input:
100000 22848 53418 32453 67945 75776 32869 69400 69808 91883 61103 54770 6462 98003 29688 88091 67059 89051 95133 73930 39458 4617 66273 13216 80948 81345 68361 75659 98028 3056 65870 20353 54742 96845 44374 73672 79208 59071 62370 46480 30413 81530 81561 73038 51252 92549 52891 43759 49441 68438 19...
output:
1323273362 1190941986 1225460120 1153142790 1222390113 1119237543 1089444516 1028169264 1197721154 1001328099 1191700715 1192952149 1142493334 1154620679 1099618250 1122979033 1065350193 1154578015 1125032799 1081746467 1064013431 1136523638 1060608655 1193326107 1203312774 1034054932 1000402172 111...
result:
ok 500000 lines
Test #10:
score: 0
Accepted
time: 359ms
memory: 37068kb
input:
100000 97989 76412 14263 71307 52319 46033 81542 78450 48261 17175 82452 66136 20814 86043 6935 97110 32529 45350 23510 34480 96528 64343 94110 83853 46877 52706 32645 56152 87442 40226 62036 15902 8951 24682 66279 18231 51321 19326 62153 60775 52566 85241 78271 77005 91666 72021 97242 79381 51996 3...
output:
1320275385 1310731034 1298844074 1304751472 1303494665 1307089213 1311489803 1313008339 1305605127 1312422127 1301570163 1303687679 1305955660 1297225061 1292436712 1296048090 1298343267 1292440902 1307776042 1312661481 1312719622 1308644338 1293927318 1314825247 1301479025 1298266173 1319389454 130...
result:
ok 500000 lines
Test #11:
score: 0
Accepted
time: 956ms
memory: 46872kb
input:
100000 49686 10705 99617 69265 80713 85939 51769 54307 1940 8849 73594 6892 19399 74838 51739 19949 67693 71777 28821 67030 85663 61819 18578 92169 7291 83009 22324 4762 54659 86038 65799 41066 1871 67403 4518 11912 52885 70937 50050 60193 48859 92959 56577 78908 28864 83186 84015 5701 29268 65691 7...
output:
45277605 29785698 41700125 39784003 353036 41435581 22863645 5712149 17546054 6876894 32301900 8467778 30576535 3093428 27345500 26401229 20416936 25107124 43949849 37561994 15655137 44566051 6069117 36942909 370708 37276701 45203967 24467159 6370837 133683 41993266 42767423 2619888 1500828 180647 1...
result:
ok 500000 lines
Test #12:
score: 0
Accepted
time: 701ms
memory: 46920kb
input:
100000 44122 74775 68715 12734 12611 45725 29565 82232 9775 15598 76075 5292 23807 9775 44746 85685 4079 47867 94301 32458 19769 94551 68715 32458 78430 93590 35520 35520 15598 10386 72854 84372 78585 44746 95535 45725 63980 52621 25128 68300 14993 61398 41569 73767 63980 33915 90941 68544 90941 568...
output:
4950 4950 4950 4950 4950 4950 4950 4950 4950 4950 4950 4950 4950 4950 4950 4950 4950 4950 4950 4950 4950 4950 4950 4950 4950 4950 4950 4950 4950 4950 4950 4950 4950 4950 4950 4950 4875 4950 4950 4950 4950 4950 4950 4950 4950 4950 4950 4950 4950 4950 4950 4950 4950 4950 4950 4950 4950 4950 4950 4950 ...
result:
ok 500000 lines
Test #13:
score: 0
Accepted
time: 410ms
memory: 38044kb
input:
100000 49686 10705 99617 69265 80713 85939 51769 54307 1940 8849 73594 6892 19399 74838 51739 19949 67693 71777 28821 67030 85663 61819 18578 92169 7291 83009 22324 4762 54659 86038 65799 41066 1871 67403 4518 11912 52885 70937 50050 60193 48859 92959 56577 78908 28864 83186 84015 5701 29268 65691 7...
output:
45277605 45275910 45273797 45274164 45275427 45275986 45275586 45274557 45275500 45275489 45274154 45275392 45274285 45275101 45274323 45274703 45274886 45275582 45273017 45276026 45273913 45272770 45274733 45273995 45275279 45273976 45271527 45275599 45274680 45274193 45273746 45276149 45274865 452...
result:
ok 500000 lines
Test #14:
score: 0
Accepted
time: 615ms
memory: 46884kb
input:
99781 7168 48208 29229 47868 87859 90406 91302 94641 85523 61728 37652 75929 52888 86821 87990 93369 36248 97988 97972 66735 91954 58918 46730 30914 94286 52389 82836 91610 61618 99068 41438 96768 952 98016 60082 72786 81236 33818 53411 91139 67862 90850 79121 941 471 97527 74781 89937 89545 225 713...
output:
1109362766 88456453 104760592 519012258 517002231 1084337627 262271075 11632412 151042444 565681982 371883673 409193870 343129 152531250 389236737 150272596 54702816 283612585 270397105 2789164 36849354 294702922 37091550 255505021 844929666 14384724 13405756 887972353 34556481 24542520 1091444202 7...
result:
ok 499960 lines
Test #15:
score: 0
Accepted
time: 734ms
memory: 46908kb
input:
99615 520 91960 27203 57921 24434 345 87172 889 66307 47760 88332 656 83052 899 47439 312 645 83362 83519 42826 96205 97336 66405 99409 19500 97242 86003 80094 35540 35081 9147 96636 85025 89220 79535 829 74 82359 87973 361 99424 51281 67942 80464 86908 61309 883 97349 91209 580 95728 85179 302 8048...
output:
35060418 249535916 52897484 39166485 284308669 303175967 43068359 2322497 103077454 47969959 44044347 39848049 31211378 538086816 123482705 57557468 606060879 508429560 773525540 18370278 81272855 645264017 200487140 126873717 217777289 6340457 215181827 20993184 106131956 112351805 11321188 4200414...
result:
ok 499079 lines
Test #16:
score: 0
Accepted
time: 809ms
memory: 46948kb
input:
99566 436 83 361 822 797 62 908 277 803 983 515 67462 72812 230 68157 435 90026 725 93692 41757 92966 818 26478 755 772 90084 41881 276 59606 654 98153 969 801 90050 163 730 19346 54088 483 958 93837 290 296 96686 251 78977 993 97075 84713 879 770 89557 22932 904 749 386 62627 134 823 72894 633 331 ...
output:
272705094 340215008 45300207 2523266 377104017 83096045 96347284 21171414 529546495 6722250 173110209 215495428 44047048 184156262 175601 170877285 380881735 117507222 2098654 6639816 21867209 28537244 101082472 26470095 9898325 75733837 227940389 32713898 35113832 16876063 34309320 127785237 297048...
result:
ok 499693 lines
Test #17:
score: 0
Accepted
time: 829ms
memory: 46812kb
input:
99468 876 31509 295 660 809 29 59127 781 124 679 965 80362 85386 891 26184 96380 956 45 592 356 63 475 266 86702 271 79107 96006 397 297 78487 377 225 718 40685 99038 850 327 215 587 88372 832 38046 747 43820 305 552 26841 91380 82926 409 87611 960 241 891 49 77951 908 782 596 219 20943 767 342 291 ...
output:
179601 106888113 70322468 146774550 2955819 42390215 11930412 34005747 48313072 27891802 8397981 14109507 103170265 222601867 41674780 1158356 35270448 9392397 1752004 7685606 26923480 4279136 11753662 1892495 68290982 2118315 15409548 220186443 4547024 9428424 11400947 39081804 6181686 44990770 509...
result:
ok 499921 lines
Test #18:
score: 0
Accepted
time: 857ms
memory: 46900kb
input:
99419 686 308 700 690 590 93083 433 712 860 119 114 990 959 941 81064 272 763 535 795 873 74320 861 229 520 760 334 889 854 67899 871 410 366 467 695 584 510 259 644 195 366 966 686 647 560 873 704 581 370 92246 90870 914 84428 42 373 653 941 978 359 182 429 916 91896 681 454 341 304 840 179 537 752...
output:
17567500 407614 743977 3467378 3351295 3789774 7227383 3749104 7793496 12207977 12236810 1207768 3084082 5657303 3746460 1935059 2034225 16350173 5786587 2378520 1980075 3122313 22023957 4094740 8446433 17357052 2199728 6180604 2666691 1615917 1736869 10857820 1516066 20493202 244452 18999000 185578...
result:
ok 499535 lines
Test #19:
score: 0
Accepted
time: 725ms
memory: 46864kb
input:
99360 100 16 82 24 28 88 92494 1 26 66 62 94097 50 72 46 91 66 51 55 22 29 43535 47 16 35 3 73 19 31 85013 76 21 17 22 81214 57 10 80 73 95 73 5 81 10 11 50 25 84 2 52 19 60 70 19 73 31 43 60 48 45 45 23 89 56 18 38 36 60 44 48 43 62 10674 57 63 13 43 82 4 88 92 15 46 94 48 2 48 94 39 42 54 1 96 47 ...
output:
3398039 12445542 19177873 4537645 18542374 288464 93802 14001096 352386 987630 1262090 20200850 19940756 7017832 2498085 13548663 56964 6813426 3767920 16499037 1750915 3820109 16964216 4774306 9746414 486044 284656 45791 15481310 62073 14735494 8478507 11550197 12670572 11047659 8733254 1962588 289...
result:
ok 499672 lines
Test #20:
score: 0
Accepted
time: 751ms
memory: 46780kb
input:
99327 64 6 96 24 54 90 61 66121 7 64710 78 94404 75 12 69524 61 80 67382 81 91 5 30498 96601 28 72 64 88676 60428 94 88 77 81187 46 9 75248 60 72 25 34 20 50 57135 80 71 93790 97970 18 30 31 36 79381 38 79903 6 45 67 54798 62434 43294 56008 61 22 84722 71816 8 25263 86 32816 93 26193 97 86 19 88 79 ...
output:
33075815 5717830 49331822 107557273 900682 7471718 17225882 3706439 2086 56516591 97587637 2118995 427439 158793777 13254406 32718618 32624609 85552145 27402132 71077211 45817703 23897018 119289354 2931277 48945170 138674367 145240425 71742430 14107706 5948171 17185537 137008580 56128445 234822 1947...
result:
ok 499492 lines
Test #21:
score: 0
Accepted
time: 784ms
memory: 46812kb
input:
99305 86059 94592 90 78207 96832 96194 95 80 72102 47 19714 98011 87 94 61095 86215 28601 89 77 24159 7 98 48 96023 89886 36908 72121 25 91558 97842 72 67 60914 28004 57060 65755 91 96884 4 57801 96265 16 85254 80931 61013 91293 84736 9 92398 99060 70978 32 34 13 98453 38096 84210 82047 81229 8 2482...
output:
52479573 56263411 56938567 84922536 164570099 7497799 10886063 990143 17625721 3574449 25236879 31959139 145994577 1632298 124025639 16529960 208836717 64847995 97644209 247585285 91989704 2827852 34668591 65132592 228388003 68616996 354578522 29261770 148704172 75117 207113270 72238130 431521132 34...
result:
ok 499789 lines
Test #22:
score: 0
Accepted
time: 685ms
memory: 46880kb
input:
99151 54870 96472 74688 38 86879 92346 8 10834 26932 82312 86669 61000 89354 26144 62 83611 85522 88732 23 66511 45 53 98355 90224 83249 39 55810 80444 51363 10 24371 93267 19 85 60102 28908 59328 89546 70724 46490 81 46 95 97287 80219 28069 97029 94253 83444 84369 98792 63 59 74 81 26420 65837 8054...
output:
1034510964 873183489 779728054 743019352 96023422 32137457 12703217 309446459 48843498 87358006 646932406 499265387 487665899 311392 50751317 32059577 246063362 172898875 617338936 786042020 953502029 281029479 224693 208228770 202633115 856967328 34899317 547817248 2600761 81460500 10877960 3781819...
result:
ok 499902 lines
Test #23:
score: 0
Accepted
time: 593ms
memory: 46872kb
input:
99128 81906 18624 98818 75 63136 47111 60348 96597 41 8088 2 9 94802 98910 84911 84139 57 73474 77192 95562 79916 87138 82547 10747 61321 96437 92082 84484 86 73 96984 53735 44695 81 90595 76732 63596 25779 37659 81982 74296 82053 85001 23 55512 59429 75626 85401 67630 82949 71032 96 70004 93957 780...
output:
23596290 188128523 50704287 224312843 17789655 282068362 10450556 3495765 479517254 734088163 10597621 270876906 1894610637 19907038 40900 18299202 170510816 1838841132 667669126 10174721 1210783055 579850851 874845294 20635008 1307201 16653730 8582739 524449 749895242 977590868 836723115 42274146 4...
result:
ok 499199 lines
Test #24:
score: 0
Accepted
time: 602ms
memory: 46868kb
input:
99001 19595 91494 97120 24 32600 43651 92770 13699 91496 40851 69981 89804 17056 33553 64121 83245 42267 98826 70839 34427 68039 98 79323 77384 7 98263 93633 74633 72145 66327 72563 85 98591 72348 84927 50978 88646 94621 67045 359 53048 79 85881 66085 24692 73804 62914 31 18 96506 78772 45084 75873 ...
output:
201483624 15778642 9607324 630380359 1367466 809239201 3885388 150872892 467468846 192194 86944570 624468816 530312570 1835352183 219551016 239628707 650209590 420180737 928914352 16878682 1248596043 78918840 209268023 842703368 1523269355 198609721 605514555 245696587 2245710 1940510859 136156722 3...
result:
ok 499995 lines
Test #25:
score: 0
Accepted
time: 574ms
memory: 46904kb
input:
99873 28365 10 7 71505 58106 88647 65748 99549 71958 93839 86104 65539 90637 99867 28722 90726 76027 79397 94727 92845 1 96502 70314 6 96266 35919 80584 95453 41556 91904 99035 59634 5 45019 97704 78079 86278 85137 30666 32323 41218 77471 74363 74931 97172 48417 59746 80065 99356 85851 93255 8 4 839...
output:
23159 4040772 412428156 1968461189 12201321 105369939 1073737185 238771488 606175175 141636805 266276792 1513067313 837786764 403214306 53907133 58871350 58985512 1623474444 1427642 304565 1367072139 691899306 172206984 227042313 89687634 36197512 1117893674 11921215 116560729 206326914 240503789 56...
result:
ok 499791 lines
Test #26:
score: 0
Accepted
time: 655ms
memory: 46876kb
input:
99779 86175 86312 69715 93482 84769 91532 94081 8 85816 2 85580 75296 80509 59813 88453 2 67921 57499 93528 2 91731 97387 16656 5 83272 8 40793 46431 88267 67876 8 98267 59820 9 7 77439 97215 10 47223 8 66330 35982 8 59571 94194 85834 28597 96484 57054 73920 98228 91167 89788 49347 3 59462 3 3 72654...
output:
364076449 46547603 87732946 70526906 180352658 463716803 498042782 664385464 272341596 34901565 204046230 37915067 254102 1073677193 5448687 204849591 233213023 314122165 22932119 330693112 25877288 381969466 3220745 284267243 41836869 9645234 73537883 84583433 14625566 366592756 12559420 252453906 ...
result:
ok 499999 lines
Test #27:
score: 0
Accepted
time: 747ms
memory: 46896kb
input:
99762 80988 97010 797 7 45232 72129 85028 84585 7 51298 9 92707 73268 5 45862 9 86617 54023 8 1 10 4 9 93753 62640 1 91466 7 33889 60987 3 96632 9 10 3 84681 80266 7 6 10 67768 6 3 17269 66300 11753 5 6 84643 3 88788 84143 41503 3 3 1 5 55410 92076 4 2 10 6 47500 2273 2 9 61271 6 19605 9 95218 2 928...
output:
7238457 71896924 35049304 347655844 73883984 107267 24427852 365127305 126288579 172784923 16725794 14957816 25841594 447744205 48242646 376861 11004580 270081676 516433224 261047282 4134178 461202451 170057128 906452 465787 25676939 52752885 15167288 50822926 40603425 5429002 493076150 7180058 7940...
result:
ok 499793 lines
Test #28:
score: 0
Accepted
time: 723ms
memory: 46904kb
input:
99736 80669 5 66405 8 10 2 7 2 7 9 37498 1 78641 3 88147 92543 3 5 2 4 8 4 74190 10 7 8 63165 6 32527 3 1 1 81037 1 8 3 3 65227 92824 5 4 3 2 96235 5 26700 51102 87227 97852 2102 1 4 94274 6 2 8 6 3 6 69963 8 99524 6 7 89761 76488 6 96236 4 76118 8 4 84039 7 46972 36627 7 83350 5 2 62541 1 1 91950 3...
output:
4583044 11796606 6491892 5024524 37390378 494666 185801974 178217 1749300 6974851 464066 189526938 27074366 22788113 780329 893548 8759461 61485109 40694091 4240281 10371518 2363381 33641495 17864413 6720758 1780802 91900616 95689723 20161238 126792 324604 3565605 8116247 60701223 1693957 30506989 5...
result:
ok 499110 lines
Test #29:
score: 0
Accepted
time: 649ms
memory: 46812kb
input:
99710 3 10 10 4 8 60831 1 7 5 2 99676 2 2 5 93758 5 8 6 2 9 95754 3 5 5 10 5 2 4 1 2 1 1 2 8 82121 8 9 6 2 8 5 10 1 5 5 3 8 3 3 5 5 6 94962 85823 70411 8 8 3 9 1 7 7 9 2 2 6 6 7 4 6 3 9 2 6 5 2 10 7 68188 7 10 9 8 8 2 1 1 6 7 2 9 2 3 9 6 61863 77468 4 1 7 5 8 8 1 6 5 8 5 1 1 8 9 6 7 6 2 1 9 34130 3 ...
output:
1733664 103849 4361 113656 3499507 1385464 1279075 535371 15315559 1524864 7041 1320307 17015393 6702936 10560786 1203431 1965952 2834411 6124641 3501950 602135 17123650 239457 11548338 17904971 2446524 1300327 4856825 56899 4933677 2039519 9445362 2700331 7355845 87295 40129 14185721 6034986 688881...
result:
ok 499659 lines
Test #30:
score: 0
Accepted
time: 639ms
memory: 46864kb
input:
99674 1 1 3 2 1 2 3 2 3 2 1 2 3 1 3 2 2 1 1 3 1 2 3 1 3 3 3 2 2 26288 3 2 3 3 2 95354 2 2 2 73317 2 3 2 2 1 2 2 2 3 2 3 3 3 3 3 53811 2 3 1 2 3 2 3 1 2 2 1 2 3 1 2 3 1 2 93381 3 1 68375 1 1 3 2 1 2 3 3 1 3 1 1 1 3 3 3 3 3 1 3 1 1 2 2 1 1 1 2 1 1 69829 2 2 3 2 1 2 3 2 62938 1 3 2 82092 2 3 3 1 3 3 2 ...
output:
5117407 387266 2846727 1437 3555883 2423880 13180153 1281036 1139783 1536722 4675682 6400890 11368592 2170112 142738 109455 282074 1139198 6862884 70500 2831301 737149 8136046 685471 288933 985036 3160127 10524230 352140 29083 1312930 4802270 4780303 2142037 486462 2332113 2416738 590752 844161 3194...
result:
ok 499498 lines
Test #31:
score: 0
Accepted
time: 732ms
memory: 46828kb
input:
99612 83412 2 77234 72319 2 3 1 3 1 1 2 40674 50561 3 20108 2 56426 1 3 22556 2 3 1 90964 78829 3 72661 61103 53808 3 85502 79700 89574 52902 2 2 90233 91000 2 80376 2 3 81471 26684 3 1 13297 3 42340 1 89218 77591 2 3 1 86855 1 64880 1 1 1 69522 1 56077 1 70672 1 2 3 1 2 84227 47399 2 67318 94284 77...
output:
13040982 13786151 161881253 6932471 9917236 59616966 194001204 81388817 325367812 10924288 191816094 36888712 21145149 40716603 11541217 5657810 135109772 169777091 48723386 1134666 1669344 290613264 13150215 498009 22082357 72191049 195585648 3016523 9466293 9831533 508501 11419037 32944855 3911129...
result:
ok 499887 lines
Test #32:
score: 0
Accepted
time: 590ms
memory: 46848kb
input:
99586 93400 95833 84624 93949 54832 50605 2612 80608 14316 38532 54236 90336 55794 97751 88876 47895 85690 62930 95873 72185 92597 21832 90927 70757 98892 29151 86967 49650 90764 46734 87204 86363 73948 40823 79446 82426 58790 88789 83219 71005 95343 80032 14191 1 92161 55414 1589 57968 53904 73553 ...
output:
5889244 315533250 788548099 232249919 5277868 141717943 434488065 8911948 12802622 193271554 78545321 2444819 32386093 84970112 126642219 13186103 62295499 790210340 137153597 7322496 166781396 1228259914 1211532570 101846766 241990614 438679087 466268503 1602450360 1399083037 56757675 465805 219980...
result:
ok 499203 lines
Test #33:
score: 0
Accepted
time: 616ms
memory: 46892kb
input:
99231 55908 59809 90553 68305 86645 96833 48330 80262 72273 6209 5622 75413 83463 82146 86635 23417 24045 79068 7504 93865 57614 89947 95868 34632 1959 60255 89891 54448 82211 57127 65566 626 95635 91968 85757 9781 98985 14476 81296 94294 67992 91302 77407 55001 22547 26362 97801 57422 60145 65232 4...
output:
685481607 1159553310 326158707 148129338 129047993 622255323 35180042 194970394 109080658 1646237691 451982362 359028107 280488168 1947859 863360041 32041187 60875987 123274901 43821149 95095425 97806430 160876105 175785 26633558 196363428 708439388 16368789 4406137 485704273 46477203 20700317 10722...
result:
ok 499063 lines
Test #34:
score: 0
Accepted
time: 768ms
memory: 46864kb
input:
99571 1 1 67983 1 1 1 83000 8 34007 387 88163 59493 11289 92821 101 91624 4 4 1 2 1244 64856 64587 78835 1 96192 40 61038 32143 540 145 95271 95836 58254 89163 94457 23867 1 16387 62007 299 95101 99408 85199 1 208 1 81423 4 7 72208 85720 79382 80448 16055 10 1 2 4 55507 64388 8809 98734 39820 2 5747...
output:
76610162 45336409 84070528 9350657 1253500 27311993 260987872 75243811 616041693 23022293 182587272 6460550 96596949 12487971 137589853 603015 5506116 350045300 116378033 19372305 15590655 296175796 245843734 159721458 172192110 148087357 25565500 392065185 3504707 4828460 93240602 100325003 4441446...
result:
ok 499831 lines
Test #35:
score: 0
Accepted
time: 735ms
memory: 46968kb
input:
99166 67431 416 6265 90592 84488 68396 8694 7502 69482 10094 9800 85327 3814 96651 59514 69391 81170 83948 2880 96771 8015 80750 3407 1004 3538 78898 5900 95129 7531 59559 291 91814 33365 7880 1377 79375 94681 88959 8294 21731 44512 74307 49047 89997 42337 95058 81184 71446 32238 72393 4713 2923 179...
output:
47478844 927371727 709880645 542262760 328495424 8877789 807782643 385796432 132328170 17055822 521032666 481610509 1405527693 46106023 205213923 736990485 4203757 2386669 67367480 406300481 458179996 504921 547047534 129305270 57884953 127956011 38774554 7756854 249540230 70820134 464563421 5009740...
result:
ok 499703 lines
Test #36:
score: 0
Accepted
time: 836ms
memory: 46844kb
input:
99139 56266 276 6997 79974 3178 5927 4611 903 2741 1682 64425 9627 79107 4380 7785 98831 9651 92418 1037 21204 5199 98627 46285 3993 24214 4536 1964 63 6034 143 1085 72416 21902 9891 5490 6012 73550 1346 6175 5769 34784 92006 9461 59284 67610 92760 86737 1199 92264 97866 9165 90236 40752 9364 45632 ...
output:
195214111 114429346 38000309 408326360 853467972 342672613 545541810 73968131 167751768 66017838 281989397 257211256 657069742 632718694 256514897 96966 2714323 1494285 45809450 153545351 346158441 60145880 225334358 695885060 400822608 50772513 80025130 61415758 573208242 709697685 648232420 849216...
result:
ok 499019 lines
Test #37:
score: 0
Accepted
time: 894ms
memory: 46820kb
input:
99107 7162 4167 51801 3343 3025 6111 8891 7856 7897 8512 5128 8273 9890 8913 6571 1694 9163 35046 224 2934 3500 5607 10694 81426 2891 4382 3806 1240 92734 48580 9121 82412 6189 5129 6254 6310 2264 7081 91412 9874 84678 1537 6823 57055 1688 3849 3381 20192 2901 91598 6857 5304 950 2915 23896 2391 106...
output:
175837983 25073170 100593 90642535 164943070 196296200 242961808 256538114 32529018 150592694 13536829 36273609 203867745 421337459 558047 100975329 127185827 35019132 95879791 173204188 25339280 184880788 102499605 147720447 114708058 167985345 139129361 213163694 302337232 29094173 1918071 1698069...
result:
ok 499839 lines
Test #38:
score: 0
Accepted
time: 911ms
memory: 46876kb
input:
99022 587 5097 421 96020 3179 9315 94829 9083 9454 2487 5146 78398 4216 6772 5884 44779 88792 3246 1700 8250 84838 2670 7746 1158 2386 9449 8657 6700 85817 88533 11287 2386 91869 89430 32253 85091 74029 1462 78255 1655 3250 1727 7194 2582 7502 29895 66248 3843 4374 89393 2066 6646 64864 92778 3176 9...
output:
37104304 176953521 1685064 63665665 199420606 50628507 113045897 1787728 17969452 35724657 72698623 132659977 167869262 44287657 65951706 31399179 66565354 165728017 42140190 90361490 143442832 71004813 24973 8405940 182624537 264169345 68156022 94424404 31571537 240408576 151296160 54806759 5383048...
result:
ok 499293 lines
Test #39:
score: 0
Accepted
time: 934ms
memory: 46928kb
input:
99526 31772 6547 3190 8447 2859 2135 851 82561 1490 7427 1661 14147 7077 86442 6088 4293 1996 93893 79869 9795 6054 5609 2509 6930 5702 1137 2228 51327 8475 5185 3667 967 3838 5528 9568 9277 1864 1281 3476 6349 2970 115 8069 655 1549 8554 2186 2465 2329 806 80518 9646 7769 1529 198 6113 1821 2098 96...
output:
21516838 66480548 92903876 11560747 74686629 51073020 63497925 40271118 24123021 25860182 43010623 56256759 91621194 90583 28909640 1214805 34623742 27849288 98397126 73498963 28102719 40181005 65219342 71272507 64410690 36142985 30038498 71183554 53425026 113813322 64156378 27561785 48884238 398097...
result:
ok 499723 lines
Test #40:
score: 0
Accepted
time: 960ms
memory: 46896kb
input:
99396 6625 13358 17136 1184 22053 7015 5483 23145 1916 16599 31912 13838 20690 31675 3771 2883 22659 25186 14700 786 17634 10926 9912 1111 2229 23191 29007 3140 32694 18599 10516 22238 23315 27775 10145 22398 24048 32593 13504 337 27104 27748 31474 24537 23408 4499 19436 32618 13980 20430 13589 9645...
output:
325675280 9448227 104000370 333202444 144618316 78337 12754567 315075717 1578390 221918192 235754403 225518616 67704323 205693448 53498323 128728653 227626489 257650108 217562 7909704 261290415 5118075 19563807 262256936 88322122 302063360 282704051 183455790 20638516 185330761 202684999 57550571 34...
result:
ok 499770 lines