codeforces1678B1,2

https://codeforces.com/contest/1678/attachments/download/16089/Codeforces Round 789 Chinese Tutorial.pdf

#include <bits/stdc++.h>
using namespace std;
using LL = long long;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t;
    for (cin >> t; t; t -= 1) {
        int n, L = -1, x = 0, y = 0;
        string s;
        cin >> n >> s;
        for (int i = 0; i < n; i += 2) {
            if (s[i] != s[i + 1]) x += 1;
            else {
                if (L != s[i]) y += 1;
                L = s[i];
            }
        }
        cout << x << " " << max(y, 1) << "\n";
    }
}
posted @ 2022-05-09 14:29  zzq12138  阅读(26)  评论(0)    收藏  举报