QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#628872#9430. Left Shifting 2Zhou_JKWA 1ms3592kbC++23575b2024-10-10 22:50:282024-10-10 22:50:29

Judging History

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

  • [2024-10-10 22:50:29]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3592kb
  • [2024-10-10 22:50:28]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N=500005;
int n;
string s;
void solve()
{
    cin>>s;
    n=s.size();
    int sum=0,del=0;
    for(int i=0,j=0;i<n;i=j)
    {
        while(j<n&&s[i]==s[j]) j++;
        int len=j-i;
        if(len>1) sum+=len-1,del=max(del,1);
        if(len%2==0&&len>2) del=max(del,2);
    }
    int ans=sum-del;
    cout<<ans<<"\n";
    return;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr),cout.tie(nullptr);
    int T;
    cin>>T;
    while(T--)
        solve();
    return 0;
}

详细

Test #1:

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

input:

3
abccbbbbd
abcde
x

output:

2
0
0

result:

ok 3 lines

Test #2:

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

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
2
3
0
0
5
6
0
0
5
2
0
1
3
1
0
3
0
1
0
1
1
0
1
4
2
3
1
0
1
5
4
0
3
0
0
1
8
0
0
6
1
2
0
2
0
0
4
1
2
5
3
1
3
3
4
0
2
0
0
0
2
0
3
2
0
4
0
5
5
0
3
0
5
0
0
2
1
0
4
0
1
6
1
2
0
3
3
3
6
2
3
0
3
5
2
3
0
0
3
0
4
7
3
2
1
1
0
0
2
0
2
1
2
3
3
1
2
0
1
1
4
2
1
4
0
1
1
2
0
1
2
0
4
0
2
1
...

result:

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