1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
| #include <bits/stdc++.h> using namespace std; using LL = long long; #define FOR(i, x, y) for (decay<decltype(y)>::type i = (x), _##i = (y); i < _##i; ++i) #define FORD(i, x, y) for (decay<decltype(x)>::type i = (x), _##i = (y); i > _##i; --i) #ifdef zerol #define dbg(args...) do { cout << "\033[32;1m" << #args << " -> "; err(args); } while (0) #else #define dbg(...) #endif void err() { cout << "\033[39;0m" << endl; } template<template<typename...> class T, typename t, typename... Args> void err(T<t> a, Args... args) { for (auto x: a) cout << x << ' '; err(args...); } template<typename T, typename... Args> void err(T a, Args... args) { cout << a << ' '; err(args...); } // ----------------------------------------------------------------------------- const int N = 1E6 + 100; int a[N]; int c[1 << 10];
string s; int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; FOR (i, 0, n) { cin >> s; for (char& c: s) a[i] |= 1 << (c - '0'); c[a[i]]++; } FOR (i, 0, 10) FOR (j, 0, 1 << 10) if ((1 << i) & j) c[j ^ (1 << i)] += c[j]; LL ans = 0; int M = (1 << 10) - 1; FOR (i, 0, n) ans += c[M ^ a[i]] - (a[i] == M); cout << ans / 2 << endl; }
|