QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#683263#9430. Left Shifting 2Akoasm_XWA 0ms3624kbC++201.1kb2024-10-27 19:45:532024-10-27 19:45:53

Judging History

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

  • [2024-10-27 19:45:53]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3624kb
  • [2024-10-27 19:45:53]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define int long long
typedef long long LL;

inline int read(){
	int x = 0 , f = 1 ; char c = getchar() ;
    while( c < '0' || c > '9' ) { if( c == '-' ) f = -1 ; c = getchar() ; } 
    while( c >= '0' && c <= '9' ) { x = x * 10 + c - '0' ; c = getchar() ; } 
    return x * f ;
}

void solve(){
    string s;
    cin>>s;
    int n = s.length();
    int ans = 0;
    if(s[0]==s[n-1]){
        for(int i=1;i<n;i++){
            if(s[i-1]==s[i]){
                ans++;
                i++;
            }
            else;
        }
    }
    else{
        for(int i=1;i<n;i++){
            if(s[i-1]==s[i]){
                ans++;
                i++;
            }
            else;
        }
        ans = max(0ll,ans - 1);
    }
    cout<<ans<<"\n";
    // printf("%d\n",ans);
}

signed main(){
    ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	// freopen("1.txt","r",stdin);
	int T = 1;
	T = read();
	while(T--) solve();
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3624kb

input:

3
abccbbbbd
abcde
x

output:

0
0
0

result:

wrong answer 1st lines differ - expected: '2', found: '0'