QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#132490#6567. Repetitive String InventionSorting#WA 219ms6020kbC++860b2023-07-30 00:32:052023-07-30 00:32:08

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-30 00:32:08]
  • 评测
  • 测评结果:WA
  • 用时:219ms
  • 内存:6020kb
  • [2023-07-30 00:32:05]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n;
string s;
int pf[801];
int lcp[801][801];
int solve(){
	for(int i=1; i<=n ;i++){
		for(int j=1; j<i ;j++){
			int z=0;
			while(i+z<=n && s[i+z]==s[j+z]) z++;
			lcp[i][j]=lcp[j][i]=z;
		}
	}
	ll ans=0;
	for(int i=1; i<=n ;i++){
		for(int j=1; j<=i ;j++){
			int sl=i-j+1;
			for(int k=1; k<=j ;k++){
				int cur=0;
				if(k>=sl && lcp[k-sl+1][j]>=sl) cur=1;
				pf[k]=pf[k-1]+cur;
			}
			for(int k=j; k>=1 ;k--){
				int tl=j-k;
				if(tl>0){
					if(i>n || lcp[k][i+1]<tl) continue;//T doesnt match
				}
				ans+=pf[k-1]*(1+(tl!=0));
			}
		}
	}
	return ans;
}
int main(){
	ios::sync_with_stdio(false);cin.tie(0);
	cin >> s;n=s.size();s='?'+s;
	ll ans=solve();
	reverse(s.begin()+1,s.end());
	ans+=solve();
	ans/=2;
	cout << ans << '\n';
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3468kb

input:

aaaa

output:

9

result:

ok single line: '9'

Test #2:

score: 0
Accepted
time: 1ms
memory: 3556kb

input:

axabxbcxcdxd

output:

22

result:

ok single line: '22'

Test #3:

score: 0
Accepted
time: 30ms
memory: 4792kb

input:

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...

output:

536006700

result:

ok single line: '536006700'

Test #4:

score: 0
Accepted
time: 22ms
memory: 4796kb

input:

abababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababab...

output:

136016600

result:

ok single line: '136016600'

Test #5:

score: 0
Accepted
time: 1ms
memory: 3472kb

input:

a

output:

0

result:

ok single line: '0'

Test #6:

score: 0
Accepted
time: 1ms
memory: 3524kb

input:

ab

output:

0

result:

ok single line: '0'

Test #7:

score: 0
Accepted
time: 1ms
memory: 3532kb

input:

aa

output:

1

result:

ok single line: '1'

Test #8:

score: 0
Accepted
time: 21ms
memory: 4800kb

input:

bbbbbrrrrbrbrrbrbrbrbbrrbbbbrrbrrbrbrbrrrrrbbbrrbrrbbrrrbbbbbrrrrbbrbbrrrrrbbrrrbbbbbrbbrbbbrbrrbrrrrrrrrbbrbrbbrrrrrrbbbbbrbrrrrbrrbbrbrrrrrbrbrbbrbrrbrrrrbrbbrbrrbrrbbbbrrrrrbrbbrbbrrrrrbrbrbrbbbrrrrrrrbbbbbbrrbrbrrrrrbbbrbrrrrbbbbrrbrrbbbbbbbrbbbbrrrbrbbbrrrrrrbbbbbrbrrbbbbrbrbrrbbrrrbbbrbbbrbbrr...

output:

209015

result:

ok single line: '209015'

Test #9:

score: 0
Accepted
time: 16ms
memory: 4820kb

input:

fkrryithikkpurfezufbthxxrtejxpprhrhurrfziigzgajipayrefarpxuggehkiggeppfjghuyejuagkjpiezhmfizgphkkfffifihrimuhgtgzykfupbprjyrbpbimapjmbkrhubzhgfhhpkrxgjgmkheiiugiyerggyukyfuuxgrehgayafzuxymxxabygpapbjxipkxgbxhzpekypfghaumukguaipphiyhzimzfmpmzahbmaagytygyekzhktbbheetxrbipgytppgbhkpimrybkbeirhrzytfehba...

output:

5696

result:

ok single line: '5696'

Test #10:

score: 0
Accepted
time: 21ms
memory: 6020kb

input:

ayeaecauuueerrcsyyyuayauarecyrruueeucacrrcesercyeasuscucscruaaresaeruurreeursssuyraeysurecacueuacycacsyuyeyusssassaasyuarrcecueayacucuyyrsasrycyrrcececyuccecyreyeccuesaasceasussaraeruyarcauarcecacrucryryseysauaucyaeyurueurerrccrayyyycccsuaaesrecurucerrascyacucucryarycayeesyysusserarseyrauyrryeacauec...

output:

18249

result:

ok single line: '18249'

Test #11:

score: 0
Accepted
time: 21ms
memory: 4692kb

input:

lclccclcclllccccclcclclcccclllllcclcclclcclllllcllccclclclccclccllcclccccccllccclclcccclclcclclccclllllccclcccccclllllccllcclclllllllccclllcllllccccccccllccclllccclcllllllllcclccclccccllccllclclcclcllcllccclcllclllclclllclllcllcclclllccclcclclllclllllllcclllcccccllcllcllcclcclcllccclclllclclcccllcll...

output:

207835

result:

ok single line: '207835'

Test #12:

score: 0
Accepted
time: 17ms
memory: 4832kb

input:

lygxvkxeeiixzzpamosqadacrnyierrztikxheupgbkfkstyjrmyvhmjrhfhwfdeyhzuyhhbczbjgcnzouiufetegmnvxoeqxiykkwysdnnmdjtpwwzpdaqzmwmapbqbdjsdoxmpbvseyfrrqpgteehoxqsjszykfqgdmcgwikavcnhoubonianpecjtumdutpxwioqtkystzndrbtlfircdsnsxraoitswvhjirqxxjrnjjsldbmdcjngecdaotrgxvikyfyjlbbeketxrxeknuxmxehvabyyyxnrchukft...

output:

3442

result:

ok single line: '3442'

Test #13:

score: 0
Accepted
time: 22ms
memory: 5736kb

input:

yjjxyyxjxyjjyxyyjxyyjxjxjxjyxyxxjxjjyxxxxxjjxyxxyjjxxjyyjjjyyyxjyjxjxyjjyjxjyjyyxjyjyjyyxxyyxxxjjxxxyyyjjjyxjyxjxjyjxjyyyjjxxxjxxjxjjjyjxjyjyyxjyjyjyyxxyyxxxjjxxxyyyjjjyxjyxjxjyjxjyyyjjxxxjxxjxjyjjxyyxjxyjjyxyyjxyyjxjxjxjyxyxxjxjjyxxxxxjjxyxxyjjxxjyyjjjyyyxjyjxjxyjjxyyxjxyjjyxyyjxyyjxjxjxjyxyxxjxjjy...

output:

103111

result:

ok single line: '103111'

Test #14:

score: 0
Accepted
time: 20ms
memory: 4800kb

input:

lhllhlhlhllhlhllhhlhhhhllhhlhhhhllhhlhhhhllhllhhllhhlhhhhllhllhhhhhllhhlhhhhhlhllhlhhlhllhlhhhhllhllhhhllhhlhhhhhhlhllhlhllhhlhhhhhhlhllhlhhllhllllhllhhhlhllhlhhhllhhlhhhhhhllhhlhhhhlhllhlhllhllhhhhllhllllhllllhllllhlllhllhlhllhhlhhhhhhhllhlllhllhlhllhhlhhhhllhllllhlllhllhlhllhllhhhhhhhllhhlhhhhllhh...

output:

298186

result:

ok single line: '298186'

Test #15:

score: 0
Accepted
time: 19ms
memory: 5688kb

input:

blbllblbblbllblbblbllblblblbblllblbbllblbllblbblbllblbblbllblblblbbllblbllblblblbbllblbllblbblbllblblblbbllblbllblblblbbllblbllblbblbllblbblbllblblblbblllblbblllblbblllblbbllblbllblblblbblllblbblllblbbllblbllblblblbblllblbbllblbllblbblbllblbblbllblblblbblllblbblllblbbllblbllblblblbblllblbblllblbblll...

output:

510790

result:

ok single line: '510790'

Test #16:

score: 0
Accepted
time: 21ms
memory: 4788kb

input:

aqqaqaaqqaaqaqqaqaaqaqqaaqqaqaaqqaaqaqqaaqqaqaaqaqqaqaaqqaaqaqqaqaaqaqqaaqqaqaaqaqqaqaaqqaaqaqqaaqqaqaaqqaaqaqqaqaaqaqqaaqqaqaaqqaaqaqqaaqqaqaaqaqqaqaaqqaaqaqqaaqqaqaaqqaaqaqqaqaaqaqqaaqqaqaaqaqqaqaaqqaaqaqqaqaaqaqqaaqqaqaaqqaaqaqqaaqqaqaaqaqqaqaaqqaaqaqqaqaaqaqqaaqqaqaaqaqqaqaaqqaaqaqqaaqqaqaaqqaaq...

output:

584698

result:

ok single line: '584698'

Test #17:

score: -100
Wrong Answer
time: 219ms
memory: 6004kb

input:

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...

output:

-35241192

result:

wrong answer 1st lines differ - expected: '8554693400', found: '-35241192'