QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#673380#9422. Two-star Contest2366503423WA 0ms3656kbC++14835b2024-10-24 22:01:532024-10-24 22:01:56

Judging History

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

  • [2024-10-24 22:01:56]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3656kb
  • [2024-10-24 22:01:53]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
int bian(int x)
{
    if(x==1) return 0;
	if(x%2==0) return x/2;
	return (x-1)/2;	
}
int main()
{
	int t;scanf("%d\n",&t);
	while(t--)
	{
		int ans=0;
		string s;cin>>s;
		map <char,int> ma;
		int n=s.size();
		for(int i=0;i<n;i++) ma[s[i]]++;
		if(ma.size()==1){cout<<bian(n)<<'\n';continue;}
		bool f=0;
		s=s+'M';
		int tou=0,wei=0; 
		for(int i=0,j=0;i<=n;i++)
		{
			while(s[i]==s[j]&&j<=n){j++;}
			int len=j-i;
			if(i==0) {tou=len;goto out;}
			if(j==n) {wei=len;goto out;}
			ans+=bian(len);
			if(len%2==0) f=1;
			out:
			i=j-1;
		}
		if(s[0]==s[n-1])
		{
			ans+=bian(tou+wei);
			if((tou+wei)%2==0) f=1;
		}
		else
		{
			ans+=bian(tou)+bian(wei);
			if(tou%2==0||wei%2==0) f=1;
		}
		cout<<ans-f<<'\n';
	}   // bbabb
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

5
3 4 5
5 1 3 -1 -1
2 -1 5 -1 5
3 3 -1 -1 4
2 3 10
10000 5 0 -1
1 10 10 10
2 3 10
10 1 2 3
100 4 5 6
2 3 10
100 1 2 3
10 4 5 6
2 3 10000
100 -1 -1 -1
1 -1 -1 -1

output:

0
0
0
0
0

result:

wrong answer Token parameter [name=yesno] equals to "0", doesn't correspond to pattern "Yes|No" (test case 1)