QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#522736#7364. 回文Cure_Beauty30 83ms4388kbC++141.0kb2024-08-17 13:01:102024-08-17 13:01:10

Judging History

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

  • [2024-08-17 13:01:10]
  • 评测
  • 测评结果:30
  • 用时:83ms
  • 内存:4388kb
  • [2024-08-17 13:01:10]
  • 提交

answer

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using std::cin;using std::cout;
constexpr int N=1000005;
std::string s;
int n,q,l,r,p[N];
bool tag=1;
signed main(){
//	freopen("palindrome.in","r",stdin);
//	freopen("palindrome.out","w",stdout);
	std::ios::sync_with_stdio(false);
	cin.tie(nullptr);cout.tie(nullptr);
	cin>>s>>q;n=s.size();s=" "+s;
	for(int i=1;i<=n;++i) if(s[i]!='a'){tag=0;break;}
	if(tag){for(int i=1;i<=q;++i){cin>>l>>r;cout<<r-l+1<<'\n';}return 0;}
	if(n<=5000&&q<=5000){
		for(int i=1;i<=q;++i){
			cin>>l>>r;std::string t="#$";
			for(int j=l;j<=r;++j){t+=s[j];t+='$';};t+="@";
			int m=2*(r-l+1),ans=0;
			for(int j=0;j<=m;++j) p[j]=0;
			for(int j=1,mid=1,r=0;j<=m;++j){
				if(j<=r) p[j]=std::min(p[2*mid-j],r-j);
				while(t[j+p[j]]==t[j-p[j]]) ++p[j];
				if(j+p[j]>r){mid=j;r=j+p[j];}
				ans=std::max(ans,p[j]);
			}
			cout<<ans-1<<'\n';
		}
		return 0;
	}
	cout<<"明堂院树";
	return 0;
}//第四十回 史太君两宴大观园 金鸳鸯三宣牙牌令
//明堂院树

Details

Tip: Click on the bar to expand more detailed information

Pretests


Final Tests

Test #1:

score: 5
Accepted
time: 1ms
memory: 3880kb

input:

kmojliclywcyevunhgfnumdzvncnmzbkxjsrkzlyguvjwqmyamvwvidqvfcwnkoolupcrjhynrnlmncqwntqaqtnwqcnmlnrnyhjrcpulooknwcfvqdivwvmaymqwjvugylzkrsmlabbmjltopjasklgawfdbosdlmwahaygutogtvoenkxddmehwokwybkpireouiqqlsfbuqslxjlusnwkzgadxtagewjlchtcezugeguzecthcljwegatxdagzkwnsuljxlsqwlkpvoajknflirxpqcxmyhcgimr
293
...

output:

101
75
83
63
3
2
101
3
3
3
39
3
1
41
3
23
2
1
63
45
1
63
31
1
101
83
3
41
13
63
63
3
2
2
3
1
1
1
1
3
2
63
23
15
15
101
2
31
63
71
101
49
37
2
101
101
3
71
1
63
3
31
85
1
2
63
101
2
3
3
63
3
63
65
63
3
101
63
41
3
3
3
73
7
1
25
63
37
29
17
1
3
3
2
3
101
1
101
1
3
3
63
1
1
31
77
101
89
31
41
101
15
59...

result:

ok 293 lines

Test #2:

score: 5
Accepted
time: 1ms
memory: 3880kb

input:

vesjaxxsumewkbahmdfohuzggavsskdplrjqgonwnvtqhqdvxwdvbbvdwxtostthmmzqckepyglcysblxcbcxlbsyclgylyqtthedcqvuoghiyfekmaycoiiumirusuzosmaijqpgrwgcnxtojzyxpnjzyzjnpxyzjotxncgwrgpqjiamsozusurimuiiocyamkefyihgouvpxqdkybihtpmfqfzlwzylmtpgzvzhcrygruvzztttbofobtttzzvurgyrchzvzgptmlyzwlzfqfmpthibykdqxpegpbglnzk...

output:

81
101
71
49
41
59
101
81
87
101
3
21
101
21
101
101
43
101
59
63
23
19
13
101
25
101
21
75
101
27
3
55
101
27
10
23
87
21
23
39
67
1
3
21
101
21
101
3
3
1
55
10
51
7
101
21
35
2
61
41
15
77
21
10
101
89
101
101
1
4
101
3
101
2
101
101
101
47
3
1
3
101
3
59
3
23
101
1
21
101
101
101
1
19
101
1
3
101...

result:

ok 290 lines

Test #3:

score: 5
Accepted
time: 83ms
memory: 3664kb

input:

anuahqplebjsacgumhxqolpgrxqcqzlhxrdthilfysevwdukoaksysixdggqzfjifopilugpdlrihgriaedgcjljuzdyqnyplpovdlvsitjcizogkcjkipzwnbdugpkkcghcpcioksqbnvfeggpzdfcxddppanaqnjdrtczcurvgdhnhuuxmktusuykwqrpjgauznlzcgxahiumnbeendsvdoflmuqaylnmsxgfdelfljnvlkeftwsvqhrxpnyjfwohdomcrqcxhvfvksfkjaihqiksfwdlopmwyhagelhju...

output:

5
1272
594
117
5
5
1666
5
1666
956
1666
5
1438
1666
1666
4
544
258
928
1666
3
5
3
669
5
1666
3
796
1666
4
1666
5
1666
3
1272
1666
746
1272
1666
862
436
590
289
1666
764
576
4
1506
5
1272
1326
638
5
1666
1272
5
3
1666
1064
606
164
752
1272
5
4
1666
804
1666
5
1272
3
5
1666
3
1666
80
5
4
5
1272
298
16...

result:

ok 4991 lines

Test #4:

score: 5
Accepted
time: 79ms
memory: 3884kb

input:

mfvckuykhckfuqmontrmfcfttxsqnaenocsvdxafpwkpftcwtqwgtsihvaquaudwebxmdijlcrenvivcwbwccmjyxmgmuhdkesgmkcbasghbbwlutayipathsvawcdkkmbdkdiurfsytgjasgsrebgtyjlclkycanipjqlpvxtusmetaxpkwvgilcqnspilinqanxofgxjwqzphraildqdewozyndxbekdknrvbdjgwwvulxfdaqpsziqmrtvlzcabcnouwilynyrbzktbfsfaepmyfjbwuuhvxihiyjicox...

output:

3
1193
698
128
857
3
698
903
5
1665
698
698
93
389
698
625
698
3
3
1665
4
3
1239
435
765
1665
76
537
1665
5
698
5
3
178
625
698
393
698
698
698
3
106
316
1033
651
625
713
1665
698
401
698
1305
1031
5
1097
3
1351
625
119
1393
698
3
625
5
194
698
698
698
321
625
3
421
698
3
698
698
747
1665
885
5
27
6...

result:

ok 4997 lines

Test #5:

score: 5
Accepted
time: 83ms
memory: 3656kb

input:

piliegnejflgljiidtifmgpcwttkfqexweatzcfecoyuyzpyayapbnenfvjbimyuttkjimtuzpoyhfugdivlxyebblrvgkwowzftkjxjopepbcdkcrioyjjscqnvycmaicuijcdkzizgtyskrkgyflmfvtntfnuikjqyblajyhygopbgpmxruwkkkuqszuuxhorfzsyzgpnxcuifrlvieeeavsrrgthetamjemxekupmclxitasqoqrokhtvomrjlksomhagdxyarqqoqhzuiqlhinhizujhkziqnabxnguz...

output:

4
96
1667
3
1667
1
791
791
603
3
3
1407
96
3
4
1667
583
4
319
757
1667
1319
791
563
725
1667
791
901
1667
1221
791
182
1667
1667
1667
1563
5
291
96
179
119
3
1045
4
1249
845
1667
1667
1667
753
96
9
1667
182
291
95
182
791
205
96
182
263
1667
1667
527
291
1445
1667
1667
1667
1
1667
791
281
291
1667
7...

result:

ok 4995 lines

Test #6:

score: 5
Accepted
time: 78ms
memory: 3668kb

input:

syucmgkigdlpevdxsshewqirqqcdljqjgaugkvzplmidhvwxeuhuzmzscczopnaviqlgnavpezpquyupilccvjsqfxjmpcsefwerqlgfitezkaffvdwlyhilzflbjecsikzvyecgpjkucqukkrauolgzffotznjxmbvcmsuzrwstehxgqzygfjfybzmyuoxvshelxlpzfxwalgxzlwvhsbaikzsgjkzvzjmlbhgubzcunksleqdgulmysfjashpwjymspmtoxiwaiimcbdqbbudlwbptrusyumtszzwbpmgg...

output:

495
495
3
7
741
741
1541
1541
495
741
1231
187
7
5
741
5
741
1221
741
551
495
1541
495
741
1541
1051
741
495
1229
741
495
1541
1081
689
1541
277
1259
4
385
4
495
4
495
741
4
805
7
1093
547
741
4
843
741
741
741
7
1403
7
5
451
7
7
495
741
741
371
4
7
399
741
741
281
495
495
3
1541
4
3
4
741
577
4
3
1...

result:

ok 4999 lines

Test #7:

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

input:

acfojkhxkvgskemxswoddjrxylgurlpfkpkhssmaqavonpjkhozprsffoslcluvabbpmynaucitshgbfrhilbxuyvdeilculqepksnsosdruqnzkrismdmpypuwigcwmlrynryysiazxaikbsvsxhwobtxuriupwxfmotimszqrfqqcfcukzmghijkeibpndndbodgzpuzqyznrjpzykhzmgrcxhexbsjmanfybqvojzbwpyttmrneejcpdncuzcjdmgxevqmbltpkotcywnfglumjpldxytuaahbgdcnges...

output:

明堂院树

result:

wrong answer 1st lines differ - expected: '5769', found: '明堂院树'

Test #8:

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

input:

aaxvxlcltrlilgqvklenrxdcqzouiizataquwymdxtkzyenpdefayzmwugrysrxpwznxpesvcglwqokoajclkeiadelfupalmwhpceexzuzethlcuidgwekhrzvacntvtfmlqptdszlphlewmmwzwcdmjwpefntdlcdrrhejjhakjpkglpbyooqkdhkzrswpmlseuqobyzrquhtdqlbfegkolncwaqoyxrmelvysykpsschwcghzecwneoklalscjqgxoqilbisabofjebktbbzomfupjqcupolpowbtazlq...

output:

明堂院树

result:

wrong answer 1st lines differ - expected: '3297', found: '明堂院树'

Test #9:

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

input:

bydjourdrgeaxhanforissxtcbtoqpcslsmsuipplgpyitlspqplflboqptqnahqwzchrjhifexlgnmbsehwkwjzojfwvhmmuatwkozdvqwxcorhmhirdgzkztmzegneseslmxuuoifnakuwsycrcgkzpnspyvvfrcbutiknycrvsqgglsvritrrmilxhhrtclxzslysblwsimexxkodgizphdapogypdudlssdispudgxhnfidsyivbvgamsujzzelovuilauyzmstgpgqipmhnbqskffrjjfnzhotbnlzk...

output:

明堂院树

result:

wrong answer 1st lines differ - expected: '10655', found: '明堂院树'

Test #10:

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

input:

hsfcfbhlqerzkkwsyslalaslnahwpqqhkflavreluedfhcprzyfaipqyzaupdypfannefsdhimxnxoxbaqfktuqcgkjhskocyzeyyvbimybpixxgygccyqjcysqsylrhqrblfqrvheoolimkvqejywdjeuzbhhqdafuybfkarmacprqkqadbrfsrehhthtginqqhwdukdzjfrtgyepxmrnpmrokehpzxtnbigekjlvwkeofqrayiodxshtdbiisdyrboacqktisjtdkfuzmuzrmhgdqewukdcufjrqtskxjk...

output:

明堂院树

result:

wrong answer 1st lines differ - expected: '10616', found: '明堂院树'

Test #11:

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

input:

uqgylihdxuhtoedyzgzsnwjfaxxdrbadecbkxhbwvzztggrcvorlbgdobvnlswamdnehzepqdqeajrhfwkavapzqvbivztnsqtqnjxjejpgokdyyfxrsuxblzpftwbdkxvrczcerpjadlkqxieyslegpwgwuvzixavdbbtzcvuvnyjpjqvzfzcdnypukljhlspedodczoamlqokdljxdwtonfavmwxemmwicpfbcxfriiqymwizfjghzskzsxyzpluyjwvwyjjzjdddhoflaizakyjzmjmucfxrowqmiiiqp...

output:

明堂院树

result:

wrong answer 1st lines differ - expected: '5370', found: '明堂院树'

Test #12:

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

input:

senpfhuxjnjduvkehgshpecrhtmrsjqaeosajatkkrtdwodqmsfmvoxyipcqjddyxbrroqpkhujinzclqudwqhehxvbpsdqnxzhkjoipcqkqddetmordwjpsuqzoerllzmzbwuorrbmwbzjoycmpeyotbhcwdxygeeqgxbwcqlrywyruatywmmvgckvaowvjpeegwhzarnabqopxpkbtrkhyqauthnzkdmmfdxxfawxygtuzmmbdzhxhstkgtjgzaprjstmssfpczmyyqryfxycoimzobpbihnnmsocfegkc...

output:

明堂院树

result:

wrong answer 1st lines differ - expected: '5', found: '明堂院树'

Test #13:

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

input:

nwsiebavjnlnjifvaylnhfzybafysczcmrzplqehpgkavzaddjbltazcotufbdzxetxrwhshlxgoqdvbwrkeqkhsbujudbcjhahwkbluvnvdvdxnwocvdkjilwcziqdivzvdlbfwzdenmqlienvoqveubtdoszndqutfsguooniomoyblyxteyhpwommzvnumpwmzqafvfgmnokjwwnkdofoikamvlrxrfkvmrxmsrknmojvaumkrsrlgnpriipbnsbqvglegyhjdefpjngwtbknuivlyftjlsxgffnsjvib...

output:

明堂院树

result:

wrong answer 1st lines differ - expected: '5', found: '明堂院树'

Test #14:

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

input:

uoqxubtwiuvrweemnisntsggdzuataqgegovblspuctnszgscxridxjlgibfbtdetqrhkfzzvbkbufeisycazjudefsyvgraenfjynszhdjtzidepogsvltustouvnviyrdsncubobnlkruzcsxsabwayfldakyslzfprixpbgpzlfneokxjtnmgtwipkddbmmeahowhndbnuymxryrkgolobkenugcpyfcelqpnpwwphnufpjcxwjyxlcsutfogqlepvyfcjohvhqivjefwtkwubjgtlsabqnpdpixgnrvw...

output:

明堂院树

result:

wrong answer 1st lines differ - expected: '5', found: '明堂院树'

Test #15:

score: 0
Wrong Answer
time: 1ms
memory: 4388kb

input:

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaakkeiauuzvxheynhjstrlmdjuyadlukikotjzhqkfxlyabcfwkdyqkgsrkeqcpingbwuhlvlqcwrnotohwdcteumlrepoccfdfznrdltjbjkjzqkdiglyqxwbukxvlivpbhdtzdxsiaqyoqsykspneectkcrlupikmvnqqtbvicmjgwzonahfpytentjnwqunjlpalkwpcskwlqcarzzlktnklalcmplozonpmfpysuyqviwslsfhnzcbplzhyhs...

output:

明堂院树

result:

wrong answer 1st lines differ - expected: '6415', found: '明堂院树'

Test #16:

score: 0
Wrong Answer
time: 1ms
memory: 4212kb

input:

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaytvhrajhtxhttnnlmeqimzzsjscccivbyritmiznnvgksdehrtmiwacnbixkxnjytuzimzssogvxaemlcpkdtimzfxqreghsbnsqpkwcfepbisgnmispquhyzeqapvpjdfjelclvezqsdjxndhuwxloghiljexxirocvfcpgrilpxspmzjkvhyifkptzguxohzyyjuxqahbblayluiktzmrsgrhthdypkigvjqngfuwkchfepqfvhyuyunfrhluvcdyhvbpktdfoyy...

output:

明堂院树

result:

wrong answer 1st lines differ - expected: '1180', found: '明堂院树'

Test #17:

score: 0
Wrong Answer
time: 1ms
memory: 4308kb

input:

aaaazkvsgnabokhungreeglngwrtynocgzehwlqgkiiiqdloxdezdcdbhriugyqfqhhaproemijuhymtacrerxmwdzzputjzucaygdskcwpvxdvuafnpfttarbksdowftsieylqlmpcvyrvhtdorechiduhgxkicaicbrcploefuuzmucorweejnscoepoijalirxzxrxbkksvuimwavmhxhhwndfkwocguaojzgtpxwtjmlrkbpbwvjtcilnyjjkmymvwaylhgmobosditopkpmmsawqlricifwcnwvxqac...

output:

明堂院树

result:

wrong answer 1st lines differ - expected: '7', found: '明堂院树'

Test #18:

score: 0
Wrong Answer
time: 1ms
memory: 4320kb

input:

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaebhhrvkfkvewwgcwzupqagltrbvbpsmrzhqqrzpphdatdovtqcskottjjaijncilycjoqvhjbvaorrczwefumogmkipliwrjgjcmcksniyjpowbzpezlmkkiivhadolbahzjlelwurmdhfktndmcqndtbimufcsilykijsbmlqrxlfkimnzghkxgtqgznzgcgmrkygvzbdizbraghkncugpszudehqyuhkywdzdbitixbamapwgzbzknwypluul...

output:

明堂院树

result:

wrong answer 1st lines differ - expected: '166667', found: '明堂院树'

Test #19:

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

input:

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaalvgbspddxrtwkccxskalmiaahvuaaevjkzxskmumnesqsjfqlgkanmmdinkbiabnrmvocequrnicjqzdatwwdzpgyoumwymnsjnklvbjrswytpqejlgxcmoaqqvpihlghjrsyvcoxhvprkfusafjsdrgopnfufkoopyqetppxuciqcwjxldgtwcthdepfcxdvrrhxcxdmsjnukgpdgkknnwzwmtavzvynhsapujivwmjlsaybeuaftemhzpmuexavqmhvpfou...

output:

明堂院树

result:

wrong answer 1st lines differ - expected: '21967', found: '明堂院树'

Test #20:

score: 0
Wrong Answer
time: 1ms
memory: 4248kb

input:

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaairvzomrstpfklvpyiboqxtnqbjazhstswwhmrdgbzsstvkrtencmmeqjfclkztnlsrrghcfrfrivxfrrpnwehishsneqljlmqwkugitnkuotmncikpvxzvgxcvdppekdbomsvqupgpjdcowzqfoxcivupvucxstsjlrlylvlzmqcxtqdwztpxmzetubgxllckejlkwjytrvdwmimdencuffcdifrllsoihxnbhoyy...

output:

明堂院树

result:

wrong answer 1st lines differ - expected: '7', found: '明堂院树'