0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-12-24 17:32:00 +00:00

C - Detective Task

https://codeforces.com/contest/1675/submission/155959148
This commit is contained in:
Baoshuo Ren 2022-05-05 23:10:05 +08:00
parent bdc65eecf9
commit 4fa9af73d1
Signed by: baoshuo
GPG Key ID: 70F90A673FB1AB68

41
Codeforces/1675/C/C.cpp Normal file
View File

@ -0,0 +1,41 @@
#include <iostream>
#include <string>
using std::cin;
using std::cout;
const char endl = '\n';
const int N = 2e5 + 5;
int t, sum[N][2], ans;
std::string s;
int main() {
std::ios::sync_with_stdio(false);
cin >> t;
while (t--) {
ans = 0;
cin >> s;
for (int i = 0; i < s.size(); i++) {
if (i) {
sum[i][0] = sum[i - 1][0] + (s[i] == '0');
sum[i][1] = sum[i - 1][1] + (s[i] == '1');
} else {
sum[i][0] = s[i] == '0';
sum[i][1] = s[i] == '1';
}
}
for (int i = 0; i < s.size(); i++) {
ans += (sum[i][0] - (s[i] == '0')) == 0 && (sum[s.size() - 1][1] == sum[i][1]);
}
cout << ans << endl;
}
return 0;
}