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;
- pair <ll,string> p[n+1];
- for (ll i=1; i<=n; i++){
- string s;
- cin>>s;
- ll x=s.length();
- map <char,ll> mp;
- for (ll i=0; i<x; i++){
- mp[s[i]]++;
- }
- string y="";
- for (ll i=97; i<=122; i++){
- y += to_string((mp[(char)i]==0)?(0):((mp[(char)i]%2)?(1):(2)));
- }
- // debugger(1)
- // cout<<"x = "<<x<<"\n";
- // cout<<"y = "<<y<<"\n";
- p[i] = make_pair(x,y);
- }
- ll ans=0;
- // cout<<"pairs generated, n^2 iterations begin\n";
- for (ll i=1; i<n; i++){
- for (ll j=i+1; j<=n; j++){
- // debugger(2)
- // cout<<"for the iteration, i = "<<i<<" and j = "<<j<<"\n";
- if ((p[i].first+p[j].first)%2==0) continue;
- // debugger(3)
- // cout<<"odd length right? = "<<(p[i].first+p[j].first)%2<<"\n";
- string s="";
- for (ll k=0; k<26; k++){
- ll z=(p[i].second)[k]-48+(p[j].second)[k]-48;
- s += to_string((z==0)?(0):((z%2)?(1):(2)));
- // debugger(4)
- // cout<<s<<"\n";
- }
- // cout<<"final string = "<<s<<"\n";
- ll e=0, f=0;
- for (ll k=0; k<26; k++){
- if (s[k]-48==0) e++;
- if (s[k]-48==2) f++;
- }
- // debugger(5)
- // cout<<"e = "<<e<<"\n";
- // cout<<"f = "<<f<<"\n";
- if (e==1 && f==0) ans++;
- // cout<<"ans = "<<ans<<"\n";
- }
- }
- cout<<ans;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement