QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#673380 | #9422. Two-star Contest | 2366503423 | WA | 0ms | 3656kb | C++14 | 835b | 2024-10-24 22:01:53 | 2024-10-24 22:01:56 |
Judging History
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)