0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-09-19 01:45:25 +00:00

B2 - Tokitsukaze and Good 01-String (hard version)

https://codeforces.com/contest/1678/submission/156372600
This commit is contained in:
Baoshuo Ren 2022-05-09 09:27:31 +08:00
parent 746db3b9e8
commit 0b2e3efdac
Signed by: baoshuo
GPG Key ID: 70F90A673FB1AB68

35
Codeforces/1678/B2/B2.cpp Normal file
View File

@ -0,0 +1,35 @@
#include <iostream>
#include <string>
using std::cin;
using std::cout;
const char endl = '\n';
int t, n;
std::string s;
int main() {
std::ios::sync_with_stdio(false);
cin >> t;
while (t--) {
int ans1 = 0, ans2 = 0;
cin >> n >> s;
int p = 0;
for (int i = 0; i < s.size(); i += 2) {
if (s[i] ^ s[i + 1]) { // 二元组内不相同
ans1++;
} else if (s[i] != p) { // 新的一段
ans2++;
p = s[i];
}
}
cout << ans1 << ' ' << std::max(1, ans2) << endl;
}
return 0;
}