This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
using namespace std;
typedef long long ll;
int encode(char a, char b) {
return (a - 'A') * 26 + (b - 'A');
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int n;
cin >> n;
vector<string> arr(n);
vector<int> a(n), b(n), c(n), d(n);
for (int i = 0; i < n; i++) {
string x, y;
cin >> x >> y;
arr[i] = x + y;
a[i] = encode(arr[i][0], arr[i][1]);
b[i] = encode(arr[i][0], arr[i][2]);
c[i] = encode(arr[i][1], arr[i][3]);
d[i] = encode(arr[i][2], arr[i][3]);
}
ll ans = 0;
for (int i = 0; i < n; i++) {
for (int j = 0; j < i; j++) {
if (a[i] == d[j] || b[i] == c[j] || c[i] == b[j] || d[i] == a[j]) {
ans++;
}
}
}
cout << ans << '\n';
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... |