QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#226545 | #7612. Matrix Inverse | ucup-team1600 | AC ✓ | 1057ms | 35068kb | C++20 | 8.1kb | 2023-10-26 03:08:06 | 2023-10-26 03:08:08 |
Judging History
answer
#pragma GCC optimize("Ofast", "unroll-loops")
#pragma GCC target("sse", "sse2", "sse3", "ssse3", "sse4")
#ifdef LOCAL
#include <iostream>
#include <cmath>
#include <algorithm>
#include <stdio.h>
#include <cstdint>
#include <cstring>
#include <string>
#include <cstdlib>
#include <vector>
#include <bitset>
#include <map>
#include <queue>
#include <ctime>
#include <stack>
#include <set>
#include <list>
#include <random>
#include <deque>
#include <functional>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <complex>
#include <numeric>
#include <cassert>
#include <array>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <thread>
#else
#include <bits/stdc++.h>
#endif
#define all(a) a.begin(),a.end()
#define len(a) (int)(a.size())
#define mp make_pair
#define pb push_back
#define fir first
#define sec second
#define fi first
#define se second
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
typedef long double ld;
template<typename T>
inline bool umin(T &a, T b) {
if (b < a) {
a = b;
return true;
}
return false;
}
template<typename T>
inline bool umax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
#ifdef LOCAL
#define D for (bool _FLAG = true; _FLAG; _FLAG = false)
#define LOG(...) print(#__VA_ARGS__" ::", __VA_ARGS__) << endl
template <class ...Ts> auto &print(Ts ...ts) { return ((cerr << ts << " "), ...); }
#else
#define D while (false)
#define LOG(...)
#endif // LOCAL
const int max_n = 2011, inf = 1000111222;
const int mod = 1000000007;
inline void inc(int &x, int y) {
x += y;
if (x >= mod) {
x -= mod;
}
}
inline void dec(int &x, int y) {
x -= y;
if (x < 0) {
x += mod;
}
}
inline int mul(int x, int y) {
return (1LL * x * y) % mod;
}
int power(int x, int y) {
if (y < 0) {
y += mod - 1;
}
if (y == 0) {
return 1;
}
if (y % 2 == 0) {
return power(mul(x, x), y / 2);
}
return mul(x, power(x, y - 1));
}
inline int inv(int x) {
return power(x, mod - 2);
}
// new mint part
inline int divide (int x, int y) {
return mul(x, inv(y));
}
struct mint {
#define oper_apply(op, f) mint& operator op (const mint &x) {f(val, x.val); return *this;}
#define oper_apply_const(op, f) mint operator op (const mint &x) const {mint tmp = *this; f(tmp.val, x.val); return tmp;}
#define oper_return(op, f) mint& operator op (const mint &x) {val = f(val, x.val); return *this;}
#define oper_return_const(op, f) mint operator op (const mint &x) const {return mint(f(val, x.val));}
int val;
mint(int x = 0) : val(x) {}
oper_apply(+=, inc);
oper_apply_const(+, inc);
oper_apply(-=, dec);
oper_apply_const(-, dec);
oper_return(*=, mul);
oper_return_const(*, mul);
oper_return(/=, divide);
oper_return_const(/, divide);
oper_return(^=, power);
oper_return_const(^, power);
};
mt19937 rng(228);
template<typename T = int>
inline T randll(T l = INT_MIN, T r = INT_MAX) {
return uniform_int_distribution<T>(l, r)(rng);
}
inline ld randld(ld l = INT_MIN, ld r = INT_MAX) {
return uniform_real_distribution<ld>(l, r)(rng);
}
inline vector <mint> mult (vector <vector <mint> > &a, vector <mint> &b) {
int n = len(b);
vector <mint> res(n);
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
res[i] += a[i][j] * b[j];
}
}
return res;
}
inline vector <mint> mult (vector <mint> &b, vector <vector <mint> > &a) {
int n = len(b);
vector <mint> res(n);
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
res[i] += b[j] * a[j][i];
}
}
return res;
}
mint dp[max_n][13] = {};
mint val[max_n] = {}, sol[13] = {};
inline void solve (int n, int k) {
for (int i = 0; i < n; i++) {
int pos = -1;
for (int j = 0; j < k; j++) {
if (dp[i][j].val != 0) {
pos = j;
break;
}
}
if (pos == -1) {
LOG(val[i].val);
assert(val[i].val == 0);
continue;
}
mint inv = mint(1) / dp[i][pos];
for (int j = 0; j < k; j++) {
dp[i][j] *= inv;
}
val[i] *= inv;
for (int j = 0; j < n; j++) {
if (i == j || dp[j][pos].val == 0) {
continue;
}
mint now = dp[j][pos];
for (int i1 = 0; i1 < k; i1++) {
dp[j][i1] -= now * dp[i][i1];
}
val[j] -= now * val[i];
}
}
for (int i = 0; i < k; i++) {
sol[i] = 0;
for (int j = 0; j < n; j++) {
if (dp[j][i].val) {
sol[i] = val[j];
break;
}
}
}
}
const int debug = 0;
int main() {
// freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int n;
cin >> n;
vector <vector <mint> > a(n, vector <mint> (n));
vector <vector <mint> > b(n, vector <mint> (n));
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
if (!debug) {
cin >> a[i][j].val;
}
else {
a[i][j].val = i == j;
}
}
}
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
if (!debug) {
cin >> b[i][j].val;
}
else {
b[i][j].val = i == j;
}
}
}
if (debug) {
set <int> X, Y;
for (int i = 0; i < 12; i++) {
int x = randll(0, n - 1);
int y = randll(0, n - 1);
int c = randll(0, mod - 1);
X.insert(x);
Y.insert(y);
b[x][y].val = c;
}
LOG(len(X), len(Y));
}
vector <int> col(n), row(n);
int cnt = 0, gg = 0;
vector<int> have;
for (int it = 0; it < 2; it++) {
vector<mint> v(n);
for (int i = 0; i < n; i++) {
v[i] = randll(0, mod - 1);
}
auto v1 = mult(v, a);
v1 = mult(v1, b);
for (int i = 0; i < n; i++) {
if (col[i]) {
continue;
}
if (v1[i].val != v[i].val) {
col[i] = 1;
++gg;
}
}
auto v2 = mult(a, v);
v2 = mult(b, v2);
for (int i = 0; i < n; i++) {
if (row[i]) {
continue;
}
if (v2[i].val != v[i].val) {
row[i] = 1;
++cnt;
have.pb(i);
}
}
}
vector <pair<pii, int> > ans;
LOG(cnt);
if (gg >= 13) {
exit(0);
}
if (cnt >= 13) {
cout << "!!!\n";
exit(0);
}
assert(cnt < 13);
for (int i = 0; i < n; i++) {
if (!col[i]) {
continue;
}
vector <mint> now(n);
for (int j = 0; j < n; j++) {
for (int k = 0; k < n; k++) {
now[j] += a[j][k] * b[k][i];
}
if (j == i) {
now[j] -= 1;
}
val[j] = now[j];
// LOG(j, now[j].val);
}
int num = 0;
for (auto &j : have) {
for (int k = 0; k < n; k++) {
dp[k][num] = a[k][j];
}
++num;
}
solve(n, cnt);
for (int j = 0; j < cnt; j++) {
if (sol[j].val != 0) {
// LOG(j, sol[j].val);
mint real_val = b[have[j]][i] - sol[j].val;
ans.pb({{have[j], i}, real_val.val});
}
}
}
sort(all(ans));
cout << len(ans) << '\n';
for (auto &i : ans) {
cout << i.first.first + 1 << ' ' << i.first.second + 1 << ' ' << i.second << '\n';
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3656kb
input:
1 953176428 107682094
output:
0
result:
ok single line: '0'
Test #2:
score: 0
Accepted
time: 710ms
memory: 34896kb
input:
1995 586309310 548144807 578573993 437893403 641164340 712256053 172321263 108058526 768610920 123320669 762746291 856047593 979279376 29067913 309867338 292286426 45124325 239705174 675003623 213743652 620561338 116308277 695369179 669459894 682522334 846995555 159510341 999359657 645579085 7499563...
output:
2 827 238 84815305 1466 499 206940592
result:
ok 3 lines
Test #3:
score: 0
Accepted
time: 726ms
memory: 34856kb
input:
1995 436890614 28924575 276129332 63568266 576410175 399540058 591733285 531509939 637241038 596750662 811926780 760228238 317196903 751498201 993802643 102539089 382116597 233386377 974332817 495280100 575832855 616941506 297856263 216480938 638907269 434126707 499611855 764625526 51141033 64624519...
output:
3 315 590 222982023 421 1912 523778307 745 1803 328256562
result:
ok 4 lines
Test #4:
score: 0
Accepted
time: 766ms
memory: 34976kb
input:
1998 583111238 684686962 60000552 833067795 399706437 80311170 511421309 126675237 578609031 629890589 4721597 505178877 965431576 488092987 110903821 856966035 934194793 831090190 93501498 982251231 221658950 561834845 801921306 125139448 771849922 610370373 625334897 671223646 927123592 441019972 ...
output:
4 21 1273 160152585 700 1573 576757184 1674 1165 958703366 1860 1550 451190886
result:
ok 5 lines
Test #5:
score: 0
Accepted
time: 816ms
memory: 35004kb
input:
2000 717395008 183448326 460843970 942614578 540060179 334668801 284127311 635920935 518435676 579369810 852254297 342132392 390366615 141010330 256825376 585810764 253867889 483289117 141421931 467578626 750184736 801127935 917825514 702243210 954747981 910219404 311930180 11494244 915417963 820983...
output:
5 30 992 620409139 585 130 391404065 910 139 921101622 1292 496 462362602 1579 1776 163902318
result:
ok 6 lines
Test #6:
score: 0
Accepted
time: 831ms
memory: 35008kb
input:
2000 620840546 358023079 309405838 45500223 855686733 508959744 51181469 968972877 537705762 129000719 720633908 884983092 862573877 806580605 252024754 680227415 839963816 519838198 171117282 55679929 677376107 529124099 733179585 20941462 208815360 171000233 981430676 830346879 857681989 863823572...
output:
6 708 1628 497911789 714 1597 924600947 1105 1248 334964897 1209 1517 696980563 1386 1495 446362422 1427 979 599811696
result:
ok 7 lines
Test #7:
score: 0
Accepted
time: 845ms
memory: 35024kb
input:
1999 199111744 347283243 902808247 73043926 77805820 474451787 854137221 262193129 508272500 493604512 479354501 851331944 65939325 676555110 301252826 583818606 235970147 545653095 120576387 825367169 249335412 365652469 200134563 609796865 481733518 594700892 34132902 906919419 939234722 888820985...
output:
7 43 586 272473841 116 1477 158203105 122 1169 761579075 477 1913 749351268 592 583 329485518 662 1400 622650552 1563 148 498180819
result:
ok 8 lines
Test #8:
score: 0
Accepted
time: 861ms
memory: 35036kb
input:
1999 95525499 999471184 616044299 270968642 734163712 806403756 187471687 954208629 738712543 303515182 65192240 341396506 976491262 49950446 564351227 957716298 984366409 189359888 6212233 992086125 956271984 926015141 961718572 628613990 96751949 438018145 639769590 234289696 391888974 135327482 5...
output:
8 279 1620 990329039 882 1321 138573187 1060 836 505053059 1155 214 213425345 1525 906 706361973 1553 569 257967325 1601 1141 127915131 1898 738 215879720
result:
ok 9 lines
Test #9:
score: 0
Accepted
time: 949ms
memory: 34884kb
input:
1996 283446729 904496697 172085277 783069511 818458698 756950687 658910284 99042559 674918562 839616643 448339652 245867480 780073469 684157018 540143866 106204044 613514272 978909042 463995202 654242309 233752461 442383227 477386126 286799884 347610798 141921338 587706626 348419066 962374154 132965...
output:
9 309 1146 916944155 993 1418 998808956 1136 629 476558426 1232 181 439191299 1268 169 491439673 1314 1282 443126632 1415 447 825877434 1541 1779 159693126 1971 1624 228388510
result:
ok 10 lines
Test #10:
score: 0
Accepted
time: 955ms
memory: 35000kb
input:
2000 805314295 257118023 408649013 403270425 561279436 651061472 951531903 607216144 450523182 22974988 674008912 524751540 430060765 578271056 821812595 450493650 896882866 256881145 794394659 634756412 525452196 456872277 895856586 30892092 953830689 157566519 434684214 457301058 431434093 3366527...
output:
10 86 1649 33550286 277 1565 703044124 280 410 767223588 1104 2000 542808584 1165 1837 79761216 1198 360 199585712 1555 178 236137043 1785 1339 983174708 1869 827 135692552 1905 106 851820078
result:
ok 11 lines
Test #11:
score: 0
Accepted
time: 953ms
memory: 34976kb
input:
2000 817831410 837938066 689510456 728988871 925783369 338613646 248460715 797908768 377220868 479079342 718258246 570192472 123025052 702404754 46773852 774152140 719909131 276906493 812767887 453766159 835272763 672918600 773064126 85235335 702812671 696620460 835547337 762745753 759411320 8083624...
output:
11 1 1476 149884243 374 1642 562186259 561 1959 143239748 631 973 100680542 888 1538 726522334 977 526 154377214 1252 262 533011147 1327 1409 392931391 1516 1778 182730233 1782 369 67351156 1855 441 263735571
result:
ok 12 lines
Test #12:
score: 0
Accepted
time: 1ms
memory: 3584kb
input:
1 320856661 676593229
output:
1 1 1 914973852
result:
ok 2 lines
Test #13:
score: 0
Accepted
time: 1004ms
memory: 34988kb
input:
2000 518876875 70744495 932244095 614062954 626814336 829150893 998680280 234000933 386686857 577640648 274534113 991968823 338694676 262803592 479224937 248407688 347367787 652722556 999864985 89935946 408575273 342878274 571453557 392556701 38963300 523278627 865830573 710529656 364067377 62819930...
output:
12 268 1341 872543861 301 670 83707290 404 923 771911145 515 915 315878115 531 1675 222526996 546 1464 698683617 667 1134 328997403 785 1886 372491749 1122 279 94873268 1178 1415 973999117 1868 1621 302520255 1969 339 658284571
result:
ok 13 lines
Test #14:
score: 0
Accepted
time: 755ms
memory: 35052kb
input:
1999 126132375 800032351 262637151 998840174 328383619 204918469 536208333 513995901 829164057 538609601 377089892 540716849 41937614 354466066 523585800 195798378 326644387 4751170 678657258 271678980 62983734 10852818 684364703 373677368 25240334 568320119 962133095 18314188 863238520 867505712 18...
output:
12 317 534 317967235 317 1221 672781882 317 1395 757051682 317 1533 223265150 663 534 107325986 663 1221 501079553 663 1395 352817739 663 1533 961065190 924 534 339954283 924 1221 188373539 924 1395 39691647 924 1533 854538181
result:
ok 13 lines
Test #15:
score: 0
Accepted
time: 728ms
memory: 35012kb
input:
1999 370828093 828933278 920173220 740771905 268813966 910479507 392970052 847922924 19573719 825413514 991590471 856671077 993900741 952892873 394675610 837428479 238861594 63756696 803502792 305104791 697054451 370933149 158939288 892700051 963947171 577946344 905348316 23696678 792096181 44575458...
output:
12 131 126 316849219 131 435 745757250 131 670 188997514 430 126 30755629 430 435 28926874 430 670 270564257 834 126 382641538 834 435 524485184 834 670 585102542 1613 126 932907865 1613 435 998975232 1613 670 263273055
result:
ok 13 lines
Test #16:
score: 0
Accepted
time: 784ms
memory: 35032kb
input:
1999 903591810 198238634 684298812 164105032 256956039 672861757 471025345 821182495 883470818 901728280 532295261 767968738 320294286 700772290 169700509 727112521 564257857 364791286 338836071 302817382 904614053 865507136 894734659 779655445 983613621 316690977 857375656 6451093 698119294 1598481...
output:
12 13 1960 424168931 194 234 227222514 615 234 273154103 615 1371 325633047 810 234 876520078 946 234 238602556 954 216 547623002 954 702 476976153 954 1960 503560106 1192 1960 698806771 1958 1371 631940104 1958 1960 388266681
result:
ok 13 lines
Test #17:
score: 0
Accepted
time: 793ms
memory: 34992kb
input:
1999 627118247 935982489 885954228 517473796 44083930 484518245 499676210 738332092 874151437 95535844 559086957 309113085 299789365 906919230 945098985 769325973 628282677 597797906 124653793 521055644 245063580 630252005 183949846 564672468 527964623 231388808 285012487 29386288 757802849 38889177...
output:
12 49 1793 921631393 705 1908 417596430 871 1908 961357700 1030 1908 283031921 1093 542 121661519 1093 1522 87579226 1093 1908 716167634 1489 542 612583557 1652 1793 909132547 1806 1522 282067170 1806 1596 984560360 1806 1793 852911378
result:
ok 13 lines
Test #18:
score: 0
Accepted
time: 692ms
memory: 35004kb
input:
2000 336477725 344614810 759723031 897668323 29157694 440949784 139315818 764784549 810466017 684155405 81843033 609608717 400540490 571611798 657357357 828338500 798932134 436045646 875622403 714290029 862194717 983729486 243849052 578156290 19156078 721842687 818890234 196674335 844235821 57639912...
output:
12 411 1126 501383645 411 1251 578770760 411 1407 428879799 766 1126 442413143 766 1251 682670649 766 1407 7221951 1138 1126 43277264 1138 1251 846615881 1138 1407 232292075 1717 1126 371996778 1717 1251 334914683 1717 1407 779537286
result:
ok 13 lines
Test #19:
score: 0
Accepted
time: 746ms
memory: 34996kb
input:
1999 192143667 846231509 374951421 282340579 992130213 32439194 730155201 452719071 682420232 674225452 10653359 409359680 584185410 580015389 475820282 736404188 394896233 352719251 492674608 141301951 784236812 373162646 188532420 708356143 183745168 192423076 442781368 484354809 697193908 9915016...
output:
12 81 1155 826104455 615 258 7345693 959 258 636752307 1016 942 774880182 1107 1155 541482380 1107 1816 176901086 1162 942 853261047 1162 1816 829575006 1717 942 377271277 1875 1816 48625384 1912 258 968957956 1912 1155 364003817
result:
ok 13 lines
Test #20:
score: 0
Accepted
time: 866ms
memory: 35028kb
input:
2000 470636580 899273352 350166464 523111928 812258536 899903901 71571732 842738863 987895689 136327554 652942779 650349069 335395341 460415467 955302064 348295085 286354455 812853909 922090473 915200207 803195822 135934405 428703857 262895139 319784332 63252432 866823736 388274158 204051575 1469072...
output:
12 360 1036 129892106 360 1767 994523999 623 327 215625787 623 750 412972732 623 928 893735116 623 1036 683799411 623 1918 186544232 1182 750 486642534 1182 929 532047060 1518 750 873084392 1578 78 186357954 1578 929 109060959
result:
ok 13 lines
Test #21:
score: 0
Accepted
time: 983ms
memory: 34976kb
input:
1999 720655701 977467852 885343236 88349312 14863630 100255901 925544428 452701056 132254633 821794681 439447077 100482626 494053817 810464371 280009501 782468062 626866283 523055497 380621157 48086399 954319042 651987710 916345938 67641818 363318266 921485607 561322272 333500586 711059456 941774238...
output:
12 276 246 501071414 276 301 135529322 276 411 310731045 276 415 702953806 276 524 457201176 276 864 980692702 276 1169 575959748 276 1474 25695168 276 1639 529621448 276 1664 385359528 276 1744 973257319 276 1917 707229662
result:
ok 13 lines
Test #22:
score: 0
Accepted
time: 653ms
memory: 35068kb
input:
2000 216228525 575319605 599895437 852292022 804282911 156399371 35939181 635345055 827829679 845342493 81147843 958100184 321410579 449849844 58967802 842945624 686219787 313017814 483472081 606773500 829761709 322450699 961455771 617304724 942667942 657778472 896729841 495800788 812068579 87926518...
output:
12 104 80 747828421 132 80 648317505 253 80 480884674 329 80 311175812 410 80 294646749 456 80 621454073 736 80 540945702 984 80 55150747 1142 80 387075663 1347 80 261641779 1417 80 658455250 1832 80 573294900
result:
ok 13 lines
Test #23:
score: 0
Accepted
time: 1ms
memory: 3644kb
input:
2 201246079 663051287 853555665 44164855 700103727 546814231 735868321 179950016
output:
3 1 1 185176838 1 2 215307243 2 1 812299899
result:
ok 4 lines
Test #24:
score: 0
Accepted
time: 696ms
memory: 35008kb
input:
2000 152162445 967176347 962347388 190716819 100879134 728064582 565971218 482986513 212508543 266299399 75583805 378053101 113182264 609874438 58819598 737369748 515742646 536633725 968999108 933696873 36299936 832998503 720571889 714015245 346002009 913704468 21883119 359082674 358603499 250302191...
output:
4 1 1 573789242 1 2000 135116635 2000 1 656863707 2000 2000 99666945
result:
ok 5 lines
Test #25:
score: 0
Accepted
time: 452ms
memory: 34980kb
input:
2000 0 0 0 0 1000000006 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
output:
12 58 172 0 174 1878 0 216 809 0 516 1255 0 816 1299 0 881 80 0 949 364 0 1423 729 0 1494 991 0 1579 1430 0 1818 334 0 1987 1728 0
result:
ok 13 lines
Test #26:
score: 0
Accepted
time: 444ms
memory: 34996kb
input:
2000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...
output:
12 21 1590 0 509 1891 0 748 1474 0 818 1934 0 869 1584 0 930 1828 0 932 1412 0 1183 1868 0 1289 267 0 1395 1227 0 1493 202 0 1929 398 0
result:
ok 13 lines
Test #27:
score: 0
Accepted
time: 470ms
memory: 34924kb
input:
1999 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...
output:
12 188 605 0 280 930 0 509 429 0 747 494 0 853 1678 0 871 1580 0 1063 650 0 1422 448 1000000006 1592 1695 0 1602 705 0 1967 1834 0 1979 108 0
result:
ok 13 lines
Test #28:
score: 0
Accepted
time: 637ms
memory: 35012kb
input:
1999 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1000000006 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1000000006 0 0 0 1000000006 0 0 1 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 1000000006 0 0 0 0 1000000005 1000000006 1 0 0 0 0 0 1 0 0 0 1000000006 1 0 0 1000000006 0 0 1000000006 0 0 0 1 0 100000...
output:
12 87 1244 0 330 419 0 367 422 0 541 158 0 631 1574 0 710 1318 0 1151 1128 0 1186 524 1000000003 1303 466 0 1596 395 1000000006 1805 417 0 1896 1740 0
result:
ok 13 lines
Test #29:
score: 0
Accepted
time: 1057ms
memory: 35004kb
input:
1999 999999982 999999985 999999996 999999994 999999979 23 999999999 12 999999982 999999988 4 999999993 999999933 1000000000 1 20 94 3 29 999999977 999999882 1000000006 21 1000000006 80 999999979 8 1 1 999999973 999999995 999999997 11 5 7 10 36 999999999 1000000000 11 17 24 25 31 40 999999970 9999999...
output:
12 330 1773 999999960 427 449 5 468 1105 999999997 497 356 1000000003 686 247 4 710 604 999999992 879 1237 99 1031 1679 999999981 1042 674 999999993 1068 1988 999999934 1751 673 999999995 1829 1201 21
result:
ok 13 lines
Test #30:
score: 0
Accepted
time: 360ms
memory: 35056kb
input:
1999 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...
output:
12 6 461 0 6 1375 0 6 1762 0 346 461 0 346 1762 0 469 1762 0 1473 1513 0 1541 461 0 1541 782 0 1541 1495 0 1541 1513 0 1582 782 0
result:
ok 13 lines
Test #31:
score: 0
Accepted
time: 382ms
memory: 35008kb
input:
1999 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...
output:
12 114 13 0 114 559 0 241 1506 0 241 1916 0 570 13 0 570 1506 0 731 1506 0 952 70 0 952 1603 0 1036 1588 0 1050 1588 0 1137 1916 0
result:
ok 13 lines
Test #32:
score: 0
Accepted
time: 403ms
memory: 34988kb
input:
1999 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...
output:
12 386 416 0 386 565 0 386 1146 0 446 201 0 982 1146 0 982 1246 0 982 1873 0 1153 100 0 1153 238 0 1165 238 0 1434 201 0 1434 238 0
result:
ok 13 lines
Test #33:
score: 0
Accepted
time: 481ms
memory: 34984kb
input:
1999 1000000005 0 1000000006 0 0 0 1000000005 1000000006 1000000006 0 0 2 1000000006 2 1 0 1000000003 1000000006 1 1 1000000006 1 4 2 0 2 0 1000000006 0 0 0 1000000005 1000000006 0 3 0 1 1000000006 1000000004 1000000006 0 0 0 1000000006 1000000006 1000000002 0 0 1000000006 1000000006 1000000006 1000...
output:
12 65 136 0 65 481 0 472 136 0 472 481 0 794 136 0 794 481 0 1426 136 0 1426 481 0 1613 136 0 1613 481 0 1815 136 0 1986 481 0
result:
ok 13 lines
Test #34:
score: 0
Accepted
time: 1ms
memory: 3540kb
input:
3 563054301 466268686 969888154 959871519 107336067 983321464 775058210 468007639 625272848 543485219 990926090 132247981 370165943 462174196 920378113 24485615 810600798 230152002
output:
9 1 1 250964580 1 2 352942815 1 3 693528628 2 1 295817768 2 2 726755757 2 3 617881002 3 1 762251209 3 2 415677779 3 3 181721698
result:
ok 10 lines
Test #35:
score: 0
Accepted
time: 712ms
memory: 35036kb
input:
1999 999999944 79 5 999999840 155 291 999999975 69 112 999999975 142 999999859 30 999999996 133 110 11 101 999999970 40 999999783 999999898 75 42 216 1 13 999999981 2 15 213 46 999999937 999999943 999999958 22 73 14 57 256 118 999999847 177 999999949 151 999999849 999999844 142 37 999999995 11 99999...
output:
12 68 817 1000000002 68 993 999999946 108 817 44 108 1372 5 191 817 7 191 993 999999988 417 1372 999999999 941 817 999999995 941 1372 3 1786 1372 11 1839 1372 30 1848 993 17
result:
ok 13 lines
Test #36:
score: 0
Accepted
time: 390ms
memory: 34956kb
input:
2000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1000000006 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
output:
12 97 1321 1 129 54 1000000005 129 110 0 129 925 0 129 938 0 129 1257 1000000006 129 1416 1000000006 180 1321 2 286 1321 1 1789 1321 0 1928 1321 0 1962 1321 1000000006
result:
ok 13 lines
Test #37:
score: 0
Accepted
time: 393ms
memory: 35000kb
input:
2000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1000000006 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1000000006 0 0 0 0 0 0 0 0...
output:
12 105 695 0 237 695 1000000006 286 695 0 1023 695 1 1284 298 1 1284 781 0 1284 1069 1000000006 1284 1580 1 1284 1622 0 1284 1693 1 1502 695 0 1603 695 1000000006
result:
ok 13 lines
Test #38:
score: 0
Accepted
time: 1ms
memory: 3620kb
input:
10 227511195 218506808 182689819 174586217 438072440 916904444 390019069 514691814 171314921 25407636 175879527 621021029 307392698 559570825 948840815 816369934 131622656 991148260 892983573 225549131 834211325 29167891 45912384 993027622 80068070 659393514 254397920 427811405 508347151 243366685 8...
output:
10 1 3 600688498 3 9 661304805 5 3 19888620 6 4 387577104 7 5 558281137 7 7 232272633 8 1 408341013 8 5 265653763 9 2 992579825 9 4 109385950
result:
ok 11 lines
Test #39:
score: 0
Accepted
time: 1ms
memory: 3588kb
input:
30 755741732 268740418 567119675 368832604 223786302 765138184 787818718 854883183 768246833 125917151 300079030 938959302 688590952 511191252 6584138 773676627 259851385 765143499 541137810 947383948 403123733 36596987 683117312 327655070 865245880 753430119 240572156 626955092 481019957 13773948 7...
output:
11 2 11 836425927 5 26 865488670 6 4 935238209 6 24 510879265 6 30 502619056 10 26 895110811 16 15 724225925 19 1 670805976 19 25 822747383 22 5 19537472 25 27 26004296
result:
ok 12 lines
Test #40:
score: 0
Accepted
time: 55ms
memory: 5616kb
input:
500 611891998 505307531 585146253 237693346 238362808 684390610 40030631 633999963 304220947 639991236 553081047 511252911 404663536 430216167 884093792 441530975 80994666 401586206 750067742 129433690 693228242 96166380 285398577 149800584 85886454 712438473 141630151 754832589 205878353 693116671 ...
output:
12 19 434 558617998 30 249 181314635 60 202 231645496 108 198 242117040 140 274 730459545 184 215 115186118 218 429 528526142 274 134 593561258 290 474 376650029 300 194 899702313 435 328 677030230 457 176 29540215
result:
ok 13 lines
Test #41:
score: 0
Accepted
time: 640ms
memory: 34672kb
input:
1996 990922390 961325742 81568915 585710413 465107729 781819792 297471666 53295713 885502434 436985366 892266589 99923669 488076275 226057391 805901833 239416173 110615296 323264059 16734217 558674206 517544731 701570943 868365333 180137646 517026419 250390382 874463105 756053490 876205744 837560895...
output:
0
result:
ok single line: '0'
Test #42:
score: 0
Accepted
time: 658ms
memory: 34972kb
input:
1998 110461795 256131761 464705880 843262886 270011618 112670645 152554539 465680982 967502690 691380590 907819455 559965663 336789620 596483126 505843993 48466221 375163652 979182758 137485376 508855677 240035827 279384061 123889523 477820338 810104815 764384783 553502992 982900491 883919366 308048...
output:
1 1966 645 478242551
result:
ok 2 lines
Extra Test:
score: 0
Extra Test Passed