#include<bits/stdc++.h>
using namespace std;
#define int long long
// int M = 62;
// string chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
int M = 32;
string chars = "abcdefghijklmnopABCDEFGHIJKLMNOP";
vector<vector<vector<int>>> cnt (11, vector<vector<int>> (M, vector<int> (M)));
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
map<char,int> mp;
for(int i = 0; i < M; i++) mp[chars[i]] = i;
int N; cin >> N;
set<string> seen;
for(int i = 0; i < N; i++){
string s; cin >> s;
if(seen.count(s)) continue;
cnt[s.length()][mp[s[0]]][mp[s[s.length() - 1]]]++;
seen.insert(s);
reverse(s.begin(), s.end());
if(seen.count(s)) continue;
cnt[s.length()][mp[s[0]]][mp[s[s.length() - 1]]]++;
seen.insert(s);
}
int MOD = 998244353;
int res = 0;
for(int len = 3; len <= 10; len++){
vector<vector<vector<int>>> dp (M, vector<vector<int>> (M, vector<int> (M)));
for(int i = 0; i < M; i++){
for(int j = 0; j < M; j++){
for(int k = 0; k < M; k++){
for(int l = 0; l < M; l++){
dp[i][j][k] += (cnt[len][i][l] * cnt[len][j][l] * cnt[len][k][l]) % MOD;
}
}
}
}
for(int i = 0; i < M; i++){
for(int j = 0; j < M; j++){
for(int k = 0; k < M; k++){
for(int l = 0; l < M; l++){
res += (dp[i][j][k] * dp[i][j][l] % MOD) * (dp[i][l][k] * dp[j][k][l] % MOD) % MOD;
res %= MOD;
}
}
}
}
}
cout << res << endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
445 ms |
15288 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
445 ms |
15288 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
445 ms |
15288 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
445 ms |
15288 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |