QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#747763#9430. Left Shifting 2xzin#WA 5ms3644kbC++14791b2024-11-14 18:10:232024-11-14 18:10:24

Judging History

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

  • [2024-11-14 18:10:24]
  • 评测
  • 测评结果:WA
  • 用时:5ms
  • 内存:3644kb
  • [2024-11-14 18:10:23]
  • 提交

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;
    }
    if(s[n - 1] == s[0]) {
        for(int i = n - 1; i >= 1; i--) {
            if(s[i] == s[0]) sum++;
            else break;
        }
    }
    else sum = 1;
    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: 3644kb

input:

3
abccbbbbd
abcde
x

output:

2
0
0

result:

ok 3 lines

Test #2:

score: -100
Wrong Answer
time: 5ms
memory: 3640kb

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 578th lines differ - expected: '1', found: '0'