#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) x.begin(),x.end()
#define pb push_back
const int N=1e6 + 5 ;
const int inf = 1e18 + 7;
const int mod = 998244353;
int g[11][25][25];
int ans = 0;
int n,m,k;
vector<int>vs;
void dfs(int i){
if(i == 4){
for(int sz = 3;sz<=10;sz++){
int val = 1;
for(int j = 0;j<4;j++){
int sum = 0;
for(int k = 0;k<='p'-'a';k++){
int c = 1;
for(int l = 0;l<4;l++){
if(l == j)continue;
c *= g[sz][vs[l]][k];
}
sum += c;
sum %= mod;
}
val *= sum;
val %= mod;
}
ans += val;
ans %= mod;
}
return;
}
for(int l = 0;l<='p'-'a';l++){
vs.pb(l);
dfs(i + 1);
vs.pop_back();
}
}
void solve(){
cin >> n;
for(int i = 1;i<=n;i++){
string a;
cin >> a;
string b = a;
g[a.size()][a[0]-'a'][a[a.size()-1]-'a'] += 1;
reverse(all(a));
if(a != b){
g[a.size()][a[0]-'a'][a[a.size()-1]-'a'] += 1;
}
}
dfs(0);
cout << ans << '\n';
}
/*
*/
signed main()
{
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int tt=1;//cin>>tt>>n;
while(tt--)solve();
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
163 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
163 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
163 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
163 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |