QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#628872 | #9430. Left Shifting 2 | Zhou_JK | WA | 1ms | 3592kb | C++23 | 575b | 2024-10-10 22:50:28 | 2024-10-10 22:50:29 |
Judging History
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'