QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#683263 | #9430. Left Shifting 2 | Akoasm_X | WA | 0ms | 3624kb | C++20 | 1.1kb | 2024-10-27 19:45:53 | 2024-10-27 19:45:53 |
Judging History
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'