Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- typedef long long ll;
- string s;
- int main(){
- // freopen("threedaysago.in", "r", stdin);
- cin >> s;
- ll flag = 0;
- ll res = 0;
- map<ll, ll> mp;
- mp[0] = 1;
- for(int i=0; i<s.size(); i++){
- flag^=(1<<(s[i]-'0'));
- /*
- get binary values which change according to
- the new string that is being considered from the string
- to process as decimal numbers which will be unique depending
- on the binary values
- */
- res+=mp[flag];
- mp[flag]++;
- /*
- calculation similar to prefix sum/map use in past problems
- where substrings need to be checked for amount that are valid
- to a certain case
- */
- }
- cout << res << '\n';
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement