QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#778647#9430. Left Shifting 2syhhh1WA 7ms3580kbC++17868b2024-11-24 15:35:422024-11-24 15:35:56

Judging History

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

  • [2024-11-24 15:35:56]
  • 评测
  • 测评结果:WA
  • 用时:7ms
  • 内存:3580kb
  • [2024-11-24 15:35:42]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;

#define int long long 
const int N=5e5+10;
char a[N];
signed main()
{
	int t;
	cin>>t;
	while(t--)
	{
	    string s;	
		cin>>s;
		int n=s.length();
		int ans=0;
		vector<int>v;
		for(int i=0;i<n;)
		{
			int j=i;
			while(s[j]==s[i])j++;
			v.push_back(j-i);
			i=j;
		}
		bool fg=false;
		for(int i=0;i<v.size();i++)
		{
			if(v[i]%2==0)fg=true;
			ans+=(v[i]/2);
		}
		int s1=0,s2=0;
		for(int i=1;i<n;i++)
		{
			if(s[i]!=s[0])
			{
				s1=i+1;
				break;
			}
		}
		for(int i=n-2;i>=0;i--)
		{
			if(s[i]!=s[n-1])
			{
				s2++;
			}else break;
		}
		bool f1=true;
		for(int i=1;i<n;i++)
		{
			if(s[i]!=s[0])f1=false;
		}
		if(fg&&s[0]!=s[n-1])ans--;
		else if(fg&&(s1%2!=1||s2%2!=1))ans--;
		if(f1)cout<<n/2<<endl;
		else cout<<ans<<endl;
	}
	
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3580kb

input:

3
abccbbbbd
abcde
x

output:

2
0
0

result:

ok 3 lines

Test #2:

score: -100
Wrong Answer
time: 7ms
memory: 3400kb

input:

5000
lfpbavjsmppdppkfwnyfmbdhptdswsoulrbhyjh
cfliuqnynejgnxolzbdoztclzbozqomvioszk
eiivcoqoymonrqgrjdtkts
mdcvservaxcbioopfungsgkiftchwlmtbzqgaraovjknsgiegkvdbolmeunvrxrpscnf
ujeqtidwtoikkqtygo
llma
qjfvgwrdhaazejsfgilnpmmhkefndzvyon
kzwwpdpbrudqmwmjscllnnjyoepxophcoopvfepikouinuxx
vftculoorxskpkxoz...

output:

1
0
0
0
0
0
1
4
0
0
1
1
0
1
1
3
0
0
5
6
0
0
5
2
0
1
3
1
0
3
0
1
0
1
1
0
1
4
1
3
1
0
1
5
3
0
3
0
0
1
7
1
0
6
1
2
0
1
0
0
4
1
2
4
3
1
3
2
3
1
2
0
0
0
2
0
2
2
0
4
0
5
5
0
3
0
4
0
0
2
1
0
2
0
1
6
1
2
0
3
3
3
5
2
3
0
3
5
1
3
0
0
3
0
4
5
3
2
1
1
0
0
2
0
1
1
2
3
3
1
2
0
1
1
4
2
1
3
0
1
1
2
0
1
2
0
4
0
1
1
...

result:

wrong answer 13th lines differ - expected: '1', found: '0'