QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#482696#4224. 串yqh20250 346ms187492kbC++141.5kb2024-07-17 20:46:492024-07-17 20:46:51

Judging History

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

  • [2024-07-17 20:46:51]
  • 评测
  • 测评结果:0
  • 用时:346ms
  • 内存:187492kb
  • [2024-07-17 20:46:49]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N=5e5+10;
int n;
namespace SAM{
	struct hzzdj{
		int len,father,son[30];
	}hz[N<<1];
	int tot,last;
	int mi[N<<1],siz[N];
	vector<int>E[N<<1];
	void init(){
		for(int i=0;i<=tot;i++){
			hz[i].len=hz[i].father=0;
			memset(hz[i].son,0,sizeof(hz[i].son));
			siz[i]=0;mi[i]=N+10;
			E[i].clear();
		}
		tot=0;last=0;hz[0].father=-1;
	}
	void insert(char ch,int i){
		int cha=ch-'a',p=last;
		int cur=++tot;hz[cur].len=hz[p].len+1;
		mi[cur]=i;siz[cur]=1;
		while(p!=-1&&!hz[p].son[cha]){
			hz[p].son[cha]=cur;
			p=hz[p].father;
		}
		if(p==-1)hz[cur].father=0;
		else{
			int q=hz[p].son[cha];
			if(hz[q].len==hz[p].len+1)hz[cur].father=q;
			else{
				int nq=++tot;hz[nq].len=hz[p].len+1;
				hz[nq].father=hz[q].father;
				hz[q].father=hz[cur].father=nq;
				memcpy(hz[nq].son,hz[q].son,sizeof(hz[q].son));
				while(p!=-1&&hz[p].son[cha]==q){
					hz[p].son[cha]=nq;;
					p=hz[p].father;
				}
			}
		}
		last=cur;
	}
	void dfs(int u){
		for(int v:E[u]){
			dfs(v);
			mi[u]=min(mi[u],mi[v]);
			siz[u]+=siz[v];
		}
	}
	int sol(){
		for(int i=1;i<=tot;i++)E[hz[i].father].push_back(i);
		dfs(0);
		int ans=n/2;
		for(int i=1;i<=tot;i++){
			if(siz[i]>=2){
				ans=max(ans,hz[i].len+(n-mi[i])/2);
			}
		}
		return ans;
	}
}
char ch[N];
void sol(){
	SAM::init();
	scanf("%s",ch+1);n=strlen(ch+1);
	for(int i=1;i<=n;i++)SAM::insert(ch[i],i);
	printf("%d\n",SAM::sol());
}
signed main(){
	int t;cin>>t;
	while(t--)sol();
	return 0;
}

详细

Test #1:

score: 0
Wrong Answer
time: 6ms
memory: 30572kb

input:

5
wwgpdvdwwgpdvdwwgpdvdwwwvdwdww
imeoqomeomqomeommeoqomeomqomem
blmjcxblmjcxlmjlmjcxjcxblmjcxl
exzhdyzhddyzhdedyzhyzhddydyyzd
tsbosqtsbosqtsbossbosqtssqtsbb

output:

23
28
18
15
20

result:

wrong answer 2nd lines differ - expected: '21', found: '28'

Test #2:

score: 0
Wrong Answer
time: 2ms
memory: 29416kb

input:

5
rmgmlkgmlkllklmlkgmgmlklklmlkm
fstnttfttfnttfttfttfttfttttftt
hxiykziykzixiykziyykzixiyiyyky
fbtnfwbtnffwbfbtnfwbtnffwwbtnw
yhdizazyhdidihdidihdizzazyyhdi

output:

21
17
18
21
17

result:

wrong answer 1st lines differ - expected: '17', found: '21'

Test #3:

score: 0
Wrong Answer
time: 2ms
memory: 31052kb

input:

