QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#21591 | #2848. 城市地铁规划 | Mr_Eight# | WA | 69ms | 66044kb | C++14 | 2.8kb | 2022-03-07 15:51:42 | 2022-05-08 03:40:50 |
Judging History
answer
//#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <math.h>
#include <cmath>
#include <algorithm>
#include <climits>
#include <functional>
#include <cstring>
#include <string>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <complex>
#include <random>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define itn int
#define nit int
#define ll long long
#define ms multiset
#define F(i,a,b) for(register int i=a,i##end=b;i<=i##end;++i)
#define UF(i,a,b) for(register int i=a,i##end=b;i>=i##end;--i)
#define re register
#define ri re int
#define il inline
#define pii pair<int,int>
#define cp complex<double>
//#pra gma G CC opti mize(3)
using namespace std;
using std::bitset;
//using namespace __gnu_pbds;
const double Pi=acos(-1);
namespace fastIO {
template<class T>
inline void read(T &x) {
x=0;
bool fu=0;
char ch=0;
while(ch>'9'||ch<'0') {
ch=getchar();
if(ch=='-')fu=1;
}
while(ch<='9'&&ch>='0') x=(x*10-48+ch),ch=getchar();
if(fu)x=-x;
}
inline int read() {
int x=0;
bool fu=0;
char ch=0;
while(ch>'9'||ch<'0') {
ch=getchar();
if(ch=='-')fu=1;
}
while(ch<='9'&&ch>='0') x=(x*10-48+ch),ch=getchar();
return fu?-x:x;
}
template<class T,class... Args>
inline void read(T& t,Args&... args) {
read(t);
read(args...);
}
char _n_u_m_[40];
template<class T>
inline void write(T x ) {
if(x==0){
putchar('0');
return;
}
T tmp = x > 0 ? x : -x ;
if( x < 0 ) putchar('-') ;
register int cnt = 0 ;
while( tmp > 0 ) {
_n_u_m_[ cnt ++ ] = tmp % 10 + '0' ;
tmp /= 10 ;
}
while( cnt > 0 ) putchar(_n_u_m_[ -- cnt ]) ;
}
template<class T>
inline void write(T x ,char ch) {
write(x);
putchar(ch);
}
}
using namespace fastIO;
int f[3002][3002],v[3002],g[3002][3002];
int n,k,a[3002];
inline bool ck(int &x,int y){
if(x<y){
x=y;
return true;
}
return false;
}
inline void solve(int l,int r,int num,int to){
if(num==1&&to){
write(r,' ');
write(to,'\n');
}
if(l==r)return;
int pos=g[r-l+1][num];
if(num==1)solve(l,r-1,pos,r);
else{
solve(r-pos+1,r,1,to);
solve(l,r-pos,num-1,to);
}
}
int main(){
cin>>n>>k;
F(i,0,k){
read(a[i]);
}
F(i,1,n){
UF(j,k,0){
v[i]=(1ll*v[i]*i+a[j])%59393;
}
}
if(n==1){
cout<<0<<" "<<v[0]<<endl;
return 0;
}
memset(f,-0x3f,sizeof(f));
f[1][1]=v[1];
F(i,1,n){
F(j,1,i)if(ck(f[i][1],f[i-1][j]+v[j+(i!=n)]))g[i][1]=j;
F(j,2,i){
F(k,1,i/j){
if(ck(f[i][j],f[k][1]+f[i-k][j-1]))g[i][j]=k;
}
}
}
write(n-1,' ');
write(f[n][1],'\n');
solve(1,n,1,0);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 14ms
memory: 39564kb
input:
63 7 4 50 14 48 33 13 44 24
output:
62 992106 62 63 61 62 60 61 59 61 58 59 57 59 56 57 55 57 54 55 53 55 52 53 51 53 50 51 49 51 48 49 47 49 46 47 45 47 44 45 43 45 42 43 41 43 40 41 39 41 38 39 37 39 36 37 35 37 34 35 33 35 32 33 31 33 30 31 29 31 28 29 27 29 26 27 25 27 24 25 23 25 22 23 21 23 20 21 19 21 18 19 17 19 16 17 15 17 14...
result:
ok
Test #2:
score: 0
Accepted
time: 4ms
memory: 39728kb
input:
208 7 23 28 14 16 46 28 26 28
output:
207 3317121 207 208 206 207 205 207 204 205 203 205 202 203 201 203 200 201 199 201 198 199 197 199 196 197 195 197 194 195 193 195 192 193 191 193 190 191 189 191 188 189 187 189 186 187 185 187 184 185 183 185 182 183 181 183 180 181 179 181 178 179 177 179 176 177 175 177 174 175 173 175 172 173 ...
result:
ok
Test #3:
score: 0
Accepted
time: 69ms
memory: 66044kb
input:
2928 3 27 20 7 29
output:
2927 13889888 2927 2928 2926 2927 2925 2927 2924 2927 2923 2927 2922 2927 2921 2927 2920 2927 2919 2927 2918 2927 2917 2927 2916 2927 2915 2916 2914 2916 2913 2916 2912 2916 2911 2916 2910 2916 2909 2916 2908 2916 2907 2916 2906 2916 2905 2916 2904 2905 2903 2905 2902 2905 2901 2905 2900 2905 2899 2...
result:
ok
Test #4:
score: 0
Accepted
time: 4ms
memory: 41752kb
input:
320 3 46 42 15 15
output:
319 1260206 319 320 318 319 317 319 316 319 315 319 314 319 313 319 312 319 311 319 310 319 309 319 308 309 307 309 306 309 305 309 304 309 303 309 302 309 301 309 300 309 299 309 298 309 297 309 296 309 295 309 294 295 293 295 292 295 291 295 290 295 289 295 288 295 287 295 286 295 285 295 284 295 ...
result:
ok
Test #5:
score: 0
Accepted
time: 13ms
memory: 42432kb
input:
380 5 41 27 8 3 31 0
output:
379 3140470 379 380 378 379 377 379 376 379 375 376 374 376 373 376 372 376 371 376 370 371 369 371 368 371 367 371 366 371 365 366 364 366 363 366 362 366 361 366 360 361 359 361 358 361 357 361 356 361 355 356 354 356 353 356 352 356 351 356 350 351 349 351 348 351 347 351 346 351 345 346 344 346 ...
result:
ok
Test #6:
score: 0
Accepted
time: 4ms
memory: 41448kb
input:
365 5 35 20 24 29 3 25
output:
364 3508667 364 365 363 364 362 364 361 364 360 361 359 361 358 361 357 358 356 358 355 358 354 355 353 355 352 355 351 352 350 352 349 352 348 349 347 349 346 349 345 346 344 346 343 346 342 343 341 343 340 343 339 340 338 340 337 340 336 337 335 337 334 337 333 334 332 334 331 334 330 331 329 331 ...
result:
ok
Test #7:
score: 0
Accepted
time: 4ms
memory: 40468kb
input:
318 6 4 44 46 6 37 14 49
output:
317 6799456 317 318 316 317 315 317 314 315 313 315 312 313 311 313 310 311 309 311 308 309 307 309 306 307 305 307 304 305 303 305 302 303 301 303 300 301 299 301 298 299 297 299 296 297 295 297 294 295 293 295 292 293 291 293 290 291 289 291 288 289 287 289 286 287 285 287 284 285 283 285 282 283 ...
result:
ok
Test #8:
score: 0
Accepted
time: 4ms
memory: 42240kb
input:
416 6 30 23 4 16 45 32 19
output:
415 5383994 415 416 414 415 413 415 412 413 411 413 410 411 409 411 408 409 407 409 406 407 405 407 404 405 403 405 402 403 401 403 400 401 399 401 398 399 397 399 396 397 395 397 394 395 393 395 392 393 391 393 390 391 389 391 388 389 387 389 386 387 385 387 384 385 383 385 382 383 381 383 380 381 ...
result:
ok
Test #9:
score: 0
Accepted
time: 12ms
memory: 42772kb
input:
572 5 15 27 5 18 3 46
output:
571 9396678 571 572 570 571 569 571 568 571 567 568 566 568 565 568 564 565 563 565 562 565 561 562 560 562 559 562 558 559 557 559 556 559 555 556 554 556 553 556 552 553 551 553 550 553 549 550 548 550 547 550 546 547 545 547 544 547 543 544 542 544 541 544 540 541 539 541 538 541 537 538 536 538 ...
result:
ok
Test #10:
score: 0
Accepted
time: 4ms
memory: 41948kb
input:
531 8 20 13 35 27 41 43 36 25 5
output:
530 9024252 530 531 529 530 528 529 527 529 526 529 525 526 524 526 523 526 522 523 521 523 520 523 519 520 518 520 517 520 516 517 515 517 514 517 513 514 512 514 511 514 510 511 509 511 508 511 507 508 506 508 505 508 504 505 503 505 502 505 501 502 500 502 499 502 498 499 497 499 496 499 495 496 ...
result:
ok
Test #11:
score: 0
Accepted
time: 7ms
memory: 41376kb
input:
487 10 29 29 40 45 5 16 40 47 47 2 14
output:
486 18026623 486 487 485 486 484 485 483 484 482 483 481 482 480 481 479 480 478 479 477 478 476 477 475 476 474 475 473 474 472 473 471 472 470 471 469 470 468 469 467 468 466 467 465 466 464 465 463 464 462 463 461 462 460 461 459 460 458 459 457 458 456 457 455 456 454 455 453 454 452 453 451 452...
result:
ok
Test #12:
score: 0
Accepted
time: 7ms
memory: 42984kb
input:
584 7 10 27 29 8 32 43 26 3
output:
583 11437238 583 584 582 583 581 583 580 581 579 581 578 579 577 579 576 577 575 577 574 575 573 575 572 573 571 573 570 571 569 571 568 569 567 569 566 567 565 567 564 565 563 565 562 563 561 563 560 561 559 561 558 559 557 559 556 557 555 557 554 555 553 555 552 553 551 553 550 551 549 551 548 549...
result:
ok
Test #13:
score: 0
Accepted
time: 4ms
memory: 39880kb
input:
59 4 48 16 9 42 21
output:
58 422967 58 59 57 58 56 58 55 58 54 58 53 58 52 53 51 53 50 53 49 53 48 53 47 48 46 48 45 48 44 48 43 48 42 43 41 43 40 43 39 43 38 43 37 38 36 38 35 38 34 38 33 38 32 33 31 33 30 33 29 33 28 33 27 28 26 28 25 28 24 28 23 28 22 23 21 23 20 23 19 23 18 23 17 18 16 18 15 18 14 18 13 18 12 13 11 13 10...
result:
ok
Test #14:
score: 0
Accepted
time: 8ms
memory: 42276kb
input:
561 3 22 31 17 49
output:
560 3223790 560 561 559 560 558 559 557 559 556 559 555 559 554 559 553 559 552 559 551 559 550 559 549 550 548 550 547 550 546 550 545 550 544 550 543 550 542 550 541 550 540 541 539 541 538 541 537 541 536 541 535 541 534 541 533 541 532 541 531 532 530 532 529 532 528 532 527 532 526 532 525 532 ...
result:
ok
Test #15:
score: 0
Accepted
time: 8ms
memory: 43492kb
input:
629 6 26 31 41 32 13 39 41
output:
628 13149156 628 629 627 628 626 627 625 627 624 625 623 625 622 623 621 623 620 621 619 621 618 619 617 619 616 617 615 617 614 615 613 615 612 613 611 613 610 611 609 611 608 609 607 609 606 607 605 607 604 605 603 605 602 603 601 603 600 601 599 601 598 599 597 599 596 597 595 597 594 595 593 595...
result:
ok
Test #16:
score: 0
Accepted
time: 4ms
memory: 42264kb
input:
616 3 38 48 27 2
output:
615 1394108 615 616 614 615 613 615 612 615 611 615 610 615 609 615 608 615 607 615 606 615 605 615 604 615 603 615 602 615 601 615 600 601 599 601 598 601 597 601 596 601 595 601 594 601 593 601 592 601 591 601 590 601 589 601 588 601 587 601 586 601 585 601 584 601 583 601 582 601 581 601 580 601 ...
result:
ok
Test #17:
score: 0
Accepted
time: 3ms
memory: 42900kb
input:
744 2 49 45 50
output:
743 1425426 743 744 742 743 741 743 740 743 739 743 738 743 737 743 736 743 735 743 734 743 733 743 732 743 731 743 730 743 729 743 728 743 727 743 726 727 725 727 724 727 723 727 722 727 721 727 720 727 719 727 718 727 717 727 716 727 715 727 714 727 713 727 712 727 711 727 710 727 709 727 708 727 ...
result:
ok
Test #18:
score: 0
Accepted
time: 7ms
memory: 43220kb
input:
629 7 27 18 48 24 37 38 6 3
output:
628 9258317 628 629 627 628 626 627 625 627 624 625 623 625 622 625 621 625 620 621 619 621 618 621 617 621 616 617 615 617 614 617 613 617 612 613 611 613 610 613 609 613 608 609 607 609 606 609 605 609 604 605 603 605 602 605 601 605 600 601 599 601 598 601 597 601 596 597 595 597 594 597 593 597 ...
result:
ok
Test #19:
score: 0
Accepted
time: 12ms
memory: 42028kb
input:
602 8 17 25 14 13 2 16 23 24 44
output:
601 9947756 601 602 600 601 599 600 598 599 597 598 596 597 595 596 594 595 593 594 592 593 591 592 590 591 589 590 588 589 587 588 586 587 585 586 584 585 583 584 582 583 581 582 580 581 579 580 578 579 577 578 576 577 575 576 574 575 573 574 572 573 571 572 570 571 569 570 568 569 567 568 566 567 ...
result:
ok
Test #20:
score: 0
Accepted
time: 13ms
memory: 45552kb
input:
900 2 9 13 12
output:
899 787522 899 900 898 899 897 899 896 899 895 899 894 899 893 899 892 899 891 899 890 899 889 899 888 899 887 899 886 899 885 899 884 885 883 885 882 885 881 885 880 885 879 885 878 885 877 885 876 885 875 885 874 885 873 885 872 885 871 885 870 885 869 885 868 885 867 885 866 885 865 885 864 885 8...
result:
ok
Test #21:
score: 0
Accepted
time: 14ms
memory: 43732kb
input:
839 7 12 12 28 33 35 29 14 17
output:
838 24516016 838 839 837 838 836 837 835 837 834 835 833 835 832 833 831 833 830 831 829 831 828 829 827 829 826 827 825 827 824 825 823 825 822 823 821 823 820 821 819 821 818 819 817 819 816 817 815 817 814 815 813 815 812 813 811 813 810 811 809 811 808 809 807 809 806 807 805 807 804 805 803 805...
result:
ok
Test #22:
score: 0
Accepted
time: 4ms
memory: 43892kb
input:
768 7 27 3 40 6 39 9 48 31
output:
767 18960055 767 768 766 767 765 767 764 765 763 765 762 763 761 763 760 761 759 761 758 759 757 759 756 757 755 757 754 755 753 755 752 753 751 753 750 751 749 751 748 749 747 749 746 747 745 747 744 745 743 745 742 743 741 743 740 741 739 741 738 739 737 739 736 737 735 737 734 735 733 735 732 733...
result:
ok
Test #23:
score: 0
Accepted
time: 2ms
memory: 44128kb
input:
783 3 25 19 31 45
output:
782 4263811 782 783 781 782 780 782 779 782 778 782 777 782 776 782 775 782 774 775 773 775 772 775 771 775 770 775 769 775 768 775 767 775 766 775 765 766 764 766 763 766 762 766 761 766 760 766 759 766 758 766 757 766 756 757 755 757 754 757 753 757 752 757 751 757 750 757 749 757 748 757 747 748 ...
result:
ok
Test #24:
score: 0
Accepted
time: 13ms
memory: 40408kb
input:
2 4 24 9 31 45 15
output:
1 248 1 2
result:
ok
Test #25:
score: 0
Accepted
time: 4ms
memory: 45060kb
input:
792 5 28 40 21 32 44 11
output:
791 6695732 791 792 790 791 789 790 788 790 787 790 786 787 785 787 784 787 783 784 782 784 781 784 780 781 779 781 778 781 777 778 776 778 775 778 774 775 773 775 772 775 771 772 770 772 769 772 768 769 767 769 766 769 765 766 764 766 763 766 762 763 761 763 760 763 759 760 758 760 757 760 756 757 ...
result:
ok
Test #26:
score: 0
Accepted
time: 2ms
memory: 45256kb
input:
939 5 35 7 31 40 25 28
output:
938 12031060 938 939 937 938 936 938 935 938 934 935 933 935 932 935 931 932 930 932 929 932 928 929 927 929 926 929 925 926 924 926 923 926 922 923 921 923 920 923 919 920 918 920 917 920 916 917 915 917 914 917 913 914 912 914 911 914 910 911 909 911 908 911 907 908 906 908 905 908 904 905 903 905...
result:
ok
Test #27:
score: 0
Accepted
time: 8ms
memory: 45484kb
input:
924 6 30 26 21 8 12 42 26
output:
923 14203740 923 924 922 923 921 923 920 921 919 921 918 919 917 919 916 917 915 917 914 915 913 915 912 913 911 913 910 911 909 911 908 909 907 909 906 907 905 907 904 905 903 905 902 903 901 903 900 901 899 901 898 899 897 899 896 897 895 897 894 895 893 895 892 893 891 893 890 891 889 891 888 889...
result:
ok
Test #28:
score: 0
Accepted
time: 8ms
memory: 45360kb
input:
902 8 8 48 35 25 32 28 21 2 44
output:
901 13244886 901 902 900 901 899 900 898 899 897 898 896 897 895 896 894 895 893 894 892 893 891 892 890 891 889 890 888 889 887 888 886 887 885 886 884 885 883 884 882 883 881 882 880 881 879 880 878 879 877 878 876 877 875 876 874 875 873 874 872 873 871 872 870 871 869 870 868 869 867 868 866 867...
result:
ok
Test #29:
score: 0
Accepted
time: 4ms
memory: 45876kb
input:
1021 2 11 16 14
output:
1020 977447 1020 1021 1019 1020 1018 1020 1017 1020 1016 1020 1015 1020 1014 1020 1013 1020 1012 1020 1011 1020 1010 1020 1009 1020 1008 1009 1007 1009 1006 1009 1005 1009 1004 1009 1003 1009 1002 1009 1001 1009 1000 1009 999 1009 998 1009 997 1009 996 1009 995 1009 994 1009 993 1009 992 1009 991 10...
result:
ok
Test #30:
score: -100
Wrong Answer
time: 3ms
memory: 5728kb
input:
1 9 18 7 32 20 44 12 15 38 14 43
output:
0 0
result:
wrong answer