APS/SWEA
1289. 원재의 메모리 복구하기
문래동까마귀
2021. 8. 24. 21:19
#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
using namespace std;
int sun = 0;
void run(string bit){
sun++;
int cnt = 0;
int size = bit.size();
bool now = 1;
for (int i = 0; i < size; i++) {
int num = stoi(bit.substr(i,1));
if (num == now) {
cnt++;
now = !now;
}
}
cout << "#" << sun << " " << cnt << endl;
}
int main() {
int t;
cin >> t;
string bit;
for (int i = 0; i < t; i++) {
cin >> bit;
run(bit);
}
return 0;
}