QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#629205 | #9430. Left Shifting 2 | KIRITO1211# | WA | 2ms | 3560kb | C++23 | 850b | 2024-10-11 08:57:25 | 2024-10-11 08:57:25 |
Judging History
answer
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define int long long
using ll = long long;
using i64 = long long;
const int mod = 998244353;
// #define DEBUG
// 线段树合并信息
void solve() {
std::string s;std::cin>>s;
int n = s.size();
int ans = 0;
int flg = 0;
for(int i = 0;i < n;i++){
int cnt = 1;
while(i + 1 < n && s[i] == s[i + 1]){
cnt++;
i++;
}
ans += cnt / 2;
if(cnt % 2 == 0) flg = 1;
}
if(flg) ans--;
std::cout<<ans<<'\n';
}
signed main() {
std::ios::sync_with_stdio(false);
std::cin.tie(0);
int t = 1;
// int res = 0;
// for(int i = 1;i <= 1145;i++) res |= i;
// std::cerr<<res<<'\n';
std::cin>>t;
while (t--) {
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3488kb
input:
3 abccbbbbd abcde x
output:
2 0 0
result:
ok 3 lines
Test #2:
score: -100
Wrong Answer
time: 2ms
memory: 3560kb
input:
5000 lfpbavjsmppdppkfwnyfmbdhptdswsoulrbhyjh cfliuqnynejgnxolzbdoztclzbozqomvioszk eiivcoqoymonrqgrjdtkts mdcvservaxcbioopfungsgkiftchwlmtbzqgaraovjknsgiegkvdbolmeunvrxrpscnf ujeqtidwtoikkqtygo llma qjfvgwrdhaazejsfgilnpmmhkefndzvyon kzwwpdpbrudqmwmjscllnnjyoepxophcoopvfepikouinuxx vftculoorxskpkxoz...
output:
1 0 0 0 0 0 1 4 0 0 1 1 0 1 1 3 0 0 5 6 0 0 5 2 0 1 3 1 0 3 0 1 0 1 1 0 1 4 1 3 1 0 1 5 3 0 3 0 0 1 7 0 0 6 1 2 0 1 0 0 4 1 2 4 3 1 3 2 3 0 2 0 0 0 2 0 2 2 0 4 0 5 5 0 3 0 4 0 0 2 1 0 2 0 1 6 1 2 0 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 2 3 3 1 2 0 1 1 4 2 1 3 0 1 1 2 0 1 2 0 4 0 1 1 ...
result:
wrong answer 13th lines differ - expected: '1', found: '0'