mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-11-08 14:18:47 +00:00
B1 - Tokitsukaze and Good 01-String (easy version)
https://codeforces.com/contest/1678/submission/156370622
This commit is contained in:
parent
604313a57b
commit
746db3b9e8
39
Codeforces/1678/B1/B1.cpp
Normal file
39
Codeforces/1678/B1/B1.cpp
Normal file
@ -0,0 +1,39 @@
|
||||
#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 ans = 0;
|
||||
|
||||
cin >> n >> s;
|
||||
|
||||
for (int i = 1, t = 1; i < s.size(); i++) {
|
||||
if (s[i] != s[i - 1]) {
|
||||
if (t & 1) {
|
||||
s[i] = s[i - 1];
|
||||
ans++;
|
||||
t++;
|
||||
} else {
|
||||
t = 1;
|
||||
}
|
||||
} else {
|
||||
t++;
|
||||
}
|
||||
}
|
||||
|
||||
cout << ans << endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user