Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define int long long
- using namespace std;
- ifstream fin("perechi.in");
- ofstream fout("perechi.out");
- int val(char ch) {
- if(isdigit(ch))
- return ch - '0';
- return ch - 'A' + 10;
- }
- int32_t main() {
- fin.sync_with_stdio(false);
- fout.sync_with_stdio(false);
- fin.tie(nullptr);
- fout.tie(nullptr);
- string s;
- vector < int > f(65536);
- int ans = 0;
- while(fin >> s) {
- int mask1 = 0, mask2 = 0;
- for(char x : s)
- mask1 |= (1 << val(x));
- for(int i = 0; i < 16; ++i)
- if(!(mask1 & (1 << i)))
- mask2 |= (1 << i);
- ++f[mask1];
- ans += f[mask2];
- }
- fout << ans;
- }
Add Comment
Please, Sign In to add comment