QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#695549 | #9430. Left Shifting 2 | Czg19916 | WA | 5ms | 3576kb | C++14 | 663b | 2024-10-31 20:15:43 | 2024-10-31 20:15:43 |
Judging History
answer
#include<iostream>
#define int long long
using namespace std;
signed main(){
int T;cin>>T;
while(T--){
string s;cin>>s;
int cnt=1;
int ans=0;
int f=0;
if(s[0]==s[s.length()-1]) f=1;
for(int i=0;i<s.length();i++){
if(i<s.length()-1&&s[i]==s[i+1]){
cnt++;
}else if(cnt>=2){
if(f==0&&cnt%2==0) f=1,cnt--;
ans+=cnt/2;
cnt=1;
}
// cout<<i<<' '<<f<<' '<<cnt<<' '<<ans<<endl;
}
cout<<ans<<endl;
}
}
/*
cacxcacxc
bbbabbaabba
bxbab bxaxba
bxaxbxaxbab
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3576kb
input:
3 abccbbbbd abcde x
output:
2 0 0
result:
ok 3 lines
Test #2:
score: -100
Wrong Answer
time: 5ms
memory: 3532kb
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'