QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#188095#7233. Colored pathucup-team004AC ✓762ms5728kbC++202.1kb2023-09-25 14:41:412023-09-25 14:41:41

Judging History

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

  • [2023-09-25 14:41:41]
  • 评测
  • 测评结果:AC
  • 用时:762ms
  • 内存:5728kb
  • [2023-09-25 14:41:41]
  • 提交

answer

#include <bits/stdc++.h>

using i64 = long long;

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    
    int n, k, W;
    std::cin >> n >> k >> W;
    
    std::vector w(n, std::vector<int>(n)), c(n, std::vector<int>(n));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            std::cin >> w[i][j];
        }
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            std::cin >> c[i][j];
            c[i][j]--;
        }
    }
    
    int ans = k + 1;
    std::vector<std::array<int, 2>> path;
    for (int s = 0; s < (1 << k); s++) {
        if (__builtin_popcount(s) >= ans) {
            continue;
        }
        std::vector dp(n, std::vector<int>(n, W + 1));
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if (s >> c[i][j] & 1) {
                    if (!i && !j) {
                        dp[i][j] = w[i][j];
                    } else if (!i) {
                        dp[i][j] = dp[i][j - 1] + w[i][j];
                    } else if (!j) {
                        dp[i][j] = dp[i - 1][j] + w[i][j];
                    } else {
                        dp[i][j] = std::min(dp[i][j - 1], dp[i - 1][j]) + w[i][j];
                    }
                }
            }
        }
        if (dp[n - 1][n - 1] <= W) {
            ans = __builtin_popcount(s);
            path.clear();
            int x = n - 1, y = n - 1;
            while (true) {
                path.push_back({x, y});
                if (!x && !y) {
                    break;
                }
                if (!x || (y && dp[x][y - 1] < dp[x - 1][y])) {
                    y--;
                } else {
                    x--;
                }
            }
            std::reverse(path.begin(), path.end());
        }
    }
    if (ans > k) {
        std::cout << -1 << "\n";
        return 0;
    }
    std::cout << ans << "\n";
    for (int i = 0; i < n * 2 - 1; i++) {
        std::cout << path[i][0] + 1 << " " << path[i][1] + 1 << " \n"[i == n * 2 - 2];
    }
    
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3 3 10
1 1 1
5 3 1
5 3 1
1 2 3
2 2 1
3 3 2

output:

2
1 1 1 2 2 2 2 3 3 3

result:

ok n = 3, k = 3, W = 10

Test #2:

score: 0
Accepted
time: 0ms
memory: 3596kb

input:

1 1 1
2
1

output:

-1

result:

ok n = 1, k = 1, W = 1

Test #3:

score: 0
Accepted
time: 0ms
memory: 3620kb

input:

2 6 1000
10 10
1 10
1 1
2 1

output:

1
1 1 1 2 2 2

result:

ok n = 2, k = 6, W = 1000

Test #4:

score: 0
Accepted
time: 0ms
memory: 3628kb

input:

1 1 1
1
1

output:

1
1 1

result:

ok n = 1, k = 1, W = 1

Test #5:

score: 0
Accepted
time: 0ms
memory: 3624kb

input:

3 5 5
3 6 4
8 5 9
8 9 8
2 2 2
3 5 1
5 4 5

output:

-1

result:

ok n = 3, k = 5, W = 5

Test #6:

score: 0
Accepted
time: 0ms
memory: 3664kb

input:

3 9 4
1 1 1
1 1 1
1 1 1
1 9 3
6 3 7
6 1 7

output:

-1

result:

ok n = 3, k = 9, W = 4

Test #7:

score: 0
Accepted
time: 0ms
memory: 3856kb

input:

3 10 52
5 1 1
6 10 1
1 8 1
5 1 1
7 10 6
9 4 2

output:

4
1 1 1 2 1 3 2 3 3 3

result:

ok n = 3, k = 10, W = 52

Test #8:

score: 0
Accepted
time: 0ms
memory: 3788kb

input:

2 1 1
3 2
1 2
1 1
1 1

output:

-1

result:

ok n = 2, k = 1, W = 1

Test #9:

score: 0
Accepted
time: 0ms
memory: 3808kb

input:

3 9 577242701
2 8 4
93069 100700 8
103515 71104 86459
6 5 6
3 7 6
1 3 5

output:

2
1 1 1 2 1 3 2 3 3 3

result:

ok n = 3, k = 9, W = 577242701

Test #10:

score: 0
Accepted
time: 316ms
memory: 5424kb

input:

392 9 769077345
6 738409 549905 686694 654367 645778 579048 739427 649079 613869 754858 335007 420208 493900 523765 262885 438569 671847 689600 554166 767092 351644 779228 780891 730798 479799 550524 668660 350341 783080 615532 414923 706681 313717 606283 400552 785638 732092 645631 643460 622895 66...

output:

7
1 1 2 1 3 1 3 2 3 3 3 4 4 4 4 5 5 5 6 5 7 5 7 6 7 7 7 8 8 8 9 8 9 9 9 10 9 11 9 12 9 13 10 13 10 14 11 14 11 15 11 16 12 16 12 17 12 18 13 18 14 18 14 19 14 20 14 21 14 22 15 22 15 23 16 23 17 23 17 24 18 24 18 25 19 25 20 25 21 25 22 25 22 26 23 26 24 26 25 26 26 26 26 27 26 28 26 29 27 29 28 29 ...

result:

ok n = 392, k = 9, W = 769077345

Test #11:

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

input:

385 1 246860241
1 283293 312335 424037 419288 401174 427898 303232 412240 366902 345517 413407 426524 326470 147823 317597 421621 427818 419206 316486 334562 301081 408652 407405 404134 248412 421173 397119 362978 377182 367313 162006 177803 150834 283962 257395 403227 348910 428097 368952 268027 41...

output:

1
1 1 2 1 3 1 4 1 4 2 4 3 4 4 5 4 6 4 7 4 7 5 7 6 8 6 9 6 10 6 11 6 11 7 11 8 12 8 13 8 13 9 14 9 14 10 14 11 15 11 16 11 16 12 16 13 16 14 17 14 18 14 19 14 20 14 20 15 21 15 21 16 21 17 21 18 22 18 23 18 24 18 25 18 25 19 26 19 26 20 27 20 27 21 27 22 27 23 28 23 29 23 30 23 31 23 31 24 32 24 32 2...

result:

ok n = 385, k = 1, W = 246860241

Test #12:

score: 0
Accepted
time: 2ms
memory: 3972kb

input:

97 5 12056206
14150 4916 343153 408064 13844 444427 42451 48490 465541 97554 399573 193397 531104 558097 85224 197121 108772 68006 165031 303362 48786 221352 181599 168805 377792 239592 467227 542928 367101 52656 414815 81507 228158 374862 283919 227664 345124 473299 566751 384099 40824 168797 42693...

output:

-1

result:

ok n = 97, k = 5, W = 12056206

Test #13:

score: 0
Accepted
time: 26ms
memory: 4072kb

input:

203 7 56779886
520346 297254 38326 450278 488138 225867 34036 308983 317037 29141 428292 59158 81158 402430 207824 338831 491110 417978 445456 185068 465107 377141 136814 523848 467625 35661 43975 507689 421812 291421 317058 310411 399742 378964 190823 235651 161053 292885 188909 301748 104351 14067...

output:

7
1 1 2 1 2 2 2 3 3 3 4 3 5 3 6 3 6 4 7 4 7 5 8 5 8 6 9 6 9 7 9 8 10 8 10 9 10 10 11 10 11 11 12 11 13 11 13 12 14 12 15 12 16 12 16 13 16 14 17 14 17 15 18 15 19 15 19 16 19 17 20 17 20 18 21 18 22 18 23 18 23 19 23 20 23 21 23 22 24 22 25 22 25 23 25 24 25 25 26 25 27 25 28 25 29 25 29 26 30 26 31...

result:

ok n = 203, k = 7, W = 56779886

Test #14:

score: 0
Accepted
time: 4ms
memory: 4048kb

input:

205 2 38714523
327513 239486 233604 328114 151132 334977 85104 353518 217959 276826 174254 75301 30945 57443 329643 147417 100776 160376 192982 138801 382402 331863 29060 101550 112997 147837 59464 328037 174627 65206 380296 38619 225547 216733 136285 75477 140902 15546 189071 288240 145247 78570 34...

