#include <bits/stdc++.h>
using namespace std;
int main()
{
ios::sync_with_stdio(0);
cin.tie(nullptr);
int n;
cin>>n;
long long int M = 998244353;
map<char, int> m;
for(int i=0; i<26; i++) m['a'+(char)i]=i;
for(int i=0; i<26; i++) m['A'+(char)i]=i+26;
for(int i=0; i<10; i++) m['0'+(char)i]=i+52;
long long int U[10][62][62];
for(int k=0; k<10; k++) for(int i=0; i<62; i++) for(int j=0; j<62; j++) U[k][i][j]=0;
for(int i=0; i<n; i++){
string s;
cin>>s;
int a=s.size()-1, b=m[s[0]];
int c = m[s[a]];
U[a][b][c]++;
if(b!=c){
U[a][c][b]++;
}else{
bool d = true;
for(int i=0; i<=a; i++){
if(s[i]!=s[a-i]){
d=false;
break;
}
}
if(d) U[a][b][c]++;
}
}
long long int H[62][62][62];
long long int ans=0;
for(int v=2; v<10; v++){
for(int k=0; k<62; k++) for(int i=k; i<62; i++) for(int j=i; j<62; j++) H[k][i][j]=0;
for(int i=0; i<62; i++){
for(int j=i; j<62; j++){
for(int k=j; k<62; k++){
for(int l=0; l<62; l++){
H[i][j][k] = (H[i][j][k]+(((U[v][i][l]*U[v][j][l])%M)*U[v][k][l]))%M;
}
}
}
}
for(int i=0; i<62; i++){
for(int j=i; j<62; j++){
for(int k=j; k<62; k++){
for(int l=k; l<62; l++){
long long int V = (((H[i][j][k]*H[i][j][l])%M)*((H[i][k][l]*H[j][k][l])%M))%M;
if(i!=j){
V*=4;
if(j!=k){
V*=3;
if(k!=l) V*=2;
}else if(j!=l){
V*=3;
}
}else if(j!=k){
if(l!=k){
V*=12;
}else{
V*=6;
}
}else if(k!=l){
V*=4;
}
ans+=V;
ans%=M;
}
}
}
}
}
cout<<ans<<endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
116 ms |
3464 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
116 ms |
3464 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
116 ms |
3464 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
116 ms |
3464 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |