QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#789160#9430. Left Shifting 2snow_mikumikuWA 2ms3616kbC++14827b2024-11-27 19:26:042024-11-27 19:26:05

Judging History

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

  • [2024-11-27 19:26:05]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3616kb
  • [2024-11-27 19:26:04]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
using LL = long long;

void solve()
{
    string S, tmp;
    cin >> S;
    if(S.size() == 2 && S[0] == S[1]) {
        cout << 1 << '\n';
        return;
    }
    tmp += S[0];
    for(int i = 1; i < S.size(); i++) {
        if(S[i] == S[i - 1]) tmp += S[i];
        else break;
    }
    S += tmp;

    int ans = 0, cnt = 1, f = 0;
    for(int i = tmp.size() + 1; i < S.size(); i++) {
        if(S[i] == S[i - 1]) cnt++;
        else {
            if(cnt % 2 == 0) f = 1;
            ans += cnt / 2;
            cnt = 1;
        }
    }
    if(cnt % 2 == 0) f = 1;
    ans += cnt / 2;
    cout << ans - f << '\n';
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int t;
    cin >> t;
    while(t--) solve();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3
abccbbbbd
abcde
x

output:

2
0
0

result:

ok 3 lines

Test #2:

score: -100
Wrong Answer
time: 2ms
memory: 3616kb

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