Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define ll long long
- int main()
- {
- ll n;
- cin>>n;
- tuple<ll,ll,ll> p[n+1];
- for (ll i=1; i<=n; i++){
- string s;
- cin>>s;
- map <char,ll> mp;
- for (ll i=0; i<s.length(); i++){
- mp[s[i]]++;
- }
- ll x=0, y=0;
- for (ll i=97; i<=122; i++){
- y = (mp[(char)i]%2) + (y<<1);
- }
- for (ll i=97; i<=122; i++){
- if (mp[(char)i]>0) x = (x<<1) + 1;
- else x = x<<1;
- }
- get<0>(p[i]) = s.length()%2;
- get<1>(p[i]) = x;
- get<2>(p[i]) = y;
- }
- ll ans=0;
- for (ll i=1; i<n; i++){
- for (ll j=i+1; i<=n; j++){
- bool x = get<0>(p[i]) ^ get<0>(p[j]);
- bool y = get<1>(p[i]) | get<1>(p[j]);
- ll mask = (1<<26) -1;
- y = y^mask;
- y = y&(y-1);
- bool z = get<2>(p[i]) & get<2>(p[j]);
- if (x && ~y && ~z) ans++;
- }
- }
- cout<<ans;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement