QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#138993#5577. Alchemyacm202226010311WA 2ms3548kbC++14451b2023-08-12 15:45:322023-08-12 15:51:37

Judging History

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

  • [2023-08-12 15:51:37]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3548kb
  • [2023-08-12 15:45:32]
  • 提交

answer

#include<iostream>
#include<string>
using namespace std;
int main()
{
	int ans=0;
	string s;
	cin>>s;
	int l=0,r=s.size()-1;
	if(r<3)
	{   if(s[l]==s[r])
	    cout<<0<<endl;
	    else
		cout<<1<<endl;
		return 0;
	}
	while(l<r)
	{   
		if(s[l]!=s[r])
		{ if(r-l<=2)
		  ans+=1;
		  else if(s[l+1]!=s[r-1])
		  ans+=1;
		  else ans+=2;
		  l+=2;
		  r-=2;
        }
		
	   else if(s[l]==s[r])
		l++,r--;
	}
	cout<<ans;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

ioi

output:

0

result:

ok single line: '0'

Test #2:

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

input:

noi

output:

1

result:

ok single line: '1'

Test #3:

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

input:

ctsc

output:

1

result:

ok single line: '1'

Test #4:

score: 0
Accepted
time: 2ms
memory: 3492kb

input:

fool

output:

2

result:

ok single line: '2'

Test #5:

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

input:

vetted

output:

2

result:

ok single line: '2'

Test #6:

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

input:

aa

output:

0

result:

ok single line: '0'

Test #7:

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

input:

ic

output:

1

result:

ok single line: '1'

Test #8:

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

input:

tlffohemdcncrfrxaqsbzcoyodvbxmhqukvfpahnakexcmacqa

output:

12

result:

ok single line: '12'

Test #9:

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

input:

qrgld

output:

1

result:

ok single line: '1'

Test #10:

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

input:

ejyfprguvwrnrsrykyrotmdjuzroohvlxqhvyeukkvmshtpczyyecpzhsqvkxueqvhlxldhofrzcjdhtotykgrsdnrnvuyrphyjy

output:

34

result:

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