mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-12-24 17:51:58 +00:00
C - Detective Task
https://codeforces.com/contest/1675/submission/155959148
This commit is contained in:
parent
bdc65eecf9
commit
4fa9af73d1
41
Codeforces/1675/C/C.cpp
Normal file
41
Codeforces/1675/C/C.cpp
Normal 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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user