#include <bits/stdc++.h>
#define SZ 47
using ll = long long;
ll rel[SZ][SZ];
ll tuplas[SZ][SZ][SZ];
ll MOD = 998244353;
std::map<char,int> mapinha;
int cur=0;
int valor(char ch){
if(mapinha.find(ch)!=mapinha.end())return mapinha[ch];
mapinha[ch]=cur;
++cur;
return mapinha[ch];
}
int main(){
std::ios::sync_with_stdio(false);
std::cin.tie(0);
std::cout.tie(0);
int N;
std::cin>>N;
std::map<std::string,bool> mapa[11];
for(int i=0;i!=N;++i){
std::string s;
std::cin >> s;
mapa[s.size()][s]=1;
std::reverse(s.begin(),s.end());
mapa[s.size()][s]=1;
}
ll ans=0;
for(int j=3;j<=10;++j){
for(auto&x:rel)for(auto&y:x)y=0;
for(auto&x:mapa[j]){
rel[valor(x.first[0])][valor(x.first.back())]++;
}
for(int i=0;i!=SZ;++i){
for(int j=i;j!=SZ;++j){
for(int k=j;k!=SZ;++k){
ll tot=0;
for(int u=0;u!=SZ;++u)tot=(tot+((rel[i][u]*rel[j][u]%MOD)*rel[k][u]))%MOD;
tuplas[i][j][k]=tuplas[i][k][j]=tuplas[j][i][k]=tuplas[j][k][i]=tuplas[k][i][j]=tuplas[k][j][i]=tot;
}
}
}
for(int i=0;i!=SZ;++i){
for(int j=0;j!=SZ;++j){
for(int k=0;k!=SZ;++k){
for(int l=0;l!=SZ;++l){
ans=(ans+(((tuplas[i][j][k]*tuplas[i][k][l]%MOD)*tuplas[k][l][j]%MOD)*tuplas[i][j][l]))%MOD;
}
}
}
}
}
std::cout<<ans<<"\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
673 ms |
15564 KB |
Output is correct |
2 |
Correct |
672 ms |
16060 KB |
Output is correct |
3 |
Correct |
669 ms |
16132 KB |
Output is correct |
4 |
Correct |
677 ms |
16124 KB |
Output is correct |
5 |
Correct |
663 ms |
16076 KB |
Output is correct |
6 |
Correct |
668 ms |
16132 KB |
Output is correct |
7 |
Correct |
660 ms |
16148 KB |
Output is correct |
8 |
Correct |
665 ms |
16076 KB |
Output is correct |
9 |
Correct |
663 ms |
16204 KB |
Output is correct |
10 |
Correct |
672 ms |
16140 KB |
Output is correct |
11 |
Correct |
661 ms |
16128 KB |
Output is correct |
12 |
Correct |
672 ms |
16052 KB |
Output is correct |
13 |
Correct |
667 ms |
16220 KB |
Output is correct |
14 |
Correct |
660 ms |
16204 KB |
Output is correct |
15 |
Correct |
674 ms |
16204 KB |
Output is correct |
16 |
Correct |
667 ms |
16116 KB |
Output is correct |
17 |
Correct |
666 ms |
16188 KB |
Output is correct |
18 |
Correct |
663 ms |
16204 KB |
Output is correct |
19 |
Correct |
673 ms |
16116 KB |
Output is correct |
20 |
Correct |
667 ms |
16192 KB |
Output is correct |
21 |
Correct |
663 ms |
16072 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
673 ms |
15564 KB |
Output is correct |
2 |
Correct |
672 ms |
16060 KB |
Output is correct |
3 |
Correct |
669 ms |
16132 KB |
Output is correct |
4 |
Correct |
677 ms |
16124 KB |
Output is correct |
5 |
Correct |
663 ms |
16076 KB |
Output is correct |
6 |
Correct |
668 ms |
16132 KB |
Output is correct |
7 |
Correct |
660 ms |
16148 KB |
Output is correct |
8 |
Correct |
665 ms |
16076 KB |
Output is correct |
9 |
Correct |
663 ms |
16204 KB |
Output is correct |
10 |
Correct |
672 ms |
16140 KB |
Output is correct |
11 |
Correct |
661 ms |
16128 KB |
Output is correct |
12 |
Correct |
672 ms |
16052 KB |
Output is correct |
13 |
Correct |
667 ms |
16220 KB |
Output is correct |
14 |
Correct |
660 ms |
16204 KB |
Output is correct |
15 |
Correct |
674 ms |
16204 KB |
Output is correct |
16 |
Correct |
667 ms |
16116 KB |
Output is correct |
17 |
Correct |
666 ms |
16188 KB |
Output is correct |
18 |
Correct |
663 ms |
16204 KB |
Output is correct |
19 |
Correct |
673 ms |
16116 KB |
Output is correct |
20 |
Correct |
667 ms |
16192 KB |
Output is correct |
21 |
Correct |
663 ms |
16072 KB |
Output is correct |
22 |
Correct |
688 ms |
16884 KB |
Output is correct |
23 |
Correct |
688 ms |
16788 KB |
Output is correct |
24 |
Correct |
679 ms |
16796 KB |
Output is correct |
25 |
Correct |
691 ms |
16780 KB |
Output is correct |
26 |
Correct |
671 ms |
16776 KB |
Output is correct |
27 |
Correct |
686 ms |
16972 KB |
Output is correct |
28 |
Correct |
682 ms |
16796 KB |
Output is correct |
29 |
Correct |
683 ms |
16712 KB |
Output is correct |
30 |
Correct |
677 ms |
16780 KB |
Output is correct |
31 |
Correct |
678 ms |
16716 KB |
Output is correct |
32 |
Correct |
682 ms |
16856 KB |
Output is correct |
33 |
Correct |
675 ms |
16808 KB |
Output is correct |
34 |
Correct |
673 ms |
16908 KB |
Output is correct |
35 |
Correct |
676 ms |
16784 KB |
Output is correct |
36 |
Correct |
676 ms |
16792 KB |
Output is correct |
37 |
Correct |
677 ms |
16724 KB |
Output is correct |
38 |
Correct |
675 ms |
16816 KB |
Output is correct |
39 |
Correct |
679 ms |
16788 KB |
Output is correct |
40 |
Correct |
704 ms |
16844 KB |
Output is correct |
41 |
Correct |
680 ms |
16796 KB |
Output is correct |
42 |
Correct |
687 ms |
16800 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
673 ms |
15564 KB |
Output is correct |
2 |
Correct |
672 ms |
16060 KB |
Output is correct |
3 |
Correct |
669 ms |
16132 KB |
Output is correct |
4 |
Correct |
677 ms |
16124 KB |
Output is correct |
5 |
Correct |
663 ms |
16076 KB |
Output is correct |
6 |
Correct |
668 ms |
16132 KB |
Output is correct |
7 |
Correct |
660 ms |
16148 KB |
Output is correct |
8 |
Correct |
665 ms |
16076 KB |
Output is correct |
9 |
Correct |
663 ms |
16204 KB |
Output is correct |
10 |
Correct |
672 ms |
16140 KB |
Output is correct |
11 |
Correct |
661 ms |
16128 KB |
Output is correct |
12 |
Correct |
672 ms |
16052 KB |
Output is correct |
13 |
Correct |
667 ms |
16220 KB |
Output is correct |
14 |
Correct |
660 ms |
16204 KB |
Output is correct |
15 |
Correct |
674 ms |
16204 KB |
Output is correct |
16 |
Correct |
667 ms |
16116 KB |
Output is correct |
17 |
Correct |
666 ms |
16188 KB |
Output is correct |
18 |
Correct |
663 ms |
16204 KB |
Output is correct |
19 |
Correct |
673 ms |
16116 KB |
Output is correct |
20 |
Correct |
667 ms |
16192 KB |
Output is correct |
21 |
Correct |
663 ms |
16072 KB |
Output is correct |
22 |
Correct |
688 ms |
16884 KB |
Output is correct |
23 |
Correct |
688 ms |
16788 KB |
Output is correct |
24 |
Correct |
679 ms |
16796 KB |
Output is correct |
25 |
Correct |
691 ms |
16780 KB |
Output is correct |
26 |
Correct |
671 ms |
16776 KB |
Output is correct |
27 |
Correct |
686 ms |
16972 KB |
Output is correct |
28 |
Correct |
682 ms |
16796 KB |
Output is correct |
29 |
Correct |
683 ms |
16712 KB |
Output is correct |
30 |
Correct |
677 ms |
16780 KB |
Output is correct |
31 |
Correct |
678 ms |
16716 KB |
Output is correct |
32 |
Correct |
682 ms |
16856 KB |
Output is correct |
33 |
Correct |
675 ms |
16808 KB |
Output is correct |
34 |
Correct |
673 ms |
16908 KB |
Output is correct |
35 |
Correct |
676 ms |
16784 KB |
Output is correct |
36 |
Correct |
676 ms |
16792 KB |
Output is correct |
37 |
Correct |
677 ms |
16724 KB |
Output is correct |
38 |
Correct |
675 ms |
16816 KB |
Output is correct |
39 |
Correct |
679 ms |
16788 KB |
Output is correct |
40 |
Correct |
704 ms |
16844 KB |
Output is correct |
41 |
Correct |
680 ms |
16796 KB |
Output is correct |
42 |
Correct |
687 ms |
16800 KB |
Output is correct |
43 |
Correct |
735 ms |
17088 KB |
Output is correct |
44 |
Correct |
748 ms |
17012 KB |
Output is correct |
45 |
Correct |
741 ms |
17004 KB |
Output is correct |
46 |
Correct |
747 ms |
17128 KB |
Output is correct |
47 |
Correct |
759 ms |
16996 KB |
Output is correct |
48 |
Correct |
758 ms |
17000 KB |
Output is correct |
49 |
Correct |
759 ms |
17056 KB |
Output is correct |
50 |
Correct |
742 ms |
17004 KB |
Output is correct |
51 |
Correct |
740 ms |
16996 KB |
Output is correct |
52 |
Correct |
763 ms |
16920 KB |
Output is correct |
53 |
Correct |
747 ms |
17012 KB |
Output is correct |
54 |
Correct |
755 ms |
16940 KB |
Output is correct |
55 |
Correct |
755 ms |
17004 KB |
Output is correct |
56 |
Correct |
736 ms |
17008 KB |
Output is correct |
57 |
Correct |
739 ms |
16988 KB |
Output is correct |
58 |
Correct |
763 ms |
17008 KB |
Output is correct |
59 |
Correct |
737 ms |
17000 KB |
Output is correct |
60 |
Correct |
740 ms |
16928 KB |
Output is correct |
61 |
Correct |
743 ms |
16996 KB |
Output is correct |
62 |
Correct |
746 ms |
17000 KB |
Output is correct |
63 |
Correct |
763 ms |
17000 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
673 ms |
15564 KB |
Output is correct |
2 |
Correct |
672 ms |
16060 KB |
Output is correct |
3 |
Correct |
669 ms |
16132 KB |
Output is correct |
4 |
Correct |
677 ms |
16124 KB |
Output is correct |
5 |
Correct |
663 ms |
16076 KB |
Output is correct |
6 |
Correct |
668 ms |
16132 KB |
Output is correct |
7 |
Correct |
660 ms |
16148 KB |
Output is correct |
8 |
Correct |
665 ms |
16076 KB |
Output is correct |
9 |
Correct |
663 ms |
16204 KB |
Output is correct |
10 |
Correct |
672 ms |
16140 KB |
Output is correct |
11 |
Correct |
661 ms |
16128 KB |
Output is correct |
12 |
Correct |
672 ms |
16052 KB |
Output is correct |
13 |
Correct |
667 ms |
16220 KB |
Output is correct |
14 |
Correct |
660 ms |
16204 KB |
Output is correct |
15 |
Correct |
674 ms |
16204 KB |
Output is correct |
16 |
Correct |
667 ms |
16116 KB |
Output is correct |
17 |
Correct |
666 ms |
16188 KB |
Output is correct |
18 |
Correct |
663 ms |
16204 KB |
Output is correct |
19 |
Correct |
673 ms |
16116 KB |
Output is correct |
20 |
Correct |
667 ms |
16192 KB |
Output is correct |
21 |
Correct |
663 ms |
16072 KB |
Output is correct |
22 |
Correct |
688 ms |
16884 KB |
Output is correct |
23 |
Correct |
688 ms |
16788 KB |
Output is correct |
24 |
Correct |
679 ms |
16796 KB |
Output is correct |
25 |
Correct |
691 ms |
16780 KB |
Output is correct |
26 |
Correct |
671 ms |
16776 KB |
Output is correct |
27 |
Correct |
686 ms |
16972 KB |
Output is correct |
28 |
Correct |
682 ms |
16796 KB |
Output is correct |
29 |
Correct |
683 ms |
16712 KB |
Output is correct |
30 |
Correct |
677 ms |
16780 KB |
Output is correct |
31 |
Correct |
678 ms |
16716 KB |
Output is correct |
32 |
Correct |
682 ms |
16856 KB |
Output is correct |
33 |
Correct |
675 ms |
16808 KB |
Output is correct |
34 |
Correct |
673 ms |
16908 KB |
Output is correct |
35 |
Correct |
676 ms |
16784 KB |
Output is correct |
36 |
Correct |
676 ms |
16792 KB |
Output is correct |
37 |
Correct |
677 ms |
16724 KB |
Output is correct |
38 |
Correct |
675 ms |
16816 KB |
Output is correct |
39 |
Correct |
679 ms |
16788 KB |
Output is correct |
40 |
Correct |
704 ms |
16844 KB |
Output is correct |
41 |
Correct |
680 ms |
16796 KB |
Output is correct |
42 |
Correct |
687 ms |
16800 KB |
Output is correct |
43 |
Correct |
735 ms |
17088 KB |
Output is correct |
44 |
Correct |
748 ms |
17012 KB |
Output is correct |
45 |
Correct |
741 ms |
17004 KB |
Output is correct |
46 |
Correct |
747 ms |
17128 KB |
Output is correct |
47 |
Correct |
759 ms |
16996 KB |
Output is correct |
48 |
Correct |
758 ms |
17000 KB |
Output is correct |
49 |
Correct |
759 ms |
17056 KB |
Output is correct |
50 |
Correct |
742 ms |
17004 KB |
Output is correct |
51 |
Correct |
740 ms |
16996 KB |
Output is correct |
52 |
Correct |
763 ms |
16920 KB |
Output is correct |
53 |
Correct |
747 ms |
17012 KB |
Output is correct |
54 |
Correct |
755 ms |
16940 KB |
Output is correct |
55 |
Correct |
755 ms |
17004 KB |
Output is correct |
56 |
Correct |
736 ms |
17008 KB |
Output is correct |
57 |
Correct |
739 ms |
16988 KB |
Output is correct |
58 |
Correct |
763 ms |
17008 KB |
Output is correct |
59 |
Correct |
737 ms |
17000 KB |
Output is correct |
60 |
Correct |
740 ms |
16928 KB |
Output is correct |
61 |
Correct |
743 ms |
16996 KB |
Output is correct |
62 |
Correct |
746 ms |
17000 KB |
Output is correct |
63 |
Correct |
763 ms |
17000 KB |
Output is correct |
64 |
Runtime error |
854 ms |
34164 KB |
Execution killed with signal 11 |
65 |
Halted |
0 ms |
0 KB |
- |