mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-12-24 17:32:00 +00:00
B2 - Tokitsukaze and Good 01-String (hard version)
https://codeforces.com/contest/1678/submission/156372600
This commit is contained in:
parent
746db3b9e8
commit
0b2e3efdac
35
Codeforces/1678/B2/B2.cpp
Normal file
35
Codeforces/1678/B2/B2.cpp
Normal 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;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user