feat(codeforces): 944

This commit is contained in:
Barrett Ruth 2025-04-15 14:24:37 -04:00
parent 24744ab5c0
commit c11932a0fb
20 changed files with 507 additions and 0 deletions

43
codeforces/944/d.cc Normal file
View file

@ -0,0 +1,43 @@
#include <bits/stdc++.h> // {{{
// https://codeforces.com/blog/entry/96344
#pragma GCC optimize("O2,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
using namespace std;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f64 = double;
using f128 = long double;
// }}}
void solve() {
string s;
cin >> s;
u32 ans = 0;
bool found = false;
for (u32 i = 0; i < s.size() - 1; ++i) {
ans += s[i] != s[i + 1];
found |= s[i] == '0' && s[i + 1] == '1';
}
cout << ans + 1 - found << '\n';
}
int main() { // {{{
cin.tie(nullptr)->sync_with_stdio(false);
cin.exceptions(cin.failbit);
int tc = 1;
cin >> tc;
for (int t = 0; t < tc; ++t) {
solve();
}
return 0;
}
// }}}