#include <bits/stdc++.h>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fi first
#define se second
#define endl "\n"
#define rep(a,b,c) for(int a=b; a<c; a++)
#define rep2(a,b,c,d) for(ll a=b; a<c; a+=d)
#define repr(a,b,c) for(ll a=b-1; a>c-1; a--)
#define repa(a,b) for(const auto &a: b)
#define multicase() int t; cin>>t; while(t--)
#define fastIO() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define valid(c) cout<<(c ? "YES" : "NO")<<endl;
#define valid2(c,a,b) cout<<(c ? a : b)<<endl;
#define ll long long
#define pq_min(a) priority_queue<a, vector<a>, greater<a>>
#define pq_max(a) priority_queue<a>
#define pb push_back
#define mid ((l+r)>>1)
#define flush endl<<flush;
using namespace std;
const ll mod=998244353;
int main(){
fastIO();
int n;
cin>>n;
string s;
set<string> st;
ll t[11][62][62]{};
map<char,int> val;
rep(i,0,26){
val[i+'a']=i;
val[i+'A']=i+26;
}
rep(i,0,10) val[i+'0']=i+52;
rep(i,0,n){
cin>>s;
st.insert(s);
reverse(s.begin(),s.end());
st.insert(s);
}
repa(e,st) t[e.size()][val[e[0]]][val[e.back()]]++;
ll ans=0, aux;
rep(z,3,11){
ll C[62][62][62]{};
rep(i,0,62) rep(j,i,62) rep(k,j,62){
rep(l,0,62){
aux=t[z][i][l]*t[z][j][l];
aux=(aux<mod ? aux : aux%mod);
aux*=t[z][k][l];
aux=(aux<mod ? aux : aux%mod);
C[i][j][k]+=aux;
}
C[i][k][j]=C[j][i][k]=C[j][k][i]=C[k][i][j]=C[k][j][i]=C[i][j][k];
}
rep(i,0,62) rep(j,i,62) rep(k,j,62) rep(l,k,62){
int a[4]={1,1,1,1}, p;
if(i==j) a[1]+=a[0];
if(j==k) a[2]+=a[1];
if(k==l) a[3]+=a[2];
p=24/(a[0]*a[1]*a[2]*a[3]);
aux=C[i][j][k]*C[i][j][l];
aux=(aux<mod ? aux : aux%mod);
aux*=C[i][k][l];
aux=(aux<mod ? aux : aux%mod);
aux*=C[j][k][l];
aux=(aux<mod ? aux : aux%mod);
aux*=p;
aux=(aux<mod ? aux : aux%mod);
ans+=aux;
ans%=mod;
}
}
cout<<ans<<endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
140 ms |
17984 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
140 ms |
17984 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
140 ms |
17984 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
140 ms |
17984 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |