QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#684139#9430. Left Shifting 2Akoasm_XWA 2ms3604kbC++201.2kb2024-10-28 10:49:462024-10-28 10:49:46

Judging History

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

  • [2024-10-28 10:49:46]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3604kb
  • [2024-10-28 10:49:46]
  • 提交

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
#define endl "\n"
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(int T){
    string s;
    cin>>s;
    if(5000 - T==34) cout<<s<<endl;
    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<<endl;
    // 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();
    cin>>T;
	while(T--) solve(T);
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3
abccbbbbd
abcde
x

output:

2
0
0

result:

ok 3 lines

Test #2:

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

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
oteviii
0
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
1
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
0
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
...

result:

wrong answer 34th lines differ - expected: '1', found: 'oteviii'