output:

-1

result:

ok n = 205, k = 2, W = 38714523

Test #15:

score: 0
Accepted
time: 5ms
memory: 4180kb

input:

222 3 226506694
2 2 37097 11359 35765 38256 40295 20557 18951 38602 32515 27515 27916 39374 33755 29299 29192 24103 22237 38124 34790 37340 40068 37710 26869 27569 35819 35073 36447 31556 30650 10783 39549 32135 32341 16980 34207 39207 36348 27408 36203 22985 39299 32271 14189 33442 39792 37914 3002...

output:

3
1 1 1 2 2 2 3 2 4 2 4 3 4 4 5 4 6 4 6 5 7 5 8 5 9 5 9 6 9 7 10 7 11 7 11 8 12 8 13 8 14 8 15 8 16 8 17 8 18 8 19 8 20 8 21 8 21 9 22 9 22 10 23 10 24 10 25 10 25 11 26 11 27 11 27 12 27 13 28 13 28 14 29 14 29 15 29 16 30 16 31 16 31 17 31 18 31 19 31 20 31 21 31 22 31 23 31 24 31 25 32 25 33 25 3...

result:

ok n = 222, k = 3, W = 226506694

Test #16:

score: 0
Accepted
time: 1ms
memory: 3964kb

input:

115 1 718900512
1 23835 19330 35303 22288 18265 36376 24242 32587 23472 18430 36247 33174 34666 27333 36121 29931 21441 22776 35367 33593 26992 32809 31663 30711 30251 18408 30326 34908 30518 26733 35274 30461 29028 34757 36084 34962 32998 35161 28650 26244 35647 29336 19503 18362 32524 24890 30146 ...

output:

1
1 1 2 1 3 1 3 2 3 3 3 4 3 5 3 6 3 7 3 8 4 8 4 9 5 9 5 10 5 11 5 12 5 13 6 13 7 13 7 14 7 15 8 15 9 15 10 15 11 15 12 15 13 15 14 15 14 16 15 16 15 17 15 18 16 18 16 19 17 19 18 19 18 20 19 20 19 21 19 22 19 23 20 23 21 23 21 24 21 25 22 25 23 25 23 26 23 27 23 28 24 28 24 29 25 29 25 30 26 30 27 3...

result:

ok n = 115, k = 1, W = 718900512

Test #17:

score: 0
Accepted
time: 9ms
memory: 3800kb

input:

118 7 19862909
34097 35044 781602 442856 359425 855070 744831 677425 18237 716526 110015 377175 567310 483154 866632 65306 46839 524442 439173 852856 157150 226964 226864 793865 17176 836798 623219 49756 703604 300040 39184 29543 823541 105755 725838 180136 174190 140469 402885 740285 685059 145344 ...

output:

-1

result:

ok n = 118, k = 7, W = 19862909

Test #18:

score: 0
Accepted
time: 2ms
memory: 4316kb

input:

190 4 748654630
1 1 2 2 3 1 4 704047 488172 661273 680960 461790 590683 707252 266308 640158 623653 462562 622079 618349 407360 677312 712854 429509 666245 602889 654352 646054 611298 716101 674228 697004 597254 703900 662305 715951 606309 540350 658217 666164 511600 555636 398433 692220 620873 7154...

output:

3
1 1 1 2 1 3 1 4 1 5 1 6 1 7 2 7 2 8 2 9 3 9 3 10 3 11 3 12 4 12 4 13 4 14 4 15 4 16 4 17 5 17 6 17 7 17 7 18 8 18 9 18 9 19 10 19 11 19 11 20 11 21 11 22 11 23 11 24 11 25 12 25 12 26 12 27 12 28 13 28 13 29 13 30 14 30 14 31 15 31 15 32 16 32 16 33 17 33 17 34 17 35 17 36 17 37 18 37 19 37 20 37 ...

result:

ok n = 190, k = 4, W = 748654630

Test #19:

score: 0
Accepted
time: 229ms
memory: 4464kb

input:

