QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#695617 | #9430. Left Shifting 2 | Czg19916 | WA | 0ms | 3836kb | C++14 | 656b | 2024-10-31 20:26:48 | 2024-10-31 20:26:48 |
Judging History
answer
#include<iostream>
#define int long long
using namespace std;
signed main(){
int T;cin>>T;
while(T--){
string s;cin>>s;
int cnt=1;
int ans=0;
int f=0;
if(s[0]==s.back()) f=1;
for(int i=0;i<s.length();i++){
if(i<s.length()-1&&s[i]==s[i+1]){
cnt++;
}else if(cnt>=2){
if(f==0&&cnt%2==0) f=1,cnt--;
ans+=cnt/2;
cnt=1;
}
// cout<<i<<' '<<f<<' '<<cnt<<' '<<ans<<endl;
}
cout<<ans<<endl;
}
}
/*
cacxcacxc
bbbabbaabba
bxbab bxaxba
bxaxbxaxbab
*/
詳細信息
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: 0ms
memory: 3836kb
input:
5000 lfpbavjsmppdppkfwnyfmbdhptdswsoulrbhyjh cfliuqnynejgnxolzbdoztclzbozqomvioszk eiivcoqoymonrqgrjdtkts mdcvservaxcbioopfungsgkiftchwlmtbzqgaraovjknsgiegkvdbolmeunvrxrpscnf ujeqtidwtoikkqtygo llma qjfvgwrdhaazejsfgilnpmmhkefndzvyon kzwwpdpbrudqmwmjscllnnjyoepxophcoopvfepikouinuxx vftculoorxskpkxoz...
output:
1 0 0 0 0 0 1 4 0 0 1 1 1 1 1 3 1 0 5 6 0 0 5 2 0 1 3 2 0 3 0 1 0 1 1 0 1 4 1 3 1 0 1 5 3 0 3 0 0 1 8 1 0 6 1 2 0 1 0 0 4 1 2 4 3 1 3 2 3 1 2 1 0 0 2 0 2 2 0 4 0 5 5 0 3 0 4 1 0 2 1 0 2 0 1 6 1 2 1 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 3 3 3 1 2 0 1 1 4 3 1 3 1 1 1 2 0 1 2 0 4 0 1 1 ...
result:
wrong answer 591st lines differ - expected: '2', found: '3'