4
skjnitkwybtcsfagbpslfxtijbwjqvskibxqwjmukwybtcsfagbbpslfxtijbwjqvskibxqwjmukwybtcsfagbpslfxtijbwjqvskibxqwjmukwybtcsfagbbpslfxtijbwjqvskibxqwjmukwybtcsfagbbpslukwybtcsfagbbpslfxtijbbbpslukwybtcsfaslfc
ssrpyzpwiydtayxmoddtqksdrhcavtsonldnmujuyzpwiydtayxmoddtqksdrhcavtsoniydtayxmoddtqksdrhwiydtayxmo...

output:

180
112
121
112

result:

wrong answer 1st lines differ - expected: '137', found: '180'

Test #4:

score: 0
Wrong Answer
time: 0ms
memory: 29640kb

input:

4
oupltnlcbcgntpnkbvktcbcpltnlcbcgpltnlcgpltngntpnlcbcgntpnkbvktcbcpltnlcbcgpltnlnlcbcgpltnlcgpltngntpnlcbcgntpnktngntpnlcbcgntpnkbvktcbcpltnlcbcgpltnlnlcbcgpltnlcgpltngntpnlcbcgntpnlcbcgntlcbcgntpnkbvn
nzmyzhhsoehahmorxpahsoehahmororxpahsoehahmhsoehahmmyzhhsoehahmhahsoehahmororxpahsoehahmhsoehahmmy...

output:

169
130
121
113

result:

wrong answer 1st lines differ - expected: '114', found: '169'

Test #5:

score: 0
Wrong Answer
time: 2ms
memory: 29480kb

input:

4
wwsqbwicfggaflmvdvegdkclrnybwwsqbwicfggafgdkclrnyaflmvdvegdkclrnybwwsqbwlrnybwwsqbwicfggafgdkclrnyaflmvdvegdkclrnybwwegdknybwwsqybwwsqbwlrnybwwsqbwicfggafgdkclrnyaflmvdvegdkclrnybqbwicfggafgdkclrnyafg
tgloxggsznuxqxggszxggszsznuxqxggszxggszggsznuxqxggsggsznuxqxggszxggszsznuxqxggszxggszggsznuxqxggs...

output:

151
120
112
106

result:

wrong answer 1st lines differ - expected: '111', found: '151'

Test #6:

score: 0
Wrong Answer
time: 0ms
memory: 31292kb

input:

3
ikcblmcsjillvojwymeimbaeipbhobwwnyaakcsvkghhusduehctjexrtaakewiruishkmewsleodhikrnfaternerxiqhamqutaiazbldrrmaddpidimwxsqwbgedswzowhovibaauncxsthwdvudokzpsfulbtbaapxlexrtaakewiruishkmewsleodhikrnfaternerxiqhamqutaiazbldrrmaddpidimwxsqwbgedswzowhovibaauncxsthwdvudokzpsfulbtbaapxlidimwxsqwbgedswzowh...

output:

813
610
568

result:

wrong answer 1st lines differ - expected: '638', found: '813'

Test #7:

score: 0
Wrong Answer
time: 0ms
memory: 33492kb

input:

3
gsxasrisfpretvfhxlwnysaarwkvizqrrntjecdltvqmsvvqgsdgkggdcszmtrfkfzwldzxnysgsxasrisfpretvfhxlwgsxasrisfpretvfhqrrntjecdltvqmsvvqgsdgkggdcszmtrfkfzwarwkvizqrrntjecdltvqmsvvqgsdgkggdcszmtrfkfzwldzxnysgsxasrisfpretvjecdltvqmsvvqgsdgkggdcszmtrfkfzwldzxnfkfzwldzxnysgsxasrisfpretvjecdltvqmsvvqgsdgkggdcsz...

output:

750
591
547

result:

wrong answer 1st lines differ - expected: '582', found: '750'

Test #8:

score: 0
Wrong Answer
time: 3ms
memory: 30720kb

input:

3
aekaabidsppfvwzguexdmycjcqqcxdmycjcqqycjcqexdmycjcqqcxdmycjcqqcxdmycjcqqycjcqevwzguexdmycjcqqcxdmyabidsppfvwzguexdmycjcqqcxdmycjcqqycjcqexdmycjcqqcxdmycjcqqcxdmycjcqqycjcqezguexdmycjcqqcxdmycjcqqycjcqexdmycjcqqcxdmycjcqqcxdmycjcqqycjcqevwzguexdmycjcqqcxdmyxdmycjcqqcxdmycjcqqycjcqexdmycjcqqcxdmycjc...

output:

712
563
520

result:

wrong answer 1st lines differ - expected: '539', found: '712'

Test #9:

score: 0
Wrong Answer
time: 239ms
memory: 108892kb

input:

4
fqbsybwtrauafctwxtzxmhmelxssvxxapauncqgvqcwxfptcktzyanenlxfguejjhdzjufgmicmptfrfasgcgkqrjxzfcipjoqukvawffkuaqniqgotoylhiignmrevhwrruupzzawbqljitxdhyooixxxlqejxaaouufwvfuzxhigbilkiazqzypkovtnwwbssiqookpnsxvvhhfpjghkezwuushsoilgtbwholuilqdszikiptsvuoqpgxhwisfbwbkkpesawxuvhgfycxuwoklwjvtrpaulbexqlrsh...

output:

187461
187897
187356
187301

result:

wrong answer 1st lines differ - expected: '187457', found: '187461'

Test #10:

score: 0
Wrong Answer
time: 100ms
memory: 51976kb

input:

105
iiqnrmmdztbfxwmieuflzvuqveboseucomrfagkbzohyktiqnnbpkyhgciuwoqacerjgxthwjqxtkfjzvnqfnxlpfhnvznxfeglecvcllzhxhszcfphsnvjuewqelnlswxwauylfaufhnejutsngnybuxtaiglaekyeexsmxmrezvpuohjxxjatgttrbetirsmvrehqtawuvlqmuzltllmtgfmjmgrdagytkijfkfagsqumsfidsuyyclhotbrvhrotbzzmgbuyromlvuqnrpntauhvxaqereyvfzjla...

output:

5005
5004
5001
5001
50007
5001
5001
5001
5001
5001
5001
5001
5001
5001
5001
5001
5001
5001
5001
5001
5002
5001
5001
5001
5001
5001
50001
5001
5001
5001
5002
5001
5001
5001
5001
5002
5001
50001
5001
5001
5001
5001
5001
5001
5001
5001
5001
5001
5001
5001
5001
5001
5001
5001
5001
5001
5001
5001
5001
50...

result:

wrong answer 1st lines differ - expected: '5001', found: '5005'

Test #11:

score: 0
Wrong Answer
time: 210ms
memory: 124608kb

input:

1000001
s
o
k
g
r
z
l
d
z
i
n
u
d
j
i
o
k
b
o
s
h
y
w
y
u
k
v
p
d
f
e
x
v
q
d
o
p
r
s
o
z
f
i
e
r
q
s
b
u
i
w
b
g
u
b
a
e
w
p
j
e
v
g
z
l
l
o
c
c
i
q
b
n
b
h
g
t
z
i
p
h
e
s
q
a
u
s
e
s
i
n
w
f
t
y
t
g
o
v
j
w
o
m
l
r
u
s
k
t
c
c
d
i
u
t
i
q
l
m
j
v
b
f
d
w
f
w
c
t
r
l
p
h
y
b
y
u
v
l
n
x
n
s
f
j
n
...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
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 825258th lines differ - expected: '250001', found: '250008'

Test #12:

score: 0
Wrong Answer
time: 23ms
memory: 37736kb

input:

110
rxxioshkbndigoxntdcejhvoskbndigoxntdcejgoxntdcejhvoskbndigoxbndigoxntdcejhvoskbndigoxntdccejhvoskbndigogoxntdcejgoxntdcejhvoskbndigoxbnejgoxntdcejhvoskbndigoxbndigoxntdcejhvoskbndigoxntdccejhvoskbndigogoxntdcejgoxntdcejhvosxntdcejhvoskbndigoxbndigoxntdcejhvoskbndigoxntdccejhvoskbndigogoxntdcejgo...

output:

