QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#747763 | #9430. Left Shifting 2 | xzin# | WA | 5ms | 3644kb | C++14 | 791b | 2024-11-14 18:10:23 | 2024-11-14 18:10:24 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
int n, ans, k, num, sum;
string s;
void sl() {
cin>>s; n = s.length(); s += '!';
num = 1; k = 0; sum = 1; ans =0;
for(int i = 1; i <= n; i++) {
if(s[i] == s[i - 1]) num++;
else {
ans += num / 2;
if(num % 2 == 0) k = 1;
num = 1;
}
}
for(int i = 1;i < n; i++) {
if(s[i] == s[0]) sum++;
else break;
}
if(s[n - 1] == s[0]) {
for(int i = n - 1; i >= 1; i--) {
if(s[i] == s[0]) sum++;
else break;
}
}
else sum = 1;
if(sum < n && sum % 2 && k) ans--;
cout<<ans<<endl;
}
int main() {
int T; cin>>T;
while (T--) {
sl();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3644kb
input:
3 abccbbbbd abcde x
output:
2 0 0
result:
ok 3 lines
Test #2:
score: -100
Wrong Answer
time: 5ms
memory: 3640kb
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 578th lines differ - expected: '1', found: '0'