Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- struct vhash { int operator()(const vector<int> &V) const { int hash = 0; for(int i = 0; i < V.size(); ++i) { hash += V[i]; } return hash; } };
- unordered_map < vector <int>, int, vhash > g;
- int main() {
- freopen("cowpatibility.in", "r", stdin);
- freopen("cowpatibility.out", "w", stdout);
- ios_base::sync_with_stdio(false);
- cin.tie(0);
- int n;
- cin >> n;
- vector < vector <int> > a(n);
- for(int i = 0; i < n; ++i) {
- for(int j = 0; j < 5; ++j) {
- int x;
- cin >> x;
- a[i].push_back(x);
- }
- sort(a[i].begin(), a[i].end());
- }
- long long ans = 0;
- for(int i = 0; i < n; ++i) {
- for(int j = 1; j < (1 << 5); ++j) {
- vector <int> p;
- int cnt = 0;
- for(int x = 0; x < 5; ++x) {
- if((j >> x) & 1) {
- ++cnt;
- p.push_back(a[i][x]);
- }
- }
- if(cnt % 2) ans += g[p];
- else ans -= g[p];
- }
- for(int j = 1; j < (1 << 5); ++j) {
- vector <int> p;
- for(int x = 0; x < 5; ++x) {
- if((j >> x) & 1) {
- p.push_back(a[i][x]);
- }
- }
- g[p]++;
- }
- }
- cout << 1LL * n * (n - 1) / 2 - ans << '\n';
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement