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>
using namespace std;
int wyst[27][27][27][27];
//26 = nie obchodzi mnie co to za litera
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n,ind1,ind2,ind3,ind4;
long long int odp;
string a,b;
cin >> n;
odp = 0;
for (int x=0;x<n;x++){
cin >> a >> b;
for (int mask = 0;mask<(1<<4);mask++){
ind1 = 26; ind2 = 26; ind3 = 26; ind4 = 26;
if (mask&1){
ind1 = (int)a[0] - 65;
}
if (mask&2){
ind2 = (int)a[1] - 65;
}
if (mask&4){
ind3 = (int)b[0] - 65;
}
if (mask&8){
ind4 = (int)b[1] - 65;
}
wyst[ind1][ind2][ind3][ind4] += 1;
}
}
for (int x=0;x<26;x++){
for (int y=0;y<=x;y++){
odp += wyst[26][x][26][y] * wyst[x][26][y][26] - wyst[x][x][y][y] * wyst[x][x][y][y];
odp += wyst[26][26][x][y] * wyst[x][y][26][26] - wyst[x][y][y][26] * wyst[x][y][y][26] - wyst[26][y][y][x] * wyst[26][y][y][x] + wyst[x][y][y][x] * wyst[x][y][y][x];
}
odp += max(wyst[x][x][x][x] * (wyst[x][x][x][x]-1),0) / 2;
}
cout << odp << "\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... |