#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(ll 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;
rep(z,0,10){
ll C[62][62][62]{};
rep(i,0,62) rep(j,0,62) rep(k,0,62) rep(l,0,62){
C[i][j][k]+=t[z][i][l]*t[z][j][l]*t[z][k][l];
C[i][j][k]%=mod;
}
rep(i,0,62) rep(j,0,62) rep(k,0,62) rep(l,0,62){
ans+=C[i][j][k]*C[i][j][l]*C[i][k][l]*C[j][k][l];
ans%=mod;
}
}
cout<<ans<<endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1078 ms |
16984 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1078 ms |
16984 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1078 ms |
16984 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1078 ms |
16984 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |