QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#695617#9430. Left Shifting 2Czg19916WA 0ms3836kbC++14656b2024-10-31 20:26:482024-10-31 20:26:48

Judging History

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

  • [2024-10-31 20:26:48]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3836kb
  • [2024-10-31 20:26:48]
  • 提交

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'