QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#139005#5577. AlchemymojospyWA 15ms3620kbC++14665b2023-08-12 16:09:222023-08-12 16:09:25

Judging History

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

  • [2023-08-12 16:09:25]
  • 评测
  • 测评结果:WA
  • 用时:15ms
  • 内存:3620kb
  • [2023-08-12 16:09:22]
  • 提交

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||l+1==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;
}

详细

Test #1:

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

input:

ioi

output:

0

result:

ok single line: '0'

Test #2:

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

input:

noi

output:

1

result:

ok single line: '1'

Test #3:

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

input:

ctsc

output:

1

result:

ok single line: '1'

Test #4:

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

input:

fool

output:

2

result:

ok single line: '2'

Test #5:

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

input:

vetted

output:

2

result:

ok single line: '2'

Test #6:

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

input:

aa

output:

0

result:

ok single line: '0'

Test #7:

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

input:

ic

output:

1

result:

ok single line: '1'

Test #8:

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

input:

tlffohemdcncrfrxaqsbzcoyodvbxmhqukvfpahnakexcmacqa

output:

12

result:

ok single line: '12'

Test #9:

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

input:

qrgld

output:

1

result:

ok single line: '1'

Test #10:

score: 0
Accepted
time: 15ms
memory: 3444kb

input:

ejyfprguvwrnrsrykyrotmdjuzroohvlxqhvyeukkvmshtpczyyecpzhsqvkxueqvhlxldhofrzcjdhtotykgrsdnrnvuyrphyjy

output:

26

result:

ok single line: '26'

Test #11:

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

input:

xcpccpcy

output:

2

result:

ok single line: '2'

Test #12:

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

input:

abpccpcp

output:

1

result:

ok single line: '1'

Test #13:

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

input:

ixpccpci

output:

2

result:

ok single line: '2'

Test #14:

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

input:

xcxccpci

output:

2

result:

ok single line: '2'

Test #15:

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

input:

xcpxcpci

output:

3

result:

ok single line: '3'

Test #16:

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

input:

ixxccpci

output:

1

result:

ok single line: '1'

Test #17:

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

input:

ixpxcpci

output:

2

result:

ok single line: '2'

Test #18:

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

input:

ixpxxycpci

output:

3

result:

ok single line: '3'

Test #19:

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

input:

yxxxyxxxxxyyxxyxxyxyyyxyxyyyyxyxxxxxxxxxxxxyyxxyxyxyyxxyyxyxxyyxxyyyyyyxxyyxxyyxxxxyyyxxxyyxyxyxxyxx

output:

21

result:

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