QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#163628#6867. String Problemjrjyy#AC ✓1ms3732kbC++20482b2023-09-04 13:08:512023-09-04 13:08:52

Judging History

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

  • [2023-09-04 13:08:52]
  • 评测
  • 测评结果:AC
  • 用时:1ms
  • 内存:3732kb
  • [2023-09-04 13:08:51]
  • 提交

answer

#include <bits/stdc++.h>

using i64 = long long;

void solve() {
    std::string s;
    std::cin >> s;

    int ans = 0;
    for (int l = 0, r; l < int(s.size()); l = r) {
        for (r = l; r < int(s.size()) && s[r] == s[l]; ++r);
        ans += r - l - 1;
    }

    std::cout << ans << '\n';
}

int main() {
    std::cin.tie(nullptr)->sync_with_stdio(false);

    int t;
    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: 3732kb

input:

16
abcdefg
pqtcuxgggzxwviimecjcewjagmkozprogmrcjzjsagqvozkubvxitikzuxpwogkuudzgfiyfqodgnparkxbdilceisaxantvqsdxcbdspgyfvzyhyzkgkolvinujangtijqkkvfbddiaeghffrnsgapoojzqwhlgsetezygfdofkvnpcgewohlfvuentobzgfslgstlwhrgeexjmbfbirgflmvecwgjdawjtpvrymxfswoezthimnpycmeekmnnnlxgaszzewgyuuctpkdczvcdhgistxfijc...

output:

0
3845
3864
3765
25214
25033
1
1
24911
5041
4981
9999
9999
3829
3872
3856

result:

ok 16 lines