Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /********TheAnshul********/
- #include<bits/stdc++.h>
- #define ll long long
- #define pb push_back
- #define endl '\n'
- #define pii pair<ll int,ll int>
- #define vi vector<ll int>
- #define all(a) (a).begin(),(a).end()
- #define F first
- #define S second
- #define sz(x) (ll int)x.size()
- #define hell 1000000007
- #define rep(i,a,b) for(ll int i=a;i<b;i++)
- #define lbnd lower_bound
- #define ubnd upper_bound
- #define bs binary_search
- #define mp make_pair
- using namespace std;
- #define N 100005
- int main()
- {
- ios_base::sync_with_stdio(false);
- cin.tie(0);
- cout.tie(0);
- int TESTS=1;
- // cin>>TESTS;
- while(TESTS--)
- {
- ll n,ans=0;
- cin>>n;
- // vector<int>p(n);
- int pow[]={1,2,4,8,16,32,64,128,256,512};
- string s;
- vi p(1024,0);
- rep(i,0,n)
- {
- vector<int>v(10,0);
- int num=0;
- cin>>s;
- rep(j,0,s.length())
- {
- v[s[j]-48]=1;
- }
- rep(j,0,10)
- {
- if(v[j]==1)
- num+=pow[j];
- }
- // cout<<num<<endl;
- p[num]++;
- }
- // for(map<ll,ll>:: iterator it=mp.begin();it!=mp.end();it++)
- // cout<<it->F<<" "<<it->S<<endl;
- rep(i,0,1024)
- {
- rep(j,i+1,1024)
- {
- if((j | i)==1023)
- ans+=p[i]*p[j];
- }
- }
- ans+=p[1023]*(p[1023]-1);
- cout<<ans;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement