#include <bits/stdc++.h>
using namespace std;
using ll = long long;
vector < map < vector <int>, int > > mp(16);
vector <int> temp;
string s[2];
int h[4];
int main()
{
int n,i;
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n;
ll rez = 0;
for(i = 1; i <= n; i++){
for(int e = 0; e < 2; e++){
cin.get();
cin >> s[e];
}
h[0] = (s[0][0] - 65) * 26 + (s[0][1] - 65);
h[2] = (s[1][0] - 65) * 26 + (s[1][1] - 65);
h[1] = (s[0][0] - 65) * 26 + (s[1][0] - 65);
h[3] = (s[0][1] - 65) * 26 + (s[1][1] - 65);
for(int e = 1; e < 16; e++){
for(int j = 0; j < 4; j++){
if((1 << j) & e) temp.push_back(h[j ^ 2]);
}
auto it = mp[e].find(temp);
if(it != mp[e].end()){
if(__builtin_popcount(e) & 1) rez += it->second;
else rez -= it->second;
it->second++;
}
temp.clear();
}
for(int e = 1; e < 16; e++){
for(int j = 0; j < 4; j++){
if((1 << j) & e) temp.push_back(h[j]);
}
mp[e][temp]++;
temp.clear();
}
}
cout << rez;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |