QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#747631#9430. Left Shifting 2xzin#WA 6ms3696kbC++14722b2024-11-14 17:43:072024-11-14 17:43:10

Judging History

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

  • [2024-11-14 17:43:10]
  • 评测
  • 测评结果:WA
  • 用时:6ms
  • 内存:3696kb
  • [2024-11-14 17:43:07]
  • 提交

answer

#include <bits/stdc++.h>


using namespace std;


int n, ans, k, num, sum;
string s;
void sl() {
    cin>>s; n = s.length(); s += '!'; 
    num = 1; k = 0; sum = 1; ans =0;
    for(int i = 1; i <= n; i++) {
        if(s[i] == s[i - 1])  num++;
        else {
            ans += num / 2; 
            if(num % 2 == 0) k = 1;
            num = 1;
        }
    }
    for(int i = 1;i <= n; i++) {
        if(s[i] == s[0]) sum++;
        else break;
    }
    for(int i = n - 1; i >= 1; i--) {
        if(s[i] == s[0]) sum++;
        else break;
    }
    if(sum < n && sum % 2 && k) ans--;
    cout<<ans<<endl;
}
int main() {
    int T; cin>>T;
    while (T--) {
        sl();
    }
    
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3
abccbbbbd
abcde
x

output:

2
0
0

result:

ok 3 lines

Test #2:

score: -100
Wrong Answer
time: 6ms
memory: 3628kb

input:

5000
lfpbavjsmppdppkfwnyfmbdhptdswsoulrbhyjh
cfliuqnynejgnxolzbdoztclzbozqomvioszk
eiivcoqoymonrqgrjdtkts
mdcvservaxcbioopfungsgkiftchwlmtbzqgaraovjknsgiegkvdbolmeunvrxrpscnf
ujeqtidwtoikkqtygo
llma
qjfvgwrdhaazejsfgilnpmmhkefndzvyon
kzwwpdpbrudqmwmjscllnnjyoepxophcoopvfepikouinuxx
vftculoorxskpkxoz...

output:

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

result:

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