879
577
663
560
622
537
14340
11759
625
966
595
537
989
567
539
544
578
562
536
600
572
521
19986
979
952
597
632
957
552
605
980
535
566
559
963
12740
629
548
571
988
641
14356
558
571
598
982
539
645
580
586
967
995
966
597
623
961
589
988
594
582
638
606
11243
954
604
558
588
579
559
627
547
590
...

result:

wrong answer 1st lines differ - expected: '629', found: '879'

Test #13:

score: 0
Wrong Answer
time: 24ms
memory: 44344kb

input:

105
jlugzbdizovzbjlugzbdizovzbjlugzbdizovzbjlugzbdizovzbjlugzbdizovzbjlugzbdizovzbjlugzbdizovzbjlugzbdizovzbjlugzbdizovzbjlugzbdizovzbjlugzbdizovzbjlugzbdizovzbjlugzbdizovzbjlugzbdizovzbjlugzbdizovzbjlugzbdizovzbjlugzbdizovzbjlugzbdizovzbjlugzbdizovzbjlugzbdizovzbjlugzbdizovzbjlugzbdizovzbjlugzbdizo...

output:

993
913
578
520
563
621
39987
623
562
551
650
631
541
598
976
663
578
600
984
556
652
996
560
596
672
964
684
972
613
990
596
551
39989
592
579
552
971
587
958
976
640
641
650
967
997
570
591
523
644
571
951
598
645
601
670
556
536
663
596
719
33006
581
618
658
544
662
22008
633
979
540
677
539
965
...

result:

wrong answer 2nd lines differ - expected: '674', found: '913'

Test #14:

score: 0
Wrong Answer
time: 28ms
memory: 55816kb

input:

5
xsmnxsolriymnoxsmnxsolriymnoxsmnxsolriymnoxsmnxsolriymnoxsmnxsolriymnoxsmnxsolriymnoxsmnxsolriymnoxsmnxsolriymnoxsmnxsolriymnoxsmnxsolriymnoxsmnxsolriymnoxsmnxsolriymnoxsmnxsolriymnoxsmnxsolriymnoxsmnxsolriymnoxsmnxsolriymnoxsmnxsolriymnoxsmnxsolriymnoxsmnxsolriymnoxsmnxsolriymnoxsmnxsolriymnoxsmn...

output:

59993
45243
31649
59999
35053

result:

wrong answer 2nd lines differ - expected: '31805', found: '45243'

Test #15:

score: 0
Wrong Answer
time: 24ms
memory: 35548kb

input:

30
qqgcvqshumzfapruaztsztbkdhknlqmegsgekylgmkmobfjceeuezxqcebpqrduyxccjcpqqbefdlqfpubvvymxfnovetrestidxxvnbzsekilcemxbmjaryqofjfjdashxrclsefyqqjswxsykbydcrshczqgaknzermwvsvmkgegeygqahteynlandipovosnbqkvnwfudnabuqddlhbzsdowmfmjtgywwjtmhaikoimkapplzsmrxcpjhdvdjtbievwmxewlokxocobbgoueqkpypkdzgejmzfyxjx...

output:

6953
6422
9965
6171
9985
5656
6137
9965
5246
5788
6213
5511
9988
9994
9991
6384
9982
6431
9993
5763
6489
5902
5343
5847
5849
6573
5863
5737
6460
6527

result:

wrong answer 1st lines differ - expected: '5409', found: '6953'

Test #16:

score: 0
Wrong Answer
time: 346ms
memory: 187492kb

input:

3
pounzdtkokaonqyllykjhhycqxdmmwndkjqlnlxbwzqlpqwcpjnysncilfxzdkenuwbjhakfacsptrukajksxnbksyjykplglopupccpgugzlcllmwgjjhtdhebttpcgfrcuvelczudmyrakngvypqdyufrpwtxbnaykelodhusglsqayoypebnzigqgcokrokbuvsadmsjzkbzkpzzucovnwltyzdrpnvmlnmqbezaqazcsybmcrhpnsjouofleczrplhqrgqhirjarmoudvjtqsjmjqzptzgimnbetrl...

output:

371035
364339
326753

result:

wrong answer 1st lines differ - expected: '283790', found: '371035'

Test #17:

score: 0
Wrong Answer
time: 152ms
memory: 113108kb

input:

36
bqsaqunccgyiarpeaezrgxpbqsaqunccgyiarpeaezrgxpbqsaqunccgyiarpeaezrgxpbqsaqunccgyiarpeaezrgxpbqsaqunccgyiarpeaezrgxpbqsaqunccgyiarpeaezrgxpbqsaqunccgyiarpeaezrgxpbqsaqunccgyiarpeaezrgxpbqsaqunccgyiarpeaezrgxpbqsaqunccgyiarpeaezrgxpbqsaqunccgyiarpeaezrgxpbqsaqunccgyiarpeaezrgxpbqsaqunccgyiarpeaezrg...

output:

49988
10658
37849
11977
49994
11321
13086
49974
12836
31204
11573
30769
29147
10648
12611
11999
49983
499970
13419
11724
19956
19953
29731
11345
12438
12680
19973
12970
19992
19986
30847
11087
10522
11308
10609
12006

result:

wrong answer 3rd lines differ - expected: '28088', found: '37849'

Test #18:

score: 0
Wrong Answer
time: 191ms
memory: 174724kb

input:

36
ueuhiuuxbkqmcjrkbkknbuogliigucooglvofroicgveqoqtacgcwukjfuszwgpermvydlhfreljsdcuhkwdfgpmbhlznaefmbfrmmzdsmpmqrhxcddjmsvpziookuvyvbpjpqnideuvvbuzhxktrhkspahzvczsdpcvfrdkvxfszauizebrmljdlsfixedavhxbyalvyrpztjhsqkleljsdcuhkwdfgpfreljsdcuhkwdfgpmbhlznaefmbfrmmzdsmpmqrhxcddjmsvpziookuvyvbpjpqnideuvvbu...

output:

14312
11643
12012
19963
12651
38273
14468
28087
33112
19974
19950
19997
49982
49993
13154
19962
337915
13287
49970
12457
36644
26432
11485
11694
19977
12699
13358
19973
10948
11629
29009
19964
27385
12772
11344
10920

result:

wrong answer 1st lines differ - expected: '11223', found: '14312'

Test #19:

score: 0
Wrong Answer
time: 111ms
memory: 118192kb

input:

400001
ggg
eee
hhh
ppp
eee
nnn
hhh
aaa
nnn
uuu
xxx
ddd
ttt
sss
jjj
fff
ccc
ddd
aaa
xxx
vvv
mmm
qqq
bbb
qqq
uuu
bbb
ggg
mmm
qqq
ccc
hhh
nnn
yyy
hhh
qqq
fff
www
xxx
uuu
iii
ggg
nnn
rrr
sss
aaa
eee
vvv
iii
eee
vvv
www
qqq
ddd
qqq
rrr
qqq
xxx
ppp
yyy
nnn
bbb
uuu
bbb
yyy
aaa
ttt
www
mmm
lll
qqq
ggg
zzz
b...

output:

2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
...

result:

wrong answer 340842nd lines differ - expected: '184400', found: '261497'

Test #20:

score: 0
Wrong Answer
time: 259ms
memory: 184092kb

input:

27
xtahmwzugvrelqyihbryeggyvqgliwxirxrdvtxbopgahekrhbpnixmfpuryqqiipznksnljetllzvehwvugsimiffivvsfktvumihxmdixcdelbziiuquevzotugagzvcndjkposprxtczumhoddsacivyowgqridxtqmikdbiyfhtsqhxtczxkvxbtfrknwjiowszbthabqtticsbgratmzufenstlbbczubdpkdqcylkcdnjvnejoarsplnaoocqkftcpwstwgdyjqhgfnstnjncuafkrhadptfgra...

output:

17064
12260
19991
11406
13637
19972
19986
11246
12946
19984
11974
12449
12283
12022
12063
393804
15245
10957
11564
350282
16463
19972
11514
11971
11448
11649
12875

result:

wrong answer 1st lines differ - expected: '12118', found: '17064'