327 9 91174764
139898 391573 547170 9777 125523 536166 600359 593224 238444 441914 57021 572028 394926 493557 343291 402130 621029 127933 344717 47781 652065 379941 475874 500786 108776 102747 3573 472840 145423 532827 442496 487027 419026 288845 255765 585577 47932 326072 442829 557994 149576 49006...

output:

-1

result:

ok n = 327, k = 9, W = 91174764

Test #20:

score: 0
Accepted
time: 0ms
memory: 3688kb

input:

100 5 545689346
3 490934 567555 550146 511389 503585 618309 553471 537308 361754 615217 493876 548255 570391 625134 480552 245671 542381 576857 488193 424606 531449 523004 617720 622108 582083 463604 407859 539969 524466 408015 547123 484723 400785 392517 515389 401662 622700 486646 607068 614003 40...

output:

2
1 1 2 1 3 1 4 1 5 1 6 1 7 1 7 2 7 3 8 3 9 3 9 4 9 5 9 6 10 6 11 6 11 7 11 8 12 8 12 9 12 10 12 11 12 12 12 13 13 13 13 14 14 14 14 15 15 15 15 16 16 16 16 17 16 18 17 18 17 19 18 19 19 19 19 20 20 20 21 20 21 21 21 22 21 23 21 24 21 25 21 26 21 27 22 27 22 28 23 28 24 28 24 29 24 30 25 30 25 31 26...

result:

ok n = 100, k = 5, W = 545689346

Test #21:

score: 0
Accepted
time: 698ms
memory: 5316kb

input:

400 10 4253
10 848399 705451 856580 888529 762693 851071 559741 958306 556629 871624 863336 977576 721880 849683 900889 838202 497651 979528 765775 567493 794245 779805 968857 900682 658556 774191 360297 579548 971163 764057 877339 900108 863696 877384 910879 993359 989973 875363 912112 702809 94056...

output:

-1

result:

ok n = 400, k = 10, W = 4253

Test #22:

score: 0
Accepted
time: 689ms
memory: 4892kb

input:

400 10 4392
2 732229 852111 492252 788899 983046 903531 743068 882948 959159 999578 968230 861218 931634 860244 539972 860696 976037 784068 838825 867886 503481 302183 573738 938220 894323 942998 680746 430039 844797 643423 680249 832392 929033 779848 819371 963465 456000 160413 424122 783672 938898...

output:

-1

result:

ok n = 400, k = 10, W = 4392

Test #23:

score: 0
Accepted
time: 646ms
memory: 5540kb

input:

400 10 321654611
603934 623466 740837 430315 692770 201290 259621 465810 850312 371874 555151 970155 569290 939640 836670 610030 57028 760533 320112 150678 135028 838726 484934 32482 686849 16220 66632 608214 869425 415852 732319 474296 263792 857552 911642 999379 54544 15397 644650 739831 779972 81...

output:

8
1 1 1 2 2 2 2 3 3 3 3 4 4 4 5 4 6 4 6 5 6 6 6 7 7 7 8 7 8 8 9 8 9 9 9 10 9 11 9 12 10 12 11 12 12 12 13 12 14 12 15 12 15 13 15 14 15 15 15 16 15 17 15 18 16 18 16 19 16 20 16 21 17 21 17 22 17 23 18 23 18 24 18 25 19 25 20 25 21 25 22 25 22 26 23 26 24 26 24 27 25 27 26 27 26 28 27 28 27 29 28 29...

result:

ok n = 400, k = 10, W = 321654611

Test #24:

score: 0
Accepted
time: 700ms
memory: 4880kb

input:

400 10 4580
3 661786 944546 869905 918877 626160 988277 787021 971241 844260 733685 948209 984742 458035 804187 952326 860714 944544 666048 961864 823106 891241 920027 747375 992904 744350 879941 887917 977297 962243 676974 970188 860305 894396 633946 966716 488886 501055 643111 931655 796874 716647...

output:

-1

result:

ok n = 400, k = 10, W = 4580

Test #25:

score: 0
Accepted
time: 705ms
memory: 4884kb

input:

400 10 4395
9 983914 729808 830216 945603 782651 960806 756870 912387 415732 824689 867977 895961 912898 885985 573318 924713 799512 918725 865622 505747 916872 923762 974745 776244 832941 982687 684514 867336 718518 938342 685967 602164 515008 586078 990004 903625 946336 748962 896781 916010 918083...

