#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][33][33][33];
int v[11][33][33];
int ans = 0;
int n,m,k;
map<char,int>mps;
vector<int>vs;
int ii(char ch){
return mps[ch];
}
void dfs(int i){
}
int cnt = 0;
void solve(){
cin >> n;
map<string,int>mp;
for(int i = 1;i<=n;i++){
string a;
cin >> a;
if(mp[a] == 0){
v[a.size()][ii(a[0])][ii(a[a.size()-1])] += 1;
}
mp[a] += 1;
reverse(all(a));
if(mp[a] == 0){
v[a.size()][ii(a[0])][ii(a[a.size()-1])] += 1;
}
mp[a] += 1;
}
for(int sz = 3;sz<=10;sz++){
for(int i = 0;i<cnt;i++){
for(int j = 0;j<cnt;j++){
for(int l = 0;l<cnt;l++){
for(int u = 0;u<cnt;u++){
g[sz][j][l][u] += ((v[sz][i][j]*v[sz][i][l]) % mod) * (v[sz][i][u])% mod;
g[sz][j][l][u] %= mod;
}
}
}
}
}
for(int sz = 3;sz<=10;sz++){
for(int i = 0;i<cnt;i++){
for(int j = 0;j<cnt;j++){
for(int l = 0;l<cnt;l++){
for(int u = 0;u<cnt;u++){
ans += (((g[sz][i][j][l] * g[sz][i][j][u])% mod) * g[sz][i][l][u]) % mod * g[sz][j][l][u] % mod;
ans %= mod;
}
}
}
}
}
cout << ans << '\n';
}
/*
*/
signed main()
{
for(int i = 0;i<='p'-'a';i+=1){
mps['a'+i] = cnt++;
}
for(int i = 0;i<='p'-'a';i+=1){
mps['A'+i] = cnt++;
}
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int tt=1;//cin>>tt>>n;
while(tt--)solve();
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
201 ms |
17036 KB |
Output is correct |
2 |
Correct |
218 ms |
18304 KB |
Output is correct |
3 |
Correct |
209 ms |
18048 KB |
Output is correct |
4 |
Correct |
211 ms |
18000 KB |
Output is correct |
5 |
Correct |
204 ms |
18004 KB |
Output is correct |
6 |
Correct |
201 ms |
17944 KB |
Output is correct |
7 |
Correct |
207 ms |
18004 KB |
Output is correct |
8 |
Correct |
211 ms |
18052 KB |
Output is correct |
9 |
Correct |
205 ms |
18000 KB |
Output is correct |
10 |
Correct |
200 ms |
17948 KB |
Output is correct |
11 |
Correct |
206 ms |
18000 KB |
Output is correct |
12 |
Correct |
210 ms |
18028 KB |
Output is correct |
13 |
Correct |
212 ms |
18000 KB |
Output is correct |
14 |
Correct |
224 ms |
18000 KB |
Output is correct |
15 |
Correct |
200 ms |
18004 KB |
Output is correct |
16 |
Correct |
216 ms |
17936 KB |
Output is correct |
17 |
Correct |
237 ms |
18040 KB |
Output is correct |
18 |
Correct |
204 ms |
18000 KB |
Output is correct |
19 |
Correct |
202 ms |
18024 KB |
Output is correct |
20 |
Correct |
239 ms |
18004 KB |
Output is correct |
21 |
Correct |
209 ms |
18032 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
201 ms |
17036 KB |
Output is correct |
2 |
Correct |
218 ms |
18304 KB |
Output is correct |
3 |
Correct |
209 ms |
18048 KB |
Output is correct |
4 |
Correct |
211 ms |
18000 KB |
Output is correct |
5 |
Correct |
204 ms |
18004 KB |
Output is correct |
6 |
Correct |
201 ms |
17944 KB |
Output is correct |
7 |
Correct |
207 ms |
18004 KB |
Output is correct |
8 |
Correct |
211 ms |
18052 KB |
Output is correct |
9 |
Correct |
205 ms |
18000 KB |
Output is correct |
10 |
Correct |
200 ms |
17948 KB |
Output is correct |
11 |
Correct |
206 ms |
18000 KB |
Output is correct |
12 |
Correct |
210 ms |
18028 KB |
Output is correct |
13 |
Correct |
212 ms |
18000 KB |
Output is correct |
14 |
Correct |
224 ms |
18000 KB |
Output is correct |
15 |
Correct |
200 ms |
18004 KB |
Output is correct |
16 |
Correct |
216 ms |
17936 KB |
Output is correct |
17 |
Correct |
237 ms |
18040 KB |
Output is correct |
18 |
Correct |
204 ms |
18000 KB |
Output is correct |
19 |
Correct |
202 ms |
18024 KB |
Output is correct |
20 |
Correct |
239 ms |
18004 KB |
Output is correct |
21 |
Correct |
209 ms |
18032 KB |
Output is correct |
22 |
Correct |
212 ms |
18884 KB |
Output is correct |
23 |
Correct |
213 ms |
18516 KB |
Output is correct |
24 |
Correct |
198 ms |
18512 KB |
Output is correct |
25 |
Correct |
210 ms |
18736 KB |
Output is correct |
26 |
Correct |
211 ms |
18512 KB |
Output is correct |
27 |
Correct |
219 ms |
18480 KB |
Output is correct |
28 |
Correct |
228 ms |
18576 KB |
Output is correct |
29 |
Correct |
200 ms |
18516 KB |
Output is correct |
30 |
Correct |
232 ms |
18384 KB |
Output is correct |
31 |
Correct |
222 ms |
18772 KB |
Output is correct |
32 |
Correct |
206 ms |
18512 KB |
Output is correct |
33 |
Correct |
203 ms |
18464 KB |
Output is correct |
34 |
Correct |
244 ms |
18484 KB |
Output is correct |
35 |
Correct |
200 ms |
18628 KB |
Output is correct |
36 |
Correct |
206 ms |
18636 KB |
Output is correct |
37 |
Correct |
206 ms |
18520 KB |
Output is correct |
38 |
Correct |
204 ms |
18512 KB |
Output is correct |
39 |
Correct |
204 ms |
18516 KB |
Output is correct |
40 |
Correct |
198 ms |
18512 KB |
Output is correct |
41 |
Correct |
211 ms |
18516 KB |
Output is correct |
42 |
Correct |
216 ms |
18640 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
201 ms |
17036 KB |
Output is correct |
2 |
Correct |
218 ms |
18304 KB |
Output is correct |
3 |
Correct |
209 ms |
18048 KB |
Output is correct |
4 |
Correct |
211 ms |
18000 KB |
Output is correct |
5 |
Correct |
204 ms |
18004 KB |
Output is correct |
6 |
Correct |
201 ms |
17944 KB |
Output is correct |
7 |
Correct |
207 ms |
18004 KB |
Output is correct |
8 |
Correct |
211 ms |
18052 KB |
Output is correct |
9 |
Correct |
205 ms |
18000 KB |
Output is correct |
10 |
Correct |
200 ms |
17948 KB |
Output is correct |
11 |
Correct |
206 ms |
18000 KB |
Output is correct |
12 |
Correct |
210 ms |
18028 KB |
Output is correct |
13 |
Correct |
212 ms |
18000 KB |
Output is correct |
14 |
Correct |
224 ms |
18000 KB |
Output is correct |
15 |
Correct |
200 ms |
18004 KB |
Output is correct |
16 |
Correct |
216 ms |
17936 KB |
Output is correct |
17 |
Correct |
237 ms |
18040 KB |
Output is correct |
18 |
Correct |
204 ms |
18000 KB |
Output is correct |
19 |
Correct |
202 ms |
18024 KB |
Output is correct |
20 |
Correct |
239 ms |
18004 KB |
Output is correct |
21 |
Correct |
209 ms |
18032 KB |
Output is correct |
22 |
Correct |
212 ms |
18884 KB |
Output is correct |
23 |
Correct |
213 ms |
18516 KB |
Output is correct |
24 |
Correct |
198 ms |
18512 KB |
Output is correct |
25 |
Correct |
210 ms |
18736 KB |
Output is correct |
26 |
Correct |
211 ms |
18512 KB |
Output is correct |
27 |
Correct |
219 ms |
18480 KB |
Output is correct |
28 |
Correct |
228 ms |
18576 KB |
Output is correct |
29 |
Correct |
200 ms |
18516 KB |
Output is correct |
30 |
Correct |
232 ms |
18384 KB |
Output is correct |
31 |
Correct |
222 ms |
18772 KB |
Output is correct |
32 |
Correct |
206 ms |
18512 KB |
Output is correct |
33 |
Correct |
203 ms |
18464 KB |
Output is correct |
34 |
Correct |
244 ms |
18484 KB |
Output is correct |
35 |
Correct |
200 ms |
18628 KB |
Output is correct |
36 |
Correct |
206 ms |
18636 KB |
Output is correct |
37 |
Correct |
206 ms |
18520 KB |
Output is correct |
38 |
Correct |
204 ms |
18512 KB |
Output is correct |
39 |
Correct |
204 ms |
18516 KB |
Output is correct |
40 |
Correct |
198 ms |
18512 KB |
Output is correct |
41 |
Correct |
211 ms |
18516 KB |
Output is correct |
42 |
Correct |
216 ms |
18640 KB |
Output is correct |
43 |
Correct |
199 ms |
18772 KB |
Output is correct |
44 |
Correct |
216 ms |
18772 KB |
Output is correct |
45 |
Correct |
214 ms |
18968 KB |
Output is correct |
46 |
Correct |
244 ms |
18808 KB |
Output is correct |
47 |
Correct |
201 ms |
18776 KB |
Output is correct |
48 |
Correct |
224 ms |
18940 KB |
Output is correct |
49 |
Correct |
204 ms |
18772 KB |
Output is correct |
50 |
Correct |
205 ms |
18704 KB |
Output is correct |
51 |
Correct |
208 ms |
18824 KB |
Output is correct |
52 |
Correct |
238 ms |
18680 KB |
Output is correct |
53 |
Correct |
204 ms |
18832 KB |
Output is correct |
54 |
Correct |
216 ms |
18680 KB |
Output is correct |
55 |
Correct |
238 ms |
18580 KB |
Output is correct |
56 |
Correct |
206 ms |
18788 KB |
Output is correct |
57 |
Correct |
207 ms |
18728 KB |
Output is correct |
58 |
Correct |
204 ms |
18784 KB |
Output is correct |
59 |
Correct |
203 ms |
18772 KB |
Output is correct |
60 |
Correct |
217 ms |
18652 KB |
Output is correct |
61 |
Correct |
236 ms |
18768 KB |
Output is correct |
62 |
Correct |
206 ms |
18812 KB |
Output is correct |
63 |
Correct |
209 ms |
18768 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
201 ms |
17036 KB |
Output is correct |
2 |
Correct |
218 ms |
18304 KB |
Output is correct |
3 |
Correct |
209 ms |
18048 KB |
Output is correct |
4 |
Correct |
211 ms |
18000 KB |
Output is correct |
5 |
Correct |
204 ms |
18004 KB |
Output is correct |
6 |
Correct |
201 ms |
17944 KB |
Output is correct |
7 |
Correct |
207 ms |
18004 KB |
Output is correct |
8 |
Correct |
211 ms |
18052 KB |
Output is correct |
9 |
Correct |
205 ms |
18000 KB |
Output is correct |
10 |
Correct |
200 ms |
17948 KB |
Output is correct |
11 |
Correct |
206 ms |
18000 KB |
Output is correct |
12 |
Correct |
210 ms |
18028 KB |
Output is correct |
13 |
Correct |
212 ms |
18000 KB |
Output is correct |
14 |
Correct |
224 ms |
18000 KB |
Output is correct |
15 |
Correct |
200 ms |
18004 KB |
Output is correct |
16 |
Correct |
216 ms |
17936 KB |
Output is correct |
17 |
Correct |
237 ms |
18040 KB |
Output is correct |
18 |
Correct |
204 ms |
18000 KB |
Output is correct |
19 |
Correct |
202 ms |
18024 KB |
Output is correct |
20 |
Correct |
239 ms |
18004 KB |
Output is correct |
21 |
Correct |
209 ms |
18032 KB |
Output is correct |
22 |
Correct |
212 ms |
18884 KB |
Output is correct |
23 |
Correct |
213 ms |
18516 KB |
Output is correct |
24 |
Correct |
198 ms |
18512 KB |
Output is correct |
25 |
Correct |
210 ms |
18736 KB |
Output is correct |
26 |
Correct |
211 ms |
18512 KB |
Output is correct |
27 |
Correct |
219 ms |
18480 KB |
Output is correct |
28 |
Correct |
228 ms |
18576 KB |
Output is correct |
29 |
Correct |
200 ms |
18516 KB |
Output is correct |
30 |
Correct |
232 ms |
18384 KB |
Output is correct |
31 |
Correct |
222 ms |
18772 KB |
Output is correct |
32 |
Correct |
206 ms |
18512 KB |
Output is correct |
33 |
Correct |
203 ms |
18464 KB |
Output is correct |
34 |
Correct |
244 ms |
18484 KB |
Output is correct |
35 |
Correct |
200 ms |
18628 KB |
Output is correct |
36 |
Correct |
206 ms |
18636 KB |
Output is correct |
37 |
Correct |
206 ms |
18520 KB |
Output is correct |
38 |
Correct |
204 ms |
18512 KB |
Output is correct |
39 |
Correct |
204 ms |
18516 KB |
Output is correct |
40 |
Correct |
198 ms |
18512 KB |
Output is correct |
41 |
Correct |
211 ms |
18516 KB |
Output is correct |
42 |
Correct |
216 ms |
18640 KB |
Output is correct |
43 |
Correct |
199 ms |
18772 KB |
Output is correct |
44 |
Correct |
216 ms |
18772 KB |
Output is correct |
45 |
Correct |
214 ms |
18968 KB |
Output is correct |
46 |
Correct |
244 ms |
18808 KB |
Output is correct |
47 |
Correct |
201 ms |
18776 KB |
Output is correct |
48 |
Correct |
224 ms |
18940 KB |
Output is correct |
49 |
Correct |
204 ms |
18772 KB |
Output is correct |
50 |
Correct |
205 ms |
18704 KB |
Output is correct |
51 |
Correct |
208 ms |
18824 KB |
Output is correct |
52 |
Correct |
238 ms |
18680 KB |
Output is correct |
53 |
Correct |
204 ms |
18832 KB |
Output is correct |
54 |
Correct |
216 ms |
18680 KB |
Output is correct |
55 |
Correct |
238 ms |
18580 KB |
Output is correct |
56 |
Correct |
206 ms |
18788 KB |
Output is correct |
57 |
Correct |
207 ms |
18728 KB |
Output is correct |
58 |
Correct |
204 ms |
18784 KB |
Output is correct |
59 |
Correct |
203 ms |
18772 KB |
Output is correct |
60 |
Correct |
217 ms |
18652 KB |
Output is correct |
61 |
Correct |
236 ms |
18768 KB |
Output is correct |
62 |
Correct |
206 ms |
18812 KB |
Output is correct |
63 |
Correct |
209 ms |
18768 KB |
Output is correct |
64 |
Incorrect |
204 ms |
19024 KB |
Output isn't correct |
65 |
Halted |
0 ms |
0 KB |
- |