fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. #define fu(i,a,b) for(int i = a; i <= b; i++)
  5. #define fd(i,a,b) for(int i = a; i >= b; i--)
  6. #define pb push_back
  7. #define int long long
  8. #define task "test"
  9. #define pii pair<int,int>
  10. const int MAXN = 1e5 + 1, MAXNN = 7e7 + 1, INF = 1e18, MOD = 1e9 + 7;
  11. int a[MAXN];
  12. int mp[MAXNN];
  13.  
  14. signed main(){
  15. ios_base::sync_with_stdio(false);
  16. cin.tie(NULL);
  17.  
  18. if(fopen(task ".inp","r")) {
  19. freopen(task ".inp","r",stdin);
  20. //freopen(task ".out","w",stdout);
  21. }
  22. int n; cin >> n;
  23. int res = 0;
  24. fu(i,1,n) {
  25. string s; cin >> s;
  26. vector<int> c(30);
  27. for(char x: s) c[x - 'a'] = (c[x - 'a'] + 1);
  28. int cur = 1;
  29. int m = 0;
  30. fu(cx,0,25) if(c[cx] & 1) m |= (1 << cx);
  31.  
  32. res += mp[m];
  33. fu(b,0,25) res += mp[(m ^ (1 << b))];
  34. mp[m]++;
  35.  
  36. }
  37. //fu(i,1,n) cout << a[i] << "\n";
  38. cout << res;
  39.  
  40. }
  41.  
  42.  
  43. /*
  44. 1 2 3 4 5 6
  45. 1 2 3 2 2 5 2 3
  46.  
  47. */
  48.  
Time limit exceeded #stdin #stdout 5s 5320KB
stdin
Standard input is empty
stdout
Standard output is empty