output:

-1

result:

ok n = 400, k = 10, W = 4395

Test #26:

score: 0
Accepted
time: 702ms
memory: 4932kb

input:

400 10 4565
8 924978 717977 822578 930024 917812 792704 645609 624064 794371 642484 790781 839407 874289 790758 891803 526459 372183 870994 730322 704355 975818 899205 420442 851348 756730 776003 741650 912843 899206 904522 954371 604460 465470 853452 575119 973540 847955 808327 927794 767168 885771...

output:

-1

result:

ok n = 400, k = 10, W = 4565

Test #27:

score: 0
Accepted
time: 738ms
memory: 4984kb

input:

400 10 4320
6 2 890531 854842 789660 947685 683572 828776 818099 931171 638009 576711 930777 364160 742769 940401 700239 643357 609649 862860 909083 992977 409635 981873 732778 691726 614330 861084 725819 546165 571377 936740 875792 972577 973830 831071 966999 825659 826552 516280 379369 997224 6492...

output:

-1

result:

ok n = 400, k = 10, W = 4320

Test #28:

score: 0
Accepted
time: 683ms
memory: 5296kb

input:

400 10 4496
3 841172 747572 719355 746569 932921 774796 913769 619117 931075 973501 815550 774126 845008 970122 722209 678913 982100 746382 917580 996827 978766 738957 749840 832079 743590 943755 977509 712957 620400 933830 936848 756883 961803 603610 889455 797275 728790 730699 820922 847495 886936...

output:

-1

result:

ok n = 400, k = 10, W = 4496

Test #29:

score: 0
Accepted
time: 762ms
memory: 5292kb

input:

400 10 4412
10 6 459312 612213 634558 709434 847725 829290 251871 963150 795894 899297 592042 664822 769923 746058 912385 674370 953545 946881 859523 947960 786320 894265 966080 514967 899333 990893 885638 883157 960668 923881 975490 768561 746152 449238 747022 901656 757992 881918 993889 945392 709...

output:

-1

result:

ok n = 400, k = 10, W = 4412

Test #30:

score: 0
Accepted
time: 671ms
memory: 5316kb

input:

400 10 4400
7 876413 856937 816346 765996 924138 710246 370407 736245 991933 967076 968911 750046 927763 539046 857518 757192 588601 672852 943524 817961 564777 827598 813297 579323 578862 825833 365457 904657 653719 689151 742253 755057 967449 952591 373129 977236 898138 927236 887037 930804 946248...

output:

-1

result:

ok n = 400, k = 10, W = 4400

Test #31:

score: 0
Accepted
time: 11ms
memory: 5728kb

input:

400 10 1000000000
1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 10...

output:

1
1 1 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 10 1 11 1 12 1 13 1 14 1 15 1 16 1 17 1 18 1 19 1 20 1 21 1 22 1 23 1 24 1 25 1 26 1 27 1 28 1 29 1 30 1 31 1 32 1 33 1 34 1 35 1 36 1 37 1 38 1 39 1 40 1 41 1 42 1 43 1 44 1 45 1 46 1 47 1 48 1 49 1 50 1 51 1 52 1 53 1 54 1 55 1 56 1 57 1 58 1 59 1 60 1 61 1 ...

result:

ok n = 400, k = 10, W = 1000000000

Test #32:

score: 0
Accepted
time: 694ms
memory: 4984kb

input:

400 10 11638639
377148 971449 999817 813774 823159 323562 383120 766089 577123 591611 486902 946552 314554 109431 630144 529279 430059 277885 821095 431576 326809 278658 871831 261457 685978 630349 463218 557771 227129 19834 5835 315772 970933 741240 212012 757742 579392 233163 262800 898750 456832 ...

output:

-1

result:

ok n = 400, k = 10, W = 11638639

Test #33:

score: 0
Accepted
time: 698ms
memory: 4884kb

input:

400 10 112058988
176076 335 855640 154163 343861 451430 306639 135778 786520 105705 68824 212070 527912 247698 383929 15641 892315 805308 534716 471673 627950 748072 115500 76839 210910 434745 910363 280811 344176 930168 919007 391278 943210 656 64528 827902 23128 558739 625356 585934 341384 714867 ...

output:

-1

result:

ok n = 400, k = 10, W = 112058988

Test #34:

score: 0
Accepted
time: 728ms
memory: 4984kb

input:

400 10 176201199
16719 103782 181266 135177 515583 600079 42087 717436 657603 484675 279880 975028 867391 87473 553748 308456 703213 217148 281278 623365 886683 856635 87694 897837 290666 276087 765024 781683 139856 400943 370723 651936 347351 329815 441370 816882 820252 693716 68895 193624 428176 8...

output:

-1

result:

ok n = 400, k = 10, W = 176201199

Test #35:

score: 0
Accepted
time: 622ms
memory: 5604kb

input:

400 10 309442370
266807 937261 892386 44850 182943 515569 194095 142445 711484 209281 460097 32479 687720 692629 361268 574866 827873 884201 112904 51220 245896 815226 333603 930484 928677 592141 820362 628809 811489 294952 367660 608811 972682 801303 630167 62200 227091 803432 800257 38225 917073 4...

output:

7
1 1 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 10 1 11 1 12 2 12 2 13 2 14 2 15 2 16 2 17 2 18 3 18 3 19 4 19 5 19 6 19 7 19 7 20 8 20 8 21 9 21 9 22 10 22 10 23 11 23 11 24 12 24 12 25 12 26 12 27 13 27 13 28 13 29 13 30 13 31 13 32 13 33 13 34 13 35 13 36 13 37 13 38 13 39 13 40 13 41 13 42 13 43 13 44 1...

result:

ok n = 400, k = 10, W = 309442370

Test #36:

score: 0
Accepted
time: 715ms
memory: 4984kb

input:

400 10 142110232
785795 833013 949499 976404 716099 237198 943116 44506 60199 916351 680952 47082 617704 762050 676832 844601 436147 393765 740571 107278 868391 534025 707892 500549 965082 547492 382313 428749 527765 432960 110126 622314 541843 78394 508200 780083 401478 259779 560627 350613 719442 ...

output:

-1

result:

ok n = 400, k = 10, W = 142110232

Test #37:

score: 0
Accepted
time: 722ms
memory: 4988kb

input:

400 10 68424394
559126 395676 419657 870837 473410 642322 206106 906031 62213 312311 429136 418795 599593 978441 932196 386729 406523 85353 581079 274636 126093 935647 30826 654429 48755 692308 490407 401031 995910 36950 147542 110620 210660 987608 563528 383822 653677 256879 819664 979191 23496 248...

output:

-1

result:

ok n = 400, k = 10, W = 68424394

Test #38:

score: 0
Accepted
time: 703ms
memory: 4892kb

input:

400 10 76669888
824000 817802 158233 548245 111339 539547 956799 15102 4161 139753 250455 398787 334709 632352 237551 331963 13839 209890 580776 754929 923114 808130 321784 972707 472567 440906 159401 893893 873849 783605 985880 235772 670920 533237 621750 966500 715406 513454 378122 869195 581516 4...

output:

-1

result:

ok n = 400, k = 10, W = 76669888

Test #39:

score: 0
Accepted
time: 681ms
memory: 4908kb

input:

400 10 38388410
450042 570134 116136 105268 698398 211179 913222 414410 50723 443008 408305 107295 988042 824355 408074 438707 925878 979302 870425 253128 806191 950877 963079 138149 74403 28513 930082 781461 941152 523472 202909 137513 525340 485066 728013 814322 571693 24182 498349 650184 644945 3...

output:

-1

result:

ok n = 400, k = 10, W = 38388410

Test #40:

score: 0
Accepted
time: 715ms
memory: 4928kb

input:

400 10 158676719
27615 964220 323855 465599 413444 572759 326186 516076 944742 309168 889166 643961 881883 515087 533149 340871 261870 346448 464810 764748 252638 190242 577086 638802 229148 321417 948759 303797 987729 180892 414948 636905 553493 381063 56330 861938 306489 247691 980898 799147 98931...

output:

-1

result:

ok n = 400, k = 10, W = 158676719

Test #41:

score: 0
Accepted
time: 608ms
memory: 5568kb

input:

400 10 367365450
914061 660492 922704 869269 802244 133659 228823 18073 702299 498858 139147 485163 958223 801695 584127 493203 912613 102594 593414 427066 491363 147070 415932 785646 591317 62821 322555 432610 615689 579305 983079 996203 201363 644324 819491 921348 233034 871569 520922 819659 67098...

output:

7
1 1 2 1 2 2 2 3 2 4 3 4 3 5 3 6 3 7 3 8 3 9 3 10 3 11 3 12 4 12 5 12 6 12 7 12 8 12 9 12 10 12 11 12 11 13 11 14 12 14 13 14 14 14 15 14 15 15 16 15 16 16 16 17 17 17 18 17 19 17 19 18 19 19 19 20 19 21 19 22 20 22 20 23 21 23 22 23 23 23 23 24 24 24 25 24 25 25 25 26 26 26 26 27 27 27 27 28 28 28...

result:

ok n = 400, k = 10, W = 367365450

Test #42:

score: 0
Accepted
time: 730ms
memory: 5512kb

input:

400 10 229158484
73663 264906 616173 829930 9793 521417 423659 402684 418114 449915 127248 514391 626150 690411 658741 897617 659488 312472 73612 378931 983290 439731 287064 153912 569043 875365 328688 190226 138460 638406 65665 745253 309914 732327 856265 20234 547816 796873 324061 413838 734257 27...

output:

9
1 1 2 1 2 2 2 3 3 3 4 3 5 3 6 3 7 3 8 3 9 3 10 3 11 3 12 3 13 3 14 3 14 4 14 5 15 5 16 5 17 5 18 5 18 6 19 6 20 6 21 6 21 7 22 7 23 7 23 8 23 9 24 9 24 10 24 11 24 12 25 12 26 12 26 13 27 13 28 13 28 14 29 14 30 14 31 14 32 14 32 15 32 16 33 16 33 17 34 17 34 18 35 18 36 18 37 18 38 18 39 18 39 19...

result:

ok n = 400, k = 10, W = 229158484

Test #43:

score: 0
Accepted
time: 668ms
memory: 5296kb

input:

400 10 84072655
461156 905215 937042 534253 746177 954454 178891 250739 386380 845675 23625 581463 853773 504066 207060 5296 177133 639713 466586 288278 480314 614292 673577 350247 596455 672681 703607 280836 278793 706164 317658 925841 488091 751692 398928 111864 707643 958924 466425 115303 389739 ...

output:

-1

result:

ok n = 400, k = 10, W = 84072655

Test #44:

score: 0
Accepted
time: 687ms
memory: 4960kb

input:

400 10 57194890
359467 789654 78636 235751 976169 851340 516443 716816 955922 570757 207528 589403 844857 340724 232722 67639 190952 48099 690698 863527 548762 351217 851193 521093 395521 249231 767352 454586 501057 395714 994069 532360 98547 314212 309973 930688 934435 192035 985964 310924 463507 7...

output:

-1

result:

ok n = 400, k = 10, W = 57194890

Test #45:

score: 0
Accepted
time: 712ms
memory: 4980kb

input:

400 10 196260946
739908 142953 838993 320555 250459 125933 703880 811314 584240 231239 681055 881127 925850 109920 289888 175221 546353 563334 705939 457582 736979 221356 113930 963140 927137 82727 600598 226065 219775 98866 138319 340240 20375 341995 921487 737825 168214 708500 570807 657097 46830 ...

output:

-1

result:

ok n = 400, k = 10, W = 196260946

Test #46:

score: 0
Accepted
time: 689ms
memory: 4884kb

input:

400 10 129459266
401122 805719 524566 430652 384336 758157 308835 242214 610944 941601 301960 5644 631457 231580 136844 754274 372855 927612 411407 474893 552601 207152 283522 159017 265908 660253 699626 840963 308102 485980 325217 352544 934692 867065 275541 754164 567220 212725 568392 12716 438964...

output:

-1

result:

ok n = 400, k = 10, W = 129459266

Test #47:

score: 0
Accepted
time: 660ms
memory: 4904kb

input:

400 10 186997668
599244 524354 838990 397668 319004 490249 899585 938365 853625 678724 61395 596958 672145 385676 495698 361683 93874 159679 35569 772842 450386 148477 494533 189239 331335 474605 429769 652497 776015 475958 631003 896595 943754 548998 444477 689884 651067 14735 132181 376271 516362 ...

output:

-1

result:

ok n = 400, k = 10, W = 186997668

Test #48:

score: 0
Accepted
time: 669ms
memory: 4984kb

input:

400 10 118410230
345500 996305 690695 428034 671843 261285 701960 134811 585670 485835 943441 170165 571321 875078 84765 805421 409377 245678 128862 331445 681818 698797 428536 479634 120370 789700 742276 681630 272171 641671 155855 477639 303420 405149 850840 753743 765969 573889 265877 14026 89248...

output:

-1

result:

ok n = 400, k = 10, W = 118410230

Test #49:

score: 0
Accepted
time: 675ms
memory: 5568kb

input:

400 10 250147882
371072 219845 136610 586299 27674 853388 970541 802118 426396 389229 898535 859358 203026 818231 5675 757494 389450 776735 559066 343459 645848 492030 725658 484320 226387 688655 642709 941195 675670 963506 454774 516326 83520 589676 524272 545879 650484 306277 676278 298472 841178 ...

output:

9
1 1 2 1 2 2 3 2 4 2 5 2 5 3 5 4 5 5 6 5 6 6 6 7 7 7 8 7 8 8 8 9 9 9 10 9 11 9 12 9 12 10 12 11 12 12 13 12 13 13 13 14 13 15 13 16 13 17 14 17 15 17 15 18 16 18 16 19 16 20 17 20 17 21 18 21 19 21 19 22 19 23 19 24 19 25 19 26 20 26 21 26 21 27 21 28 21 29 22 29 23 29 23 30 24 30 25 30 26 30 27 30...

result:

ok n = 400, k = 10, W = 250147882

Test #50:

score: 0
Accepted
time: 681ms
memory: 4992kb

input:

400 10 185524921
576289 247712 428619 536816 365487 446144 155318 479558 517086 722576 790358 235327 808139 55541 651714 561165 548520 73355 957542 694036 54010 941664 298883 361773 773851 444406 843434 357220 291193 927557 799365 64123 130581 250934 485454 177189 784774 552489 222934 551691 91252 7...

output:

-1

result:

ok n = 400, k = 10, W = 185524921

Test #51:

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

input:

5 1 15
1 100 1 1 1
1 100 1 100 1
1 100 1 100 1
1 100 1 100 1
1 1 1 100 1
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1

output:

-1

result:

ok n = 5, k = 1, W = 15

Test #52:

score: 0
Accepted
time: 199ms
memory: 5504kb

input:

400 10 798999201
999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 999...

output:

10
1 1 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 10 1 11 1 12 1 13 1 14 1 15 1 16 1 17 1 18 1 19 1 20 1 21 1 22 1 23 1 24 1 25 1 26 1 27 1 28 1 29 1 30 1 31 1 32 1 33 1 34 1 35 1 36 1 37 1 38 1 39 1 40 1 41 1 42 1 43 1 44 1 45 1 46 1 47 1 48 1 49 1 50 1 51 1 52 1 53 1 54 1 55 1 56 1 57 1 58 1 59 1 60 1 61 1...

result:

ok n = 400, k = 10, W = 798999201

Test #53:

score: 0
Accepted
time: 253ms
memory: 5464kb

input:

391 10 780999219
999999 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000...

output:

10
1 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 10 1 11 1 12 1 13 1 14 1 15 1 16 1 17 1 18 1 19 1 20 1 21 1 22 1 23 1 24 1 25 1 26 1 27 1 28 1 29 1 30 1 31 1 32 1 33 1 34 1 35 1 36 1 37 1 38 1 39 1 40 1 41 1 42 1 43 1 44 1 45 1 46 1 47 1 48 1 49 1 50 1 51 1 52 1 53 1 54 1 55 1 56 1 57 1 58 1 59 1 60 1 61 1 6...

result:

ok n = 391, k = 10, W = 780999219