QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#483408#7364. 回文TLE_AK0 37ms25100kbC++141.3kb2024-07-18 16:46:372024-07-18 16:46:42

Judging History

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

  • [2024-07-18 16:46:42]
  • 评测
  • 测评结果:0
  • 用时:37ms
  • 内存:25100kb
  • [2024-07-18 16:46:37]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;


namespace acac
{
	
	char S[2000010],C[500010];
	int dy[500010],p[2000010],st[1000010][30];

	int n,m,q;
	
	void read()
	{
		scanf("%s",C+1);
		n=strlen(C+1);
		S[++m]='?';
		S[++m]='$';
		for(int i=1;i<=n;i++)
		{
			S[++m]=C[i];
			dy[i]=m;
			S[++m]='$'; 
		}
		S[++m]='!';
	}
	
	int qr(int l,int r)
	{
		int k=log(r-l+1)/log(2);
		return max(st[l][k],st[r-(1<<k)+1][k]);
	 } 
	
	int  main()
	{
		read();
		int mid=0,r=0;
		for(int i=2;i<m;i++)
		{
			int w=mid*2-i;
			if(i<=r)p[i]=min(p[w],r-i+1);
			else p[i]=1;
			while(S[i+p[i]]==S[i-p[i]])
			{
				p[i]++;
			}
			if(i+p[i]>r)mid=i,r=i+p[i]-1;
			st[i][0]=p[i]-1;
			//cout<<st[i][0]<<' ';
		}
		for(int j=1;j<=20;j++)
		{
		
			for(int i=1;i<=m;i++)
			{
				st[i][j]=max(st[i][j-1],st[i+(1<<(j-1))][j-1]);
			}
		}
		scanf("%d",&q);
		while(q--)
		{
			int a,b;
			scanf("%d%d",&a,&b);
			a=dy[a]-1,b=dy[b]+1;
			int l=1,r=b-a+1,ans=1;
			
		//	cout<<l<<' '<<r<<endl;
			while(l<=r)
			{
				int mid=(l+r)>>1;
				//cout<<mid<<endl;
				if(qr(a+mid-1,b-mid+1)>=mid)
				{
					ans=mid;
					l=mid+1;
				}
				else r=mid-1;
			}
			cout<<ans<<'\n';
		}
		return 0;
	}
}

int main()
{
	acac::main();
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Runtime Error

input:

kmojliclywcyevunhgfnumdzvncnmzbkxjsrkzlyguvjwqmyamvwvidqvfcwnkoolupcrjhynrnlmncqwntqaqtnwqcnmlnrnyhjrcpulooknwcfvqdivwvmaymqwjvugylzkrsmlabbmjltopjasklgawfdbosdlmwahaygutogtvoenkxddmehwokwybkpireouiqqlsfbuqslxjlusnwkzgadxtagewjlchtcezugeguzecthcljwegatxdagzkwnsuljxlsqwlkpvoajknflirxpqcxmyhcgimr
293
...

output:


result:


Test #2:

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

input:

vesjaxxsumewkbahmdfohuzggavsskdplrjqgonwnvtqhqdvxwdvbbvdwxtostthmmzqckepyglcysblxcbcxlbsyclgylyqtthedcqvuoghiyfekmaycoiiumirusuzosmaijqpgrwgcnxtojzyxpnjzyzjnpxyzjotxncgwrgpqjiamsozusurimuiiocyamkefyihgouvpxqdkybihtpmfqfzlwzylmtpgzvzhcrygruvzztttbofobtttzzvurgyrchzvzgptmlyzwlzfqfmpthibykdqxpegpbglnzk...

output:

82
101
72
50
42
60
101
82
87
101
3
21
101
21
101
101
44
101
60
64
24
20
14
101
26
101
21
76
101
28
3
56
101
28
10
24
88
21
24
40
68
1
3
21
101
21
101
4
3
1
56
10
52
8
101
21
36
2
62
42
16
78
21
10
101
90
101
101
1
5
101
3
101
2
101
101
101
48
3
1
3
101
3
60
3
24
101
1
21
101
101
101
1
20
101
1
3
101...

result:

wrong answer 1st lines differ - expected: '81', found: '82'

Test #3:

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

input:

anuahqplebjsacgumhxqolpgrxqcqzlhxrdthilfysevwdukoaksysixdggqzfjifopilugpdlrihgriaedgcjljuzdyqnyplpovdlvsitjcizogkcjkipzwnbdugpkkcghcpcioksqbnvfeggpzdfcxddppanaqnjdrtczcurvgdhnhuuxmktusuykwqrpjgauznlzcgxahiumnbeendsvdoflmuqaylnmsxgfdelfljnvlkeftwsvqhrxpnyjfwohdomcrqcxhvfvksfkjaihqiksfwdlopmwyhagelhju...

output:

5
1272
595
118
5
5
1666
5
1666
957
1666
5
1439
1666
1666
4
545
259
929
1666
3
5
3
669
5
1666
3
797
1666
4
1666
5
1666
3
1272
1666
747
1272
1666
863
437
591
290
1666
765
577
4
1507
5
1272
1327
639
5
1666
1272
5
3
1666
1065
607
165
753
1272
5
4
1666
805
1666
5
1272
3
5
1666
3
1666
81
5
4
5
1272
299
16...

result:

wrong answer 3rd lines differ - expected: '594', found: '595'

Test #4:

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

input:

mfvckuykhckfuqmontrmfcfttxsqnaenocsvdxafpwkpftcwtqwgtsihvaquaudwebxmdijlcrenvivcwbwccmjyxmgmuhdkesgmkcbasghbbwlutayipathsvawcdkkmbdkdiurfsytgjasgsrebgtyjlclkycanipjqlpvxtusmetaxpkwvgilcqnspilinqanxofgxjwqzphraildqdewozyndxbekdknrvbdjgwwvulxfdaqpsziqmrtvlzcabcnouwilynyrbzktbfsfaepmyfjbwuuhvxihiyjicox...

output:

3
1194
698
129
858
3
698
904
5
1665
698
698
94
390
698
625
698
3
3
1665
4
3
1240
436
766
1665
77
538
1665
5
698
5
3
179
625
698
394
698
698
698
3
107
317
1034
652
625
714
1665
698
402
698
1306
1032
5
1098
3
1352
625
120
1394
698
3
625
5
195
698
698
698
322
625
3
422
698
3
698
698
748
1665
886
5
28
6...

result:

wrong answer 2nd lines differ - expected: '1193', found: '1194'

Test #5:

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

input:

piliegnejflgljiidtifmgpcwttkfqexweatzcfecoyuyzpyayapbnenfvjbimyuttkjimtuzpoyhfugdivlxyebblrvgkwowzftkjxjopepbcdkcrioyjjscqnvycmaicuijcdkzizgtyskrkgyflmfvtntfnuikjqyblajyhygopbgpmxruwkkkuqszuuxhorfzsyzgpnxcuifrlvieeeavsrrgthetamjemxekupmclxitasqoqrokhtvomrjlksomhagdxyarqqoqhzuiqlhinhizujhkziqnabxnguz...

output:

4
96
1667
3
1667
1
791
791
604
3
3
1408
96
3
4
1667
584
4
320
758
1667
1320
791
564
726
1667
791
902
1667
1222
791
182
1667
1667
1667
1564
5
291
96
180
120
3
1046
4
1250
846
1667
1667
1667
754
96
10
1667
182
291
96
182
791
206
96
182
264
1667
1667
528
291
1446
1667
1667
1667
1
1667
791
282
291
1667
...

result:

wrong answer 9th lines differ - expected: '603', found: '604'

Test #6:

score: 0
Runtime Error

input:

syucmgkigdlpevdxsshewqirqqcdljqjgaugkvzplmidhvwxeuhuzmzscczopnaviqlgnavpezpquyupilccvjsqfxjmpcsefwerqlgfitezkaffvdwlyhilzflbjecsikzvyecgpjkucqukkrauolgzffotznjxmbvcmsuzrwstehxgqzygfjfybzmyuoxvshelxlpzfxwalgxzlwvhsbaikzsgjkzvzjmlbhgubzcunksleqdgulmysfjashpwjymspmtoxiwaiimcbdqbbudlwbptrusyumtszzwbpmgg...

output:

495
495
3
7
741
741
1541
1541
495
741
1232
188
7
5
741
5
741
1222
741
552
495
1541
495
741
1541
1052
741
495
1230
741
495
1541
1082
690
1541
278
1260
4
386
4
495
4
495
741
4
806
7
1094
548
741
4
844
741
741
741
7
1404
7
5
452
7
7
495
741
741
372
4
7
400
741
741
282
495
495
3
1541
4
3
4
741
578
4
3
1...

result:


Test #7:

score: 0
Wrong Answer
time: 22ms
memory: 21836kb

input:

acfojkhxkvgskemxswoddjrxylgurlpfkpkhssmaqavonpjkhozprsffoslcluvabbpmynaucitshgbfrhilbxuyvdeilculqepksnsosdruqnzkrismdmpypuwigcwmlrynryysiazxaikbsvsxhwobtxuriupwxfmotimszqrfqqcfcukzmghijkeibpndndbodgzpuzqyznrjpzykhzmgrcxhexbsjmanfybqvojzbwpyttmrneejcpdncuzcjdmgxevqmbltpkotcywnfglumjpldxytuaahbgdcnges...

output:

5770
5770
5770
5770
5770
5770
5770
5770
5770
5770
5770
5770
5770
5770
5770
5770
5770
5770
5770
5770
5770
5770
5770
5770
5770
5770
5770
5770
5770
5770
5770
5770
5770
5770
5770
5770
5770
5770
5770
5770
5770
5770
5770
5770
5770
5770
5770
5770
5770
5770
5770
5770
5770
5770
5770
5770
5770
5770
5770
5770
...

result:

wrong answer 1st lines differ - expected: '5769', found: '5770'

Test #8:

score: 0
Wrong Answer
time: 33ms
memory: 25072kb

input:

aaxvxlcltrlilgqvklenrxdcqzouiizataquwymdxtkzyenpdefayzmwugrysrxpwznxpesvcglwqokoajclkeiadelfupalmwhpceexzuzethlcuidgwekhrzvacntvtfmlqptdszlphlewmmwzwcdmjwpefntdlcdrrhejjhakjpkglpbyooqkdhkzrswpmlseuqobyzrquhtdqlbfegkolncwaqoyxrmelvysykpsschwcghzecwneoklalscjqgxoqilbisabofjebktbbzomfupjqcupolpowbtazlq...

output:

3298
12041
5
7
11678
1438
12041
5
88
14910
140
5
9
12041
15140
1158
5
12041
14914
12744
16665
7
16665
12041
5
3
7
5402
7
16665
16665
12041
8960
12041
5
5
11760
12041
7314
16665
12041
16665
4496
2954
11106
16665
7856
8512
12041
2954
1352
14140
2954
12041
16665
5
6634
4972
13328
7
2954
16474
5
16665
1...

result:

wrong answer 1st lines differ - expected: '3297', found: '3298'

Test #9:

score: 0
Runtime Error

input:

bydjourdrgeaxhanforissxtcbtoqpcslsmsuipplgpyitlspqplflboqptqnahqwzchrjhifexlgnmbsehwkwjzojfwvhmmuatwkozdvqwxcorhmhirdgzkztmzegneseslmxuuoifnakuwsycrcgkzpnspyvvfrcbutiknycrvsqgglsvritrrmilxhhrtclxzslysblwsimexxkodgizphdapogypdudlssdispudgxhnfidsyivbvgamsujzzelovuilauyzmstgpgqipmhnbqskffrjjfnzhotbnlzk...

output:

10656
5
9092
6
16665
7
9296
12693
6
6
16665
16665
6
5010
2039
752
12693
12693
2188
7342
6
16665
8432
12693
3688
7
12693
16665
7472
7
7
9288
12693
12693
4786
4786
12693
16665
4786
16665
3186
16665
10382
6
4786
12693
12280
2476
7
5
12693
3924
12693
6
4786
888
5426
5
6
16665
12693
11704
4682
4786
16665...

result:


Test #10:

score: 0
Wrong Answer
time: 37ms
memory: 24664kb

input:

hsfcfbhlqerzkkwsyslalaslnahwpqqhkflavreluedfhcprzyfaipqyzaupdypfannefsdhimxnxoxbaqfktuqcgkjhskocyzeyyvbimybpixxgygccyqjcysqsylrhqrblfqrvheoolimkvqejywdjeuzbhhqdafuybfkarmacprqkqadbrfsrehhthtginqqhwdukdzjfrtgyepxmrnpmrokehpzxtnbigekjlvwkeofqrayiodxshtdbiisdyrboacqktisjtdkfuzmuzrmhgdqewukdcufjrqtskxjk...

output:

10617
8341
978
13845
6131
152
978
978
7183
7
9921
8062
5
152
12439
7
11895
5
978
152
5511
6385
5
7172
16664
5
1357
978
5
16664
13083
978
7868
6079
5
5
5
16664
152
11517
5
11357
16664
7
5
14121
13923
2551
2264
5
3864
978
8341
14293
7
1146
4
5
6341
8341
4
5
13623
5
16664
8341
152
16664
3187
978
5
5
11...

result:

wrong answer 1st lines differ - expected: '10616', found: '10617'

Test #11:

score: 0
Wrong Answer
time: 36ms
memory: 25100kb

input:

uqgylihdxuhtoedyzgzsnwjfaxxdrbadecbkxhbwvzztggrcvorlbgdobvnlswamdnehzepqdqeajrhfwkavapzqvbivztnsqtqnjxjejpgokdyyfxrsuxblzpftwbdkxvrczcerpjadlkqxieyslegpwgwuvzixavdbbtzcvuvnyjpjqvzfzcdnypukljhlspedodczoamlqokdljxdwtonfavmwxemmwicpfbcxfriiqymwizfjghzskzsxyzpluyjwvwyjjzjdddhoflaizakyjzmjmucfxrowqmiiiqp...

output:

5371
6
6
3
10495
14091
3
5
9805
2463
5
17758
5
17758
17758
17758
6686
12531
17758
16621
5
5
13895
301
5
17758
17758
17758
12583
15747
6686
5
1635
17758
1263
12773
5
5
5
979
17758
4
5
17758
493
12487
17758
5
7247
5
5
17758
5
5
1787
5
5
5
2529
17758
5
2059
5725
389
5
841
17758
6686
5
5
5
17758
17758
1...

result:

wrong answer 1st lines differ - expected: '5370', found: '5371'

Test #12:

score: 0
Runtime Error

input:

senpfhuxjnjduvkehgshpecrhtmrsjqaeosajatkkrtdwodqmsfmvoxyipcqjddyxbrroqpkhujinzclqudwqhehxvbpsdqnxzhkjoipcqkqddetmordwjpsuqzoerllzmzbwuorrbmwbzjoycmpeyotbhcwdxygeeqgxbwcqlrywyruatywmmvgckvaowvjpeegwhzarnabqopxpkbtrkhyqauthnzkdmmfdxxfawxygtuzmmbdzhxhstkgtjgzaprjstmssfpczmyyqryfxycoimzobpbihnnmsocfegkc...

output:

5
7
8597
12105
5
7
7
5
7
5
13535
7569
2651
5
5
22963
7
4
5
8623
7
5
11327
5
5
7
5
3643
16369
5
7
7635
15869
7
10217
5
7
7
7
7
7
11443
5
385
23391
5
22921
24996
5
7
6483
8237
11561
5
7
7
6
7
6443
7
6
7
5
7
4281
7
5
685
13157
5
3003
5
7
7
7
14065
5
5
5
5419
5
14087
2901
5
5
7
7115
5
19689
8099
5
5
192...

result:


Test #13:

score: 0
Runtime Error

input:

nwsiebavjnlnjifvaylnhfzybafysczcmrzplqehpgkavzaddjbltazcotufbdzxetxrwhshlxgoqdvbwrkeqkhsbujudbcjhahwkbluvnvdvdxnwocvdkjilwcziqdivzvdlbfwzdenmqlienvoqveubtdoszndqutfsguooniomoyblyxteyhpwommzvnumpwmzqafvfgmnokjwwnkdofoikamvlrxrfkvmrxmsrknmojvaumkrsrlgnpriipbnsbqvglegyhjdefpjngwtbknuivlyftjlsxgffnsjvib...

output:

5
2502
5830
2502
10753
2502
10753
759
9948
3991
2502
2502
4988
2502
10753
3724
10753
3490
759
7
10753
5
5830
5830
7
5
5830
7518
7
5830
2502
5
2429
10753
10753
10753
2502
10753
10753
2502
834
7300
5
6372
2502
5
10753
10753
5
2
5830
5
10753
6892
10753
5
7
5830
10753
10753
5482
5
2502
3015
8620
2502
25...

result:


Test #14:

score: 0
Wrong Answer
time: 37ms
memory: 21824kb

input:

uoqxubtwiuvrweemnisntsggdzuataqgegovblspuctnszgscxridxjlgibfbtdetqrhkfzzvbkbufeisycazjudefsyvgraenfjynszhdjtzidepogsvltustouvnviyrdsncubobnlkruzcsxsabwayfldakyslzfprixpbgpzlfneokxjtnmgtwipkddbmmeahowhndbnuymxryrkgolobkenugcpyfcelqpnpwwphnufpjcxwjyxlcsutfogqlepvyfcjohvhqivjefwtkwubjgtlsabqnpdpixgnrvw...

output:

5
5
1763
5
5271
1430
104
6191
3087
3087
6147
5
3087
3087
3087
4422
3087
1614
5
5
5
4
5
3087
3087
6266
5271
5271
3087
5271
3258
104
5
104
1366
5
3087
3087
5
3087
7
3087
4405
2088
17
3087
3087
3087
5
5271
6125
5
5
5271
3087
3087
3087
5271
5
4
5271
5
5271
3087
3087
4670
4
3087
1740
4
104
2088
3722
3087...

result:

wrong answer 3rd lines differ - expected: '1762', found: '1763'

Test #15:

score: 0
Runtime Error

input:

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaakkeiauuzvxheynhjstrlmdjuyadlukikotjzhqkfxlyabcfwkdyqkgsrkeqcpingbwuhlvlqcwrnotohwdcteumlrepoccfdfznrdltjbjkjzqkdiglyqxwbukxvlivpbhdtzdxsiaqyoqsykspneectkcrlupikmvnqqtbvicmjgwzonahfpytentjnwqunjlpalkwpcskwlqcarzzlktnklalcmplozonpmfpysuyqviwslsfhnzcbplzhyhs...

output:


result:


Test #16:

score: 0
Runtime Error

input:

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaytvhrajhtxhttnnlmeqimzzsjscccivbyritmiznnvgksdehrtmiwacnbixkxnjytuzimzssogvxaemlcpkdtimzfxqreghsbnsqpkwcfepbisgnmispquhyzeqapvpjdfjelclvezqsdjxndhuwxloghiljexxirocvfcpgrilpxspmzjkvhyifkptzguxohzyyjuxqahbblayluiktzmrsgrhthdypkigvjqngfuwkchfepqfvhyuyunfrhluvcdyhvbpktdfoyy...

output:


result:


Test #17:

score: 0
Runtime Error

input:

aaaazkvsgnabokhungreeglngwrtynocgzehwlqgkiiiqdloxdezdcdbhriugyqfqhhaproemijuhymtacrerxmwdzzputjzucaygdskcwpvxdvuafnpfttarbksdowftsieylqlmpcvyrvhtdorechiduhgxkicaicbrcploefuuzmucorweejnscoepoijalirxzxrxbkksvuimwavmhxhhwndfkwocguaojzgtpxwtjmlrkbpbwvjtcilnyjjkmymvwaylhgmobosditopkpmmsawqlricifwcnwvxqac...

output:


result:


Test #18:

score: 0
Runtime Error

input:

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaebhhrvkfkvewwgcwzupqagltrbvbpsmrzhqqrzpphdatdovtqcskottjjaijncilycjoqvhjbvaorrczwefumogmkipliwrjgjcmcksniyjpowbzpezlmkkiivhadolbahzjlelwurmdhfktndmcqndtbimufcsilykijsbmlqrxlfkimnzghkxgtqgznzgcgmrkygvzbdizbraghkncugpszudehqyuhkywdzdbitixbamapwgzbzknwypluul...

output:


result:


Test #19:

score: 0
Runtime Error

input:

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaalvgbspddxrtwkccxskalmiaahvuaaevjkzxskmumnesqsjfqlgkanmmdinkbiabnrmvocequrnicjqzdatwwdzpgyoumwymnsjnklvbjrswytpqejlgxcmoaqqvpihlghjrsyvcoxhvprkfusafjsdrgopnfufkoopyqetppxuciqcwjxldgtwcthdepfcxdvrrhxcxdmsjnukgpdgkknnwzwmtavzvynhsapujivwmjlsaybeuaftemhzpmuexavqmhvpfou...

output:


result:


Test #20:

score: 0
Runtime Error

input:

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaairvzomrstpfklvpyiboqxtnqbjazhstswwhmrdgbzsstvkrtencmmeqjfclkztnlsrrghcfrfrivxfrrpnwehishsneqljlmqwkugitnkuotmncikpvxzvgxcvdppekdbomsvqupgpjdcowzqfoxcivupvucxstsjlrlylvlzmqcxtqdwztpxmzetubgxllckejlkwjytrvdwmimdencuffcdifrllsoihxnbhoyy...

output:


result: