QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#480259#956. 后缀排序crazy_sea#100 ✓390ms26248kbC++14896b2024-07-16 11:46:242024-07-16 11:46:24

Judging History

你现在查看的是测评时间为 2024-07-16 11:46:24 的历史记录

  • [2024-11-28 22:34:50]
  • 管理员手动重测本题所有获得100分的提交记录
  • 测评结果:100
  • 用时:460ms
  • 内存:28160kb
  • [2024-11-28 21:51:46]
  • 管理员手动重测本题所有提交记录
  • 测评结果:100
  • 用时:508ms
  • 内存:26252kb
  • [2024-07-16 11:46:24]
  • 评测
  • 测评结果:100
  • 用时:390ms
  • 内存:26248kb
  • [2024-07-16 11:46:24]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N=1e6+10;
char s[N];
int n,t[N],sa[N],rk[N],a[N],b[N],p[N];
bool chk(int x,int y,int k){return rk[x]==rk[y]&&rk[x+k]==rk[y+k];}
int main()
{
	scanf("%s",s+1);
	n=strlen(s+1);
	int m=128;
	for(int i=1;i<=n;i++) t[rk[i]=s[i]]++;
	for(int i=1;i<=m;i++) t[i]+=t[i-1];
	for(int i=n;i;i--) sa[t[rk[i]]--]=i;
	for(int i=0;i<=m;i++) t[i]=0;
	if(n==1) rk[1]=1;
	for(int x=1;x<=n;x<<=1)
	{
		int len=0;
		for(int j=1;j<=n;j++) t[rk[j]]++;
		for(int j=1;j<=m;j++) t[j]+=t[j-1];
		for(int j=n;j>n-x;j--) p[++len]=j;
		for(int j=1;j<=n;j++) if(sa[j]>x) p[++len]=sa[j]-x;
		for(int j=n;j;j--) sa[t[rk[p[j]]]--]=p[j];
		for(int j=1;j<=m;j++) t[j]=0;
		b[sa[1]]=m=1;
		for(int j=2;j<=n;j++) b[sa[j]]=(chk(sa[j],sa[j-1],x)?m:++m);
		for(int j=1;j<=n;j++) rk[j]=b[j];
	}
	for(int i=1;i<=n;i++) printf("%d%c",sa[i]," \n"[i==n]);
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 10
Accepted
time: 0ms
memory: 12064kb

input:

5Q2K2Pz3vL3K5NFJ48Lj77MYpTRo8dq25fS26BUl59i16a9kuxuFu4d477vz0057gB00218hv69C2Wz7Fk5pMt153uVAq3F3rK0T

output:

67 61 68 62 99 87 44 70 69 32 36 3 5 77 94 11 96 89 8 56 17 54 88 63 41 13 1 33 83 74 37 45 21 57 80 22 64 58 18 29 71 75 42 47 92 66 38 76 95 15 81 52 16 98 4 12 10 19 23 85 14 6 2 27 35 100 26 39 91 78 24 46 55 30 34 65 72 43 20 82 48 40 28 84 25 31 93 97 86 53 51 90 49 73 9 59 50 60 7 79

result:

ok 100 numbers

Test #2:

score: 10
Accepted
time: 2ms
memory: 14188kb

input:

5Q2K2Pz3vL3K5NFJ48Lj77MYpTRo8dq25fS26BUl59i16a9kuxuFu4d477vz0057gB00218hv69C2Wz7Fk5pMt153uVAq3F3rK0T6x537w3ME8JK5N1K1H2mQ25fhwSXF71PN7pq33144n03i7668I924792U1O299jyC066396197Az5XUG4436L1gj5ltv0K591DJu2Fb8UGV54Uz7B1E37583565h6XKWb011m429JT119a5Aa0nGP880GI7691f8bs920iq4725A9W7VYVLJrM7Y3KHhdO6562B34gqZ...

output:

67 834 61 984 435 230 932 390 302 791 991 68 961 835 551 887 814 423 143 749 541 62 166 729 910 465 764 663 382 361 252 193 481 996 99 366 668 700 265 321 985 246 843 804 737 807 854 851 436 813 239 231 543 927 848 680 139 767 744 317 87 560 724 44 775 783 800 718 70 172 657 445 240 401 499 756 794 ...

result:

ok 1000 numbers

Test #3:

score: 10
Accepted
time: 2ms
memory: 12060kb

input:

5Q2K2Pz3vL3K5NFJ48Lj77MYpTRo8dq25fS26BUl59i16a9kuxuFu4d477vz0057gB00218hv69C2Wz7Fk5pMt153uVAq3F3rK0T6x537w3ME8JK5N1K1H2mQ25fhwSXF71PN7pq33144n03i7668I924792U1O299jyC066396197Az5XUG4436L1gj5ltv0K591DJu2Fb8UGV54Uz7B1E37583565h6XKWb011m429JT119a5Aa0nGP880GI7691f8bs920iq4725A9W7VYVLJrM7Y3KHhdO6562B34gqZ...

output:

67 834 61 984 435 230 932 390 302 791 991 68 961 835 551 887 814 423 143 749 541 62 166 729 910 465 764 663 382 361 252 193 481 996 99 366 668 700 265 321 985 246 843 804 737 807 854 851 436 813 239 231 543 927 848 680 139 767 744 317 87 560 724 44 775 783 800 718 70 172 657 445 240 401 499 756 794 ...

result:

ok 1000 numbers

Test #4:

score: 10
Accepted
time: 3ms
memory: 11992kb

input:

5Q2K2Pz3vL3K5NFJ48Lj77MYpTRo8dq25fS26BUl59i16a9kuxuFu4d477vz0057gB00218hv69C2Wz7Fk5pMt153uVAq3F3rK0T6x537w3ME8JK5N1K1H2mQ25fhwSXF71PN7pq33144n03i7668I924792U1O299jyC066396197Az5XUG4436L1gj5ltv0K591DJu2Fb8UGV54Uz7B1E37583565h6XKWb011m429JT119a5Aa0nGP880GI7691f8bs920iq4725A9W7VYVLJrM7Y3KHhdO6562B34gqZ...

output:

1215 67 7665 834 1826 7511 5919 3053 61 3312 6300 2679 1594 4074 9549 3994 1216 9041 7309 984 435 9744 230 1246 7870 2136 1083 932 390 3023 6221 2107 5961 302 791 991 3530 3946 4059 9751 2781 68 5494 7719 5334 7001 8839 3525 2856 2330 4033 1358 7135 8275 7042 2156 1353 5431 1327 8878 1858 7963 6070 ...

result:

ok 10000 numbers

Test #5:

score: 10
Accepted
time: 0ms
memory: 12052kb

input:

5Q2K2Pz3vL3K5NFJ48Lj77MYpTRo8dq25fS26BUl59i16a9kuxuFu4d477vz0057gB00218hv69C2Wz7Fk5pMt153uVAq3F3rK0T6x537w3ME8JK5N1K1H2mQ25fhwSXF71PN7pq33144n03i7668I924792U1O299jyC066396197Az5XUG4436L1gj5ltv0K591DJu2Fb8UGV54Uz7B1E37583565h6XKWb011m429JT119a5Aa0nGP880GI7691f8bs920iq4725A9W7VYVLJrM7Y3KHhdO6562B34gqZ...

output:

1215 67 7665 834 1826 7511 5919 3053 61 3312 6300 2679 1594 4074 9549 3994 1216 9041 7309 984 435 9744 230 1246 7870 2136 1083 932 390 3023 6221 2107 5961 302 791 991 3530 3946 4059 9751 2781 68 5494 7719 5334 7001 8839 3525 2856 2330 4033 1358 7135 8275 7042 2156 1353 5431 1327 8878 1858 7963 6070 ...

result:

ok 10000 numbers

Test #6:

score: 10
Accepted
time: 16ms
memory: 14500kb

input:

5Q2K2Pz3vL3K5NFJ48Lj77MYpTRo8dq25fS26BUl59i16a9kuxuFu4d477vz0057gB00218hv69C2Wz7Fk5pMt153uVAq3F3rK0T6x537w3ME8JK5N1K1H2mQ25fhwSXF71PN7pq33144n03i7668I924792U1O299jyC066396197Az5XUG4436L1gj5ltv0K591DJu2Fb8UGV54Uz7B1E37583565h6XKWb011m429JT119a5Aa0nGP880GI7691f8bs920iq4725A9W7VYVLJrM7Y3KHhdO6562B34gqZ...

output:

68971 23766 16236 84001 1215 26527 48751 32248 30140 72030 28767 92557 43162 24259 25407 54376 75855 19511 13517 67 53747 87651 14066 82459 71782 86029 43950 97897 47837 7665 68972 13510 834 32328 99196 78406 83547 81136 78839 87297 70893 11242 63345 90340 71195 48534 1826 26208 37790 94754 94139 42...

result:

ok 100000 numbers

Test #7:

score: 10
Accepted
time: 17ms
memory: 16388kb

input:

5Q2K2Pz3vL3K5NFJ48Lj77MYpTRo8dq25fS26BUl59i16a9kuxuFu4d477vz0057gB00218hv69C2Wz7Fk5pMt153uVAq3F3rK0T6x537w3ME8JK5N1K1H2mQ25fhwSXF71PN7pq33144n03i7668I924792U1O299jyC066396197Az5XUG4436L1gj5ltv0K591DJu2Fb8UGV54Uz7B1E37583565h6XKWb011m429JT119a5Aa0nGP880GI7691f8bs920iq4725A9W7VYVLJrM7Y3KHhdO6562B34gqZ...

output:

68971 23766 16236 84001 1215 26527 48751 32248 30140 72030 28767 92557 43162 24259 25407 54376 75855 19511 13517 67 53747 87651 14066 82459 71782 86029 43950 97897 47837 7665 68972 13510 834 32328 99196 78406 83547 81136 78839 87297 70893 11242 63345 90340 71195 48534 1826 26208 37790 94754 94139 42...

result:

ok 100000 numbers

Test #8:

score: 10
Accepted
time: 390ms
memory: 26248kb

input:

5Q2K2Pz3vL3K5NFJ48Lj77MYpTRo8dq25fS26BUl59i16a9kuxuFu4d477vz0057gB00218hv69C2Wz7Fk5pMt153uVAq3F3rK0T6x537w3ME8JK5N1K1H2mQ25fhwSXF71PN7pq33144n03i7668I924792U1O299jyC066396197Az5XUG4436L1gj5ltv0K591DJu2Fb8UGV54Uz7B1E37583565h6XKWb011m429JT119a5Aa0nGP880GI7691f8bs920iq4725A9W7VYVLJrM7Y3KHhdO6562B34gqZ...

output:

702437 852879 412799 162791 928297 702438 622989 983054 642549 261095 377477 552453 679737 416887 68971 278337 315744 160869 995837 186829 681266 327995 277671 818964 351970 838627 883654 348201 749182 652099 725131 290366 677064 877296 529774 170877 594821 447484 471517 964025 208565 255655 507795 ...

result:

ok 1000000 numbers

Test #9:

score: 10
Accepted
time: 383ms
memory: 26248kb

input:

eX8N69cLH4G7P8QDy5156Hx8m0VN4sH9t0C4MoGd0cN51dgGXJL73z6N20CLISd0X1nhFKvdXa5q2nWCMjmkM30Es5tAZ5L6c306nT2oQfrf2Zt510ofV35o9TJ5T811LtWMrZyh18MX9qw72109C5be766Bd3qLO4xD1DDe479eUE5987M7D8Y895fT1W8v76E093n631511T0UVJh29806570CW9b5Is483605N8654a5VWS08UxTJE91bpt43f74q0hkMd1Z9a23he6MAE3kG0u5127tc3h5f8y39AjD9...

output:

38596 639028 437546 648133 351969 176869 229309 186806 709078 462998 756773 229120 449395 203997 694956 387238 859598 730372 206962 594419 304109 865880 486633 87868 144959 580819 713317 427972 274476 938366 686801 782959 62962 785003 847579 57996 600405 148706 255431 125253 470979 965679 925624 274...

result:

ok 1000000 numbers

Test #10:

score: 10
Accepted
time: 378ms
memory: 26176kb

input:

8585jh1f9l3466C87O58gfT7sPR0Vw2kdl75l450z1aiD294Q98lb2h4eWb77E8O987OzoJ1617c76ewlDF6G35z0p51g7X53r9642d72kX96JaJra72G832G87vyY42UVx980GB137H85hg47CMn3o1249D6aaGPCr8z3f0pptL20TH1X6ec0vg1zJ22kw3DF96bCo708qr75G8n59J3v7m2164IX1N84D8O10byi86jR44lQ7U9ccl490428AkdTY6830E7VVf5705W86IJ0MvY94653hx18on20J44890...

output:

73767 216802 73768 690419 604466 827813 587942 736629 238255 331491 654128 797636 599436 533392 476737 533131 558055 861637 813759 428079 371878 574078 216803 151038 556486 238788 165007 289648 324429 383245 331977 951071 341486 342866 674032 50992 680691 104594 382352 956720 401592 251525 523118 51...

result:

ok 1000000 numbers