QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#139002#5577. AlchemymojospyWA 1ms3620kbC++14657b2023-08-12 16:07:302023-08-12 16:07:32

Judging History

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

  • [2023-08-12 16:07:32]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3620kb
  • [2023-08-12 16:07:30]
  • 提交

answer

#include<iostream>
#include<string>
using namespace std;
char c[27]="zabcdefghijklmnopqrstuvwxy";
string s;
int n;
int same(int l,int r){
	//cout<<s<<endl;
	if(l<0) return 0;
	while(l>=0&&r<n&&s[l]==s[r]){
		--l;
		++r;
		
	}
	if(l==0){
		if(l+2==r) return 1;
		else return 2;
	}
	else if(l<0) return 0;
	else if(s[l-1]!=s[r+1]) return 1+same(l-2,r+2);
	else{
		s[r+1]=c[s[r+1]-'a'];
		int p1=1+same(l-1,r+1);
		s[r+1]=s[l-1];
		int p2=2+same(l-1,r+1);
		if(l+1==r) --p2;
		return min(p1,p2);
	}
	return 0;
} 
int main(){
	cin>>s;
	n=s.size();
	if(n&1) cout<<same(n/2-1,n/2+1);
	else cout<<same(n/2-1,n/2);
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

ioi

output:

0

result:

ok single line: '0'

Test #2:

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

input:

noi

output:

1

result:

ok single line: '1'

Test #3:

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

input:

ctsc

output:

1

result:

ok single line: '1'

Test #4:

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

input:

fool

output:

2

result:

ok single line: '2'

Test #5:

score: 0
Accepted
time: 0ms
memory: 3404kb

input:

vetted

output:

2

result:

ok single line: '2'

Test #6:

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

input:

aa

output:

0

result:

ok single line: '0'

Test #7:

score: -100
Wrong Answer
time: 1ms
memory: 3512kb

input:

ic

output:

2

result:

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