QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#182771#5743. Palindromic Polynomialucup-team1209WA 887ms7776kbC++205.0kb2023-09-18 15:15:252023-09-18 15:15:26

Judging History

你现在查看的是最新测评结果

  • [2023-09-18 15:15:26]
  • 评测
  • 测评结果:WA
  • 用时:887ms
  • 内存:7776kb
  • [2023-09-18 15:15:25]
  • 提交

answer

#include<bits/stdc++.h>
const int mod = 1e9 + 9;
using namespace std;
#define pb push_back
#define cs const
using std::cin;
using std::cout;
using u64 = unsigned long long;
using ll = long long;

void Add(int &x, int y) {
    if((x += y) >= mod) x -= mod; 
}
int add(int x, int y) {
    Add(x, y);
    return x;
}
void Dec(int &x, int y) {
    if((x -= y) < 0) x += mod; 
}
int dec(int x, int y) {
    Dec(x, y);
    return x;
}
int mul(int x, int y) {
    return 1ll * x * y % mod; 
}
void Mul(int &x, int y) {
    x = 1ll * x * y % mod; 
}
int ksm(int a, int b) {
    int c = 1; 
    for(; b; b >>= 1, Mul(a, a))
    if(b & 1) Mul(c, a);
    return c; 
}
const int N = 1e3 + 5;
int T, n; 
int a[N][N];

void fuckyou(int d, int mx, vector <int> x, vector <int> y) {
    for(int i = 0; i < n; i++) {
        for(int j = 1; j < d; j++) {
            int coef = j + j == mx ? ksm(x[i], j) : add(ksm(x[i], j), ksm(x[i], mx - j));
            a[i][j] = coef;
        }
        a[i][0] = 0; 
        a[i][d] = add(ksm(x[i], mx) + 1, y[i]);
    }

    // cout << d << ' ' << n <<  endl;

    for(int i = 0; i < d; i++) {
        int k = i; 
        while(a[k][i] == 0 && k < n) ++ k;
        if(k >= n) {
            continue; 
        }
        swap(a[i], a[k]);
        int iv = ksm(a[i][i], mod - 2);
        for(int j = 0; j < n; j++) 
        if(j != i && a[j][i]) {
            int c = mul(a[j][i], iv);
            for(int k = i; k <= d; k++)
                Dec(a[j][k], mul(a[i][k], c));
        }
    }
}
void Main() {
    cin >> n; 
    vector <int> x(n), y(n);
    for(int & a : x) cin >> a; 
    for(int & a : y) cin >> a; 
    
    bool zero = 1; 
    for(int a : y) zero &= a == 0; 
    if(zero) {
        cout << 0 << '\n';
        return;
    }

    vector <bool> ok(1e4 + 1, 1);
    for(int i = 0; i < n; i++)
    for(int j = 0; j < n; j++) 
    if(mul(x[i], x[j]) == 1) {
        // cout << "FF " << x[i] << ' ' << x[j] << endl;
        if(y[j] == 0) {
            if(y[i] != 0) {
                cout << -1 << '\n';
                return; 
            }
            continue; 
        }
        int c = mul(y[i], ksm(y[j], mod - 2));
        // x_i ^ d = c 
        // c != 0
        int mult = 1; 
        for(int t = 0; t <= 1e4; t++) {
            if(mult != c) ok[t] = 0; 
            Mul(mult, x[i]);
        }
    }
    int mx = -1;
    for(int i = 0; i <= 1e4; i++) {
        if(ok[i]) mx = max(mx, i);
    }
    if(mx > 2 * (n + 5)) {
        for(int i = 2 * (n + 5); i <= 1e4; i++)  
            if(ok[i]) { mx = i; break; }
    }
    // for(int i = 0;i <= 10; i++) cout << ok[i] << ' '; cout <<endl;
    // cout << mx << endl; 
    if(mx == -1) {
        cout << -1 << '\n';
        return;
    }
    int d = min(mx / 2 + 1, n);
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < d; j++) {
            int coef = j + j == mx ? ksm(x[i], j) : add(ksm(x[i], j), ksm(x[i], mx - j));
            a[i][j] = coef; 
        }
        a[i][d] = y[i];
    }

    // cout << d << ' ' << n <<  endl;

    for(int i = 0; i < d; i++) {
        int k = i; 
        while(a[k][i] == 0 && k < n) ++ k;
        if(k >= n) {
            continue; 
        }
        swap(a[i], a[k]);
        int iv = ksm(a[i][i], mod - 2);
        for(int j = 0; j < n; j++) 
        if(j != i && a[j][i]) {
            int c = mul(a[j][i], iv);
            for(int k = i; k <= d; k++)
                Dec(a[j][k], mul(a[i][k], c));
        }
    }
    for(int i = d; i < n; i++) 
    if(a[i][d]) {
        cout << -1 << '\n';
        return;
    }
    vector <int> ans (mx + 1);
    for(int i = 0; i < d; i++){
        int c = 0; 
        if(a[i][i] == 0) {
            if(a[i][d]) {
                cout << -1 << '\n';
                return;
            }
        }
        else {
            c = mul(a[i][d], ksm(a[i][i], mod - 2));
        }
        // cout << i << ' ' << c << endl;
        ans[i] = ans[mx - i] = c; 
    }
    if(ans[0] == 0) {
        fuckyou(d, mx, x, y);
        ans[0] = ans.back() = 1; 
        for(int i = 1; i < d; i++){
            int c = 0; 
            if(a[i][i] == 0) {
                if(a[i][d]) {
                    cout << -1 << '\n';
                    return;
                }
            }
            else {
                c = mul(a[i][d], ksm(a[i][i], mod - 2));
            }
            // cout << i << ' ' << c << endl;
            ans[i] = ans[mx - i] = c; 
        }
    }
    for(int i = 0; i <n; i++) {
        int c = 1; 
        int f = 0; 
        for(int w : ans) {
            Add(f, mul(c, w));
            Mul(c, x[i]);
        }
        if(f != y[i]) {
            cout << -1 << '\n';
            return;
        }
    }
    cout << ans.size()- 1 << '\n';
    for(int x : ans) cout << x << ' '; cout << '\n';
}
int main() {
    #ifdef zqj
    freopen("1.in","r",stdin);
    #endif
	std::ios::sync_with_stdio(false), cin.tie(0);
    cin >> T; 
    while(T--) Main();
    return 0; 
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3556kb

input:

8
2
0 1
2 4
3
0 1 2
2 10 36
4
0 1 2 3
1 4 9 16
5
0 1 2 3 4
1 25 961 14641 116281
2
2 500000005
5 375000004
2
2 500000005
5 375000004
2
2 500000005
1 2
3
2 500000005 3
5 375000004 10

output:

14
2 0 0 0 0 0 0 0 0 0 0 0 0 0 2 
16
2 999999998 14 0 0 0 0 0 0 0 0 0 0 0 14 999999998 2 
18
1 939060511 787273552 273665956 0 0 0 0 0 0 0 0 0 0 0 273665956 787273552 939060511 1 
20
1 617839688 772195627 752150047 357814672 0 0 0 0 0 0 0 0 0 0 0 357814672 752150047 772195627 617839688 1 
3
44444444...

result:

ok OK (8 test cases)

Test #2:

score: 0
Accepted
time: 15ms
memory: 4220kb

input:

10
100
24820 26839 18512 6097 25046 22372 21548 2359 17721 9732 16436 12710 14995 4112 17855 28268 28129 13501 23470 16561 8633 29875 13119 10835 15842 14515 5588 10553 28603 3849 12379 17065 15155 15079 26029 3003 2878 29555 3609 8886 2841 17696 9648 4533 5924 12557 25988 29061 26075 28447 28620 20...

output:

210
774456028 625715004 957967896 175821277 852996541 10114470 782435748 989965102 319424780 827347133 101863741 314025746 537701607 767915676 933495962 798304114 179271831 65987602 144529458 159483161 62987563 161499310 119004684 85458839 550227246 7009936 734949139 819388481 274605683 791103672 73...

result:

ok OK (10 test cases)

Test #3:

score: 0
Accepted
time: 847ms
memory: 7764kb

input:

1
1000
112 16069 28329 8759 23521 1674 11755 9574 19846 5769 27729 17604 3648 29441 25349 24311 6088 2549 6437 16310 25464 25775 20988 21334 3451 1098 26971 3856 28015 24136 18147 24690 4690 4517 14412 29017 14675 5027 18071 4428 29328 28568 12161 2780 23653 21472 21227 23968 1331 24977 7243 13552 6...

output:

2010
728070982 954752669 558415083 315019741 970436842 126394304 560523882 230643076 834954212 193825413 779994699 630115765 869047704 12768254 861278022 198296540 259070475 170754039 956459935 371871212 401440105 177062019 737991927 680424089 961289415 18470649 772273333 219956619 390601546 6918870...

result:

ok OK (1 test case)

Test #4:

score: 0
Accepted
time: 6ms
memory: 3600kb

input:

21
8
1000000008 191950673 311042534 341446923 351508511 730849637 837221839 949983050
2 199758730 296525790 620719636 271569769 48989015 768611306 77253955
8
1 6208459 29989762 187741303 265062278 393002943 957915451 986759042
2 603327752 901822821 349826936 933716294 123962049 672761843 702453404
8...

output:

8
1 0 0 0 0 0 0 0 1 
8
1 0 0 0 0 0 0 0 1 
8
1 0 0 0 0 0 0 0 1 
8
1 0 0 0 0 0 0 0 1 
8
1 0 0 0 0 0 0 0 1 
8
1 0 0 0 0 0 0 0 1 
8
1 0 0 0 0 0 0 0 1 
8
1 0 0 0 0 0 0 0 1 
8
1 0 0 0 0 0 0 0 1 
8
1 0 0 0 0 0 0 0 1 
8
1 0 0 0 0 0 0 0 1 
8
1 0 0 0 0 0 0 0 1 
8
1 0 0 0 0 0 0 0 1 
8
1 0 0 0 0 0 0 0 1 
8
1 0 ...

result:

ok OK (21 test cases)

Test #5:

score: 0
Accepted
time: 6ms
memory: 3532kb

input:

21
8
1000000008 82536156 95733833 173997609 176779824 454444312 524861364 586834996
4 841461190 384072747 954440743 152490383 894790857 441089967 851188211
8
1 62386922 117616238 344901582 692317472 798339321 934650757 967500526
4 923589217 91616771 328945919 250367604 465360899 562911768 673536418
...

output:

8
2 0 0 0 0 0 0 0 2 
8
2 0 0 0 0 0 0 0 2 
8
2 0 0 0 0 0 0 0 2 
8
2 0 0 0 0 0 0 0 2 
8
2 0 0 0 0 0 0 0 2 
8
2 0 0 0 0 0 0 0 2 
8
2 0 0 0 0 0 0 0 2 
8
2 0 0 0 0 0 0 0 2 
8
2 0 0 0 0 0 0 0 2 
8
2 0 0 0 0 0 0 0 2 
8
2 0 0 0 0 0 0 0 2 
8
2 0 0 0 0 0 0 0 2 
8
2 0 0 0 0 0 0 0 2 
8
2 0 0 0 0 0 0 0 2 
8
2 0 ...

result:

ok OK (21 test cases)

Test #6:

score: 0
Accepted
time: 7ms
memory: 3652kb

input:

21
9
72520483 109296160 328830012 427629800 496439117 517407888 723526448 875376334 984205010
513501309 405430695 97038420 80044690 244607478 420952403 730491956 655670564 934113242
9
1000000008 1 196696216 367187687 520201124 575456207 634588206 768006032 938587173
0 2 305160038 629977990 316645777...

output:

9
1 0 0 0 0 0 0 0 0 1 
9
1 0 0 0 0 0 0 0 0 1 
9
1 0 0 0 0 0 0 0 0 1 
9
1 0 0 0 0 0 0 0 0 1 
9
1 0 0 0 0 0 0 0 0 1 
9
1 0 0 0 0 0 0 0 0 1 
9
1 0 0 0 0 0 0 0 0 1 
9
1 0 0 0 0 0 0 0 0 1 
9
1 0 0 0 0 0 0 0 0 1 
9
1 0 0 0 0 0 0 0 0 1 
9
1 0 0 0 0 0 0 0 0 1 
9
1 0 0 0 0 0 0 0 0 1 
9
1 0 0 0 0 0 0 0 0 1 
9...

result:

ok OK (21 test cases)

Test #7:

score: 0
Accepted
time: 3ms
memory: 3672kb

input:

21
9
7776991 170135976 184357477 364912922 393159207 671848154 694727065 726096468 807558271
931408489 76229428 359286772 482810970 983371544 900415283 988630700 476855584 692102868
9
1000000008 1 254616697 350933937 613951686 792090796 806204674 896604470 996266271
0 4 296124300 133457045 889008814...

output:

9
2 0 0 0 0 0 0 0 0 2 
9
2 0 0 0 0 0 0 0 0 2 
9
2 0 0 0 0 0 0 0 0 2 
9
2 0 0 0 0 0 0 0 0 2 
9
2 0 0 0 0 0 0 0 0 2 
9
2 0 0 0 0 0 0 0 0 2 
9
2 0 0 0 0 0 0 0 0 2 
9
2 0 0 0 0 0 0 0 0 2 
9
2 0 0 0 0 0 0 0 0 2 
9
2 0 0 0 0 0 0 0 0 2 
9
2 0 0 0 0 0 0 0 0 2 
9
2 0 0 0 0 0 0 0 0 2 
9
2 0 0 0 0 0 0 0 0 2 
9...

result:

ok OK (21 test cases)

Test #8:

score: 0
Accepted
time: 6ms
memory: 3796kb

input:

21
8
1000000008 293188747 506560951 728885372 795956429 838708555 880755953 954756300
1 931650696 717763978 59630926 173745195 741697269 899703391 234180638
8
1 46322566 407158342 509723817 636040242 738500416 759476271 948754709
25 216101899 119160932 343194015 57776340 157262836 276807561 33982633...

output:

8
1 2 3 4 5 4 3 2 1 
8
1 2 3 4 5 4 3 2 1 
8
1 2 3 4 5 4 3 2 1 
8
1 2 3 4 5 4 3 2 1 
8
1 2 3 4 5 4 3 2 1 
8
1 2 3 4 5 4 3 2 1 
8
1 2 3 4 5 4 3 2 1 
8
1 2 3 4 5 4 3 2 1 
8
1 2 3 4 5 4 3 2 1 
8
1 2 3 4 5 4 3 2 1 
8
86218236 319601183 499436352 117551717 0 117551717 499436352 319601183 86218236 
8
1 2 3...

result:

ok OK (21 test cases)

Test #9:

score: 0
Accepted
time: 7ms
memory: 3576kb

input:

21
9
75218911 90366076 119101189 194246800 350541227 377200962 818012261 895921660 966585262
732955481 335776396 765729084 902489414 875573484 526286992 675327718 219549932 52753284
9
1000000008 1 121073903 135154924 206002108 693217175 709348851 800428289 922910175
0 30 110846868 369125846 78199011...

output:

9
1 2 3 4 5 5 4 3 2 1 
9
1 2 3 4 5 5 4 3 2 1 
9
1 2 3 4 5 5 4 3 2 1 
9
1 2 3 4 5 5 4 3 2 1 
9
1 2 3 4 5 5 4 3 2 1 
9
1 2 3 4 5 5 4 3 2 1 
9
1 2 3 4 5 5 4 3 2 1 
9
1 2 3 4 5 5 4 3 2 1 
9
1 2 3 4 5 5 4 3 2 1 
9
1 2 3 4 5 5 4 3 2 1 
9
191054574 377045428 945494516 352361894 0 0 352361894 945494516 3770...

result:

ok OK (21 test cases)

Test #10:

score: 0
Accepted
time: 8ms
memory: 3588kb

input:

21
10
1000000008 12260195 80754602 163716464 312829272 391611827 673741746 728563133 811628297 911803655
0 235646491 746092480 793242180 563675433 190413403 995430294 304276112 911389010 347436328
10
1 18892100 71240811 234644042 405445374 537145743 553798351 572060490 726412557 875107448
36 5419823...

output:

10
1 2 3 4 5 6 5 4 3 2 1 
10
1 2 3 4 5 6 5 4 3 2 1 
10
1 2 3 4 5 6 5 4 3 2 1 
10
1 2 3 4 5 6 5 4 3 2 1 
10
1 2 3 4 5 6 5 4 3 2 1 
10
1 2 3 4 5 6 5 4 3 2 1 
10
1 2 3 4 5 6 5 4 3 2 1 
10
1 2 3 4 5 6 5 4 3 2 1 
10
1 2 3 4 5 6 5 4 3 2 1 
10
1 2 3 4 5 6 5 4 3 2 1 
10
534095186 243838268 776205475 2839366...

result:

ok OK (21 test cases)

Test #11:

score: 0
Accepted
time: 13ms
memory: 3680kb

input:

21
15
102902010 104440499 141407938 254801315 302108881 375503505 483498247 569424584 631076513 674425009 710414727 748037505 787597696 897754981 913961979
750445007 723764181 522261770 384970598 466582584 399445938 304490242 178761561 97731177 711994375 711199040 109300424 225657734 328363283 70380...

output:

15
33 16 52 95 8 73 90 18 18 90 73 8 95 52 16 33 
15
33 16 52 95 8 73 90 18 18 90 73 8 95 52 16 33 
15
33 16 52 95 8 73 90 18 18 90 73 8 95 52 16 33 
15
33 16 52 95 8 73 90 18 18 90 73 8 95 52 16 33 
15
33 16 52 95 8 73 90 18 18 90 73 8 95 52 16 33 
15
33 16 52 95 8 73 90 18 18 90 73 8 95 52 16 33 
...

result:

ok OK (21 test cases)

Test #12:

score: 0
Accepted
time: 13ms
memory: 3564kb

input:

21
15
190238676 408903599 473934421 488621309 500829135 684814169 779979654 813377310 866962260 874120900 882901969 929880722 939256395 956209677 995016475
508631129 882709950 185145270 713649239 983567479 998524204 67708788 859291 999492696 130232703 891966111 441494490 332533393 703135760 64268444...

output:

15
18 81 81 16 58 48 71 18 18 71 48 58 16 81 81 18 
15
18 81 81 16 58 48 71 18 18 71 48 58 16 81 81 18 
15
18 81 81 16 58 48 71 18 18 71 48 58 16 81 81 18 
15
18 81 81 16 58 48 71 18 18 71 48 58 16 81 81 18 
15
18 81 81 16 58 48 71 18 18 71 48 58 16 81 81 18 
15
18 81 81 16 58 48 71 18 18 71 48 58 1...

result:

ok OK (21 test cases)

Test #13:

score: 0
Accepted
time: 17ms
memory: 3708kb

input:

21
19
26294376 70967317 135772333 163164758 190196450 190331407 263742305 289352143 294421555 384429498 404563902 421898751 501143739 558923946 663294565 687319026 754424225 840450575 911028598
260487108 14726161 703228508 619949324 417344016 544228071 953555078 345998205 557232429 191999681 4600517...

output:

19
96 23 54 68 33 62 84 100 26 18 18 26 100 84 62 33 68 54 23 96 
19
96 23 54 68 33 62 84 100 26 18 18 26 100 84 62 33 68 54 23 96 
19
96 23 54 68 33 62 84 100 26 18 18 26 100 84 62 33 68 54 23 96 
19
96 23 54 68 33 62 84 100 26 18 18 26 100 84 62 33 68 54 23 96 
19
96 23 54 68 33 62 84 100 26 18 18...

result:

ok OK (21 test cases)

Test #14:

score: 0
Accepted
time: 17ms
memory: 3904kb

input:

21
19
65433256 203120539 230619032 242339653 306408928 319892667 358753761 406955804 456020246 568215116 658002035 667809083 713920687 758560518 792203516 826915826 868910207 947222195 979951831
710093141 609738169 294821300 319884586 559809243 118163813 202242806 53046643 383830818 669518255 473578...

output:

19
28 54 85 91 50 30 65 94 27 59 59 27 94 65 30 50 91 85 54 28 
19
28 54 85 91 50 30 65 94 27 59 59 27 94 65 30 50 91 85 54 28 
19
28 54 85 91 50 30 65 94 27 59 59 27 94 65 30 50 91 85 54 28 
19
28 54 85 91 50 30 65 94 27 59 59 27 94 65 30 50 91 85 54 28 
19
28 54 85 91 50 30 65 94 27 59 59 27 94 65...

result:

ok OK (21 test cases)

Test #15:

score: 0
Accepted
time: 17ms
memory: 3644kb

input:

21
19
94730190 98406141 117177150 151885244 178905728 222257031 349187661 384666078 386234223 455425437 470266682 722168666 809818898 835948150 860749403 917499921 934399177 956526573 989637011
303082625 162132429 408192664 585973108 271970371 500211566 129010096 685239539 653965708 393652022 994078...

output:

19
50 91 94 78 86 62 66 32 36 9 9 36 32 66 62 86 78 94 91 50 
19
50 91 94 78 86 62 66 32 36 9 9 36 32 66 62 86 78 94 91 50 
19
50 91 94 78 86 62 66 32 36 9 9 36 32 66 62 86 78 94 91 50 
19
50 91 94 78 86 62 66 32 36 9 9 36 32 66 62 86 78 94 91 50 
19
50 91 94 78 86 62 66 32 36 9 9 36 32 66 62 86 78 ...

result:

ok OK (21 test cases)

Test #16:

score: 0
Accepted
time: 245ms
memory: 7560kb

input:

1
1000
1000000008 1163314 1725881 1859188 1927255 4342530 4578730 4746103 5123392 5506632 6230591 7566874 8086831 8637758 8890521 9139570 9965029 10373127 11912148 12953170 13042845 14260540 14474386 14647027 16719219 17143558 17206396 17598422 18621675 19116034 20547451 20737458 20849209 21344486 2...

output:

1000
79575517 935081668 622423990 636314169 144962938 141608677 45549202 341682233 778977652 453994042 201348892 869626487 36301614 222442438 810013863 682259528 307591988 74561654 865182948 602546620 503622727 592141979 822723137 146617557 257332795 208689416 598623744 418635055 602842188 790204312...

result:

ok OK (1 test case)

Test #17:

score: 0
Accepted
time: 241ms
memory: 7436kb

input:

1
1000
1000000008 119871 1389570 2707693 3843539 4475280 5503109 5549495 6795010 6881337 7004323 7784996 8817035 10260341 11888079 13315748 13575297 15614332 16009588 16062325 18552071 21109298 22056617 22934163 23508035 26281837 26986091 28233931 30097845 30596645 31675568 31809106 33878728 3514484...

output:

1000
257920431 967312002 754148659 599813599 198657247 4255073 205357317 162913793 13556407 971226952 712695563 911842439 13175537 473968002 101763748 450088031 263579202 561428812 121431558 219709408 20961014 664435919 698890141 769188921 150065990 731810438 847809296 773977042 752404641 279478033 ...

result:

ok OK (1 test case)

Test #18:

score: 0
Accepted
time: 245ms
memory: 7484kb

input:

1
1000
1000000008 995271 1043526 1569741 1930761 2373180 2655267 2894638 2972099 3570020 3727464 5293902 5459186 5592012 7143746 8038917 8302839 8742904 9597001 10871411 12265577 13229016 13866685 14178506 15546918 15659624 16069122 16352870 18441557 18941292 20438984 20579817 21493813 21999600 2332...

output:

1000
501255971 151947671 15379387 40432587 410380585 932847170 103225974 997584739 699852020 81269848 791519323 291398574 853646708 115657125 950691825 189433956 345218295 288555342 72048515 285844713 681878453 294292577 8612288 639872842 31042508 295420878 917443062 364745349 285266528 384039334 77...

result:

ok OK (1 test case)

Test #19:

score: 0
Accepted
time: 245ms
memory: 7480kb

input:

1
1000
1000000008 1930327 3748583 4732516 5761677 6524408 6953970 7673074 10215389 11599237 12891198 13367997 13443691 13480811 13814537 14242925 15448701 16851660 17860191 18576284 20750503 21287239 21772850 21931267 24200127 25706412 26674484 27001628 29416809 29417481 29696933 31919132 32361009 3...

output:

1001
699823936 960430970 466808260 367627308 887277552 499732708 58003325 935821729 881198281 683229062 394146056 948666944 496575363 513160824 135232708 173261431 893748371 655394711 673273739 669498825 499101800 423009350 521175573 587981065 326379400 944531590 308335268 639271 44519486 615086089 ...

result:

ok OK (1 test case)

Test #20:

score: 0
Accepted
time: 241ms
memory: 7504kb

input:

1
1000
1000000008 19655 1057867 1964843 2826271 6349908 7186978 9276122 11144062 11910084 12130477 13712767 15211331 15439577 17431103 22303206 22618031 23229606 24087435 25793057 27118960 28967939 29863766 32133950 32224454 32229860 32973855 34256429 35288465 35428105 37461019 37639895 38513911 385...

output:

1001
573812026 970487184 54079906 729269645 992385603 501033918 306099574 153165789 541020138 766193119 203842796 772546959 496714701 709509556 951619247 518823752 471110991 621012037 657844374 502179212 728932842 261499842 668183286 996484894 999548729 988097708 420921257 976214782 595681083 342543...

result:

ok OK (1 test case)

Test #21:

score: 0
Accepted
time: 244ms
memory: 7472kb

input:

1
1000
1000000008 2123473 2337497 2647785 2714138 4307445 4578311 5599173 6100322 7262671 8156005 8717048 9035468 9622351 10544976 11210969 11400533 12274760 14890507 14904020 15890200 16450429 16952722 17869294 18432568 19673198 20047804 23509418 25269660 25383779 25455144 27481698 29629773 2975078...

output:

1001
513696057 255459459 34960381 585089837 563151590 941609552 860262444 771558333 542837981 323880904 732877021 734091557 648720233 399209665 98926534 977997086 197644597 530934517 847651305 191957156 997005314 747477111 253493069 495320658 793627625 561865538 774502765 955347595 547130819 6505250...

result:

ok OK (1 test case)

Test #22:

score: 0
Accepted
time: 245ms
memory: 7564kb

input:

1
1000
1000000008 1 979543 1099673 2311834 2392336 3331761 5232856 5668529 5853303 8253217 9412317 10576558 12212409 12972885 13090359 13401142 14359459 14936104 15009169 15325450 15889761 17492445 18234479 18367419 19877788 20196006 21459330 21965618 22568003 24705386 24908023 27175324 27645592 280...

output:

1000
875040106 280699124 387142789 156289401 113119764 231698527 568134600 201705284 342325462 637892505 284662306 112090695 881317853 253818873 428126974 64848144 666946232 16046000 956700128 133611760 712665170 169086466 738922597 123194460 643106545 225300668 53441513 682019016 230413433 44626739...

result:

ok OK (1 test case)

Test #23:

score: 0
Accepted
time: 245ms
memory: 7776kb

input:

1
1000
1000000008 1 4002897 4074300 7807719 9221820 10062677 10247707 11793051 12076502 12383773 12850315 12909440 13699665 14669717 17364634 18334687 18488120 19251198 19327484 19351685 21227522 21473157 22536795 23445221 24786248 25276279 25516212 28760808 28997973 30065464 30458276 30865599 31228...

output:

1000
677490484 34172339 425915220 133272717 525533229 497270494 69060070 728759223 494156373 365238799 88340994 210682693 798755901 542372007 639584015 837271699 331303174 949443697 33441551 974757662 957173392 470387 508380030 823350231 934835917 767377046 942616254 653535532 114963770 69252437 578...

result:

ok OK (1 test case)

Test #24:

score: 0
Accepted
time: 241ms
memory: 7564kb

input:

1
1000
1000000008 1 1020644 5382771 5719073 6493197 7113938 7716494 9076935 9900713 12520522 13643863 14906033 15306765 15520944 16541433 17389045 18586011 19460259 20441544 21264034 21593776 23108118 25344994 26032018 29105874 29507267 31940778 32334657 32350077 32372905 33037067 33369145 34839406 ...

output:

1000
324400949 138285803 462932276 949332334 799317485 110578698 32991752 988658071 114579580 156197354 845254329 122647862 127745259 196929514 618844963 457937567 610323286 94294405 999013365 98901407 38224877 901618608 568697948 449088553 151609376 6909982 890319078 117709970 123579938 19357588 27...

result:

ok OK (1 test case)

Test #25:

score: 0
Accepted
time: 325ms
memory: 7508kb

input:

1
1000
459429 699878 1274783 1464867 2263572 2791534 3527960 4706024 6945270 7888629 8613660 8722107 8742188 9003703 10916249 11336542 12438667 12708870 14332440 16686112 16896938 17257014 19457577 20651141 22022600 23446548 24162091 25735242 27706189 28900858 29566281 31433967 32485062 32890720 330...

output:

1263
678735812 646564274 921167445 218016234 866558897 883420617 601128871 69254626 161066716 15593236 382293893 943358268 108436382 50505553 917307856 738916082 231023720 854513066 898950636 278679243 171272374 838711561 723502912 537669754 368349787 169138577 45266296 620297242 903436670 386166319...

result:

ok OK (1 test case)

Test #26:

score: 0
Accepted
time: 275ms
memory: 7560kb

input:

1
1000
539582 587787 823210 1838290 2968320 4763018 5452385 5759375 7499639 9268735 10059629 10426675 11252932 12083704 12772856 13255096 15256882 15398881 16556597 17094215 17824573 18058249 19298525 26461962 26540463 27208624 28878283 29337698 29508878 29750225 29816065 30030072 30700382 32937761 ...

output:

1107
232283190 618775730 303854058 959878404 558070533 46604810 152334547 432291478 886511389 671063710 281271370 724480861 719719954 993676022 151929466 253327162 380427531 936881565 507487103 585899159 925679409 501433253 430028877 101467195 278097109 83324989 426633821 930471735 642048986 9321610...

result:

ok OK (1 test case)

Test #27:

score: 0
Accepted
time: 398ms
memory: 7548kb

input:

1
1000
1400971 1525412 1895243 2886037 2935228 2953133 3648417 3848336 5149240 5665376 5805252 7627425 8262327 10896987 12584489 12609031 12775145 14176272 14403849 15101570 16731600 17493993 21095811 21269540 21865611 21996684 24659823 25151457 25644882 25843765 26226417 26507726 27698139 28396383 ...

output:

1461
271142442 503155898 459268216 627960257 259838969 262297498 7468124 11689642 565024763 339849727 95199975 46629873 24592757 346908825 287616392 182137163 619563629 480313705 301981317 371803699 260830238 218608015 382015764 573115904 293457793 901749979 723640940 73220728 251769420 529045494 80...

result:

ok OK (1 test case)

Test #28:

score: 0
Accepted
time: 340ms
memory: 7556kb

input:

1
1000
18257 2517136 2754522 3446997 3572234 3605609 4467547 4867328 5022683 6204397 7174270 8070365 8480158 9091902 10467727 11532430 11927584 13251677 13286612 13960248 14528228 14753170 15245960 16201420 17810446 17901664 19852933 19925622 20407743 20582958 20617713 21204188 21668313 22997268 234...

output:

1286
12772343 381314631 221382231 623172783 487595188 339384695 930801139 176913146 841153413 270292269 217693013 747771591 157597417 866529546 407912153 462621789 774380689 525484169 301882116 700642963 568369844 15386877 407895793 618328193 72135924 966438076 656616107 844039751 873639265 46104699...

result:

ok OK (1 test case)

Test #29:

score: 0
Accepted
time: 580ms
memory: 7708kb

input:

1
1000
996737 1536175 3101070 3644382 5170720 5787576 6266386 9714384 9834864 10495517 14090608 14642514 15311125 15793968 16310838 17244201 17316962 17585111 18479026 19707052 19839248 20025852 21127374 21714531 22326012 22524961 22528119 23538749 24774379 33421876 34041195 34456463 34531389 369802...

output:

1998
465267962 566575315 181228735 918993988 243380397 693606103 170639231 631271312 66441324 622412859 731625956 260174432 461276781 720031754 941720684 125876967 922320330 889619259 421018635 125873401 588288865 656210737 781962469 583354401 638798196 565135212 150278947 562698828 202938035 166245...

result:

ok OK (1 test case)

Test #30:

score: 0
Accepted
time: 598ms
memory: 7600kb

input:

1
1000
782165 818688 2385162 2504686 3746632 3810165 4398857 4905098 6244695 6489354 7213334 7653067 8091494 8142002 9238224 9638275 10692110 11290778 12619875 12886372 13068826 13740051 14689310 15762919 16498511 18469126 19480024 20070327 20364643 20406003 21855872 22034565 22721542 24506788 25382...

output:

5068
752683864 203408183 791862609 67627546 240395746 447517626 922362598 2662695 71183033 783807258 881268559 818028533 18045738 4002689 233453658 55374425 400291772 739596556 728103236 116759594 770016526 1425844 966072336 392639342 543748119 87913623 772671211 76624303 332734157 349392152 2349821...

result:

ok OK (1 test case)

Test #31:

score: 0
Accepted
time: 592ms
memory: 7744kb

input:

1
1000
1000000008 1 65747 867548 2909364 3566380 4307576 6281702 6849581 9004452 9421540 9652914 10782791 10827322 12408129 13657581 14320403 14966315 15286154 16077116 16306015 17456970 18103823 18576529 19640517 20120108 20974376 21146685 21691051 23155596 23483018 23795267 24773978 25191064 25465...

output:

3818
721900611 986603646 655080522 46902491 132373888 984140511 346174085 421392311 39965721 236154450 94756455 656592450 268517322 984713632 91317834 670678767 645146105 355692200 698923696 686415878 643641040 196488308 13941190 861792682 443186522 153850368 56789182 971610622 480307560 78053111 95...

result:

ok OK (1 test case)

Test #32:

score: 0
Accepted
time: 560ms
memory: 7552kb

input:

1
1000
1000000008 1 155415 1120795 5075090 5177841 5400240 5939545 6126832 6686481 6742156 7555095 8548302 8719620 8760748 9630584 10548298 11929056 11963247 13342890 13462765 14568520 14853846 15509357 15642103 19105061 19119816 22065447 23896409 25071710 25850281 26198108 27466856 29576775 2973926...

output:

1950
478252766 755836035 829300990 793816536 825789833 500229126 469280837 424603550 99319264 789538895 646481297 392197050 983655 143345856 686198397 179185712 176052509 338902888 72295543 514879951 296605990 198839233 570259295 43515999 678850481 782455066 909346900 867279032 445530612 760132277 1...

result:

ok OK (1 test case)

Test #33:

score: 0
Accepted
time: 602ms
memory: 7500kb

input:

1
1000
1000000008 1 3794823 3990160 4069010 7200609 7545237 7625903 7650923 7733012 8150039 10453187 11194942 11992704 12565148 12672036 14197425 14297429 14923010 15319779 15437211 16212886 17214909 19584436 19709541 19803867 20615123 20736540 21014631 22135416 22185505 22580462 22672626 23621938 2...

output:

5832
641075194 988703507 745723125 534591697 835079649 827673858 743138225 210407023 168997494 454881747 806608082 750998484 633861796 346420823 409427079 210451502 6975502 865024871 494097595 587355237 48543266 228730286 572270706 85330301 344091978 849694965 784691010 809000703 979659705 115870691...

result:

ok OK (1 test case)

Test #34:

score: 0
Accepted
time: 91ms
memory: 4044kb

input:

10
100
2293126 5942420 6337941 13099309 15116089 17067398 29529174 33256334 41013027 44923450 45673733 49287672 55640824 74354927 89743825 113199983 113795966 115263356 115429622 123843442 124728214 143038491 148791867 150711496 154560895 182479530 183537789 186924669 211790168 215889394 219573024 2...

output:

9997
738044725 565471393 710718676 678521638 830877592 922228800 273449312 137427104 14110832 805210060 191879400 366327131 17829501 376107773 657383064 816448347 271406806 89889815 185497133 501485357 638972745 293616317 603897045 778559561 182709562 450951716 945596569 24646979 586011537 560651469...

result:

ok OK (10 test cases)

Test #35:

score: 0
Accepted
time: 887ms
memory: 7512kb

input:

1
1000
1000000008 1 608809 2224418 2326580 2581597 2695175 4257301 4479801 4799707 5130361 5204849 6780675 6896748 7061506 7644954 7961444 8003206 8027106 9508105 9821035 10575547 10789292 10912576 12658630 14498860 15393382 15512131 15681489 16648049 16784819 17598541 18724939 19801366 20241696 204...

output:

10000
627555398 443687930 852594747 93030036 304449291 119697980 42814680 807850991 34617552 125070632 654010121 348470127 372930596 304000735 133008229 591845354 266928903 918715176 110229003 669616362 463532230 310609252 235108714 373446551 928981857 100881248 848529832 604390577 593085907 4147881...

result:

ok OK (1 test case)

Test #36:

score: -100
Wrong Answer
time: 30ms
memory: 3652kb

input:

42
1
0
0
5
0 1 2 3 4
0 1 2 3 4
17
1000000008 89972839 143164456 150216222 375988435 396176433 406913122 480521943 498414429 524078486 542182493 594307752 654089635 712922007 721980374 778983440 846984859
357907157 200159115 60068034 155124844 775922328 419112157 111254958 90487512 492415083 43233847...

output:

0
-1
3584
513120930 761462168 311030381 969877703 256414853 331672612 446331592 395621171 610689472 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

result:

wrong answer Integer parameter [name=array element] equals to -1, violates the range [0, 1000000008] (test case 1)