QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#691970#9430. Left Shifting 2Z-wzyWA 1ms3620kbC++20849b2024-10-31 13:33:162024-10-31 13:33:17

Judging History

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

  • [2024-10-31 13:33:17]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3620kb
  • [2024-10-31 13:33:16]
  • 提交

answer

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

#define int long long
#define P pair<int,int>

const int mod = 1e9 + 7, inf = 1e17;

void run(){
    string s;
    cin >> s;
    int n = s.size();
    int ans = 0;
    vector<int> g;
    int ok = 0;
    for(int i=0;i<n;i++){
        int res = 1;
        while(i < n - 1 && s[i] == s[i + 1]){
            i ++;
            res ++;
        }
        g.push_back(res);
        ans += res / 2;
        ok |= (res % 2 == 0);
    }
    if(g.size() == 1){
        cout << ans << '\n';
        return;
    }
    if(s[0] == s[n - 1]){
        cout << ans << '\n';
    }
    else{
        cout << ans - ok << '\n';
    }
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    
    int T = 1;
    cin >> T;
    while(T --) run(); return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3620kb

input:

3
abccbbbbd
abcde
x

output:

2
0
0

result:

ok 3 lines

Test #2:

score: -100
Wrong Answer
time: 0ms
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 591st lines differ - expected: '2', found: '3'