#include <bits/stdc++.h>
using namespace std;
#define int long
const int B = 62, LIM = 8, M = 998244353;
int get(char c) {
if(c < 60) return c - 48;
return c - (c < 95 ? 55 : 61);
}
int n, a[LIM][B][B], b[LIM][B][B][B], res;
map<string, bool> inp;
int i, j, k, l, x;
#define c(i, j, k, l) ((b[L][i][j][l] * b[L][j][k][l]) % M)
signed main() {
cin >> n;
while(n--) {
string s; cin >> s;
i = size(s);
if(inp[s]) continue;
string t = s;
reverse(begin(t), end(t));
inp[s] = inp[t] = 1;
int z = get(s[0]), y = get(end(s)[-1]);
++a[i-3][z][y];
if(s != t) ++a[i-3][y][z];
}
for(int L = 0; L < LIM; L++) {
for(int i = 0; i < B; i++) for(int j = 0; j < B; j++) for(int k = 0; k < B; k++) for(int x = 0; x < B; x++) b[L][i][j][k] += a[L][i][x] * a[L][j][x] * a[L][k][x];
for(int i = 0; i < B; i++) for(int j = 0; j < B; j++) for(int k = 0; k < B; k++) b[L][i][j][k] %= M;
for(int i = 0; i < B; i++) for(int j = 0; j < B; j++) for(int k = 0; k < B; k++) for(int l = 0; l < B; l++) res += (c(i, j, k, l) * c(l, k, j, i)) % M;
}
cout << res % M;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
705 ms |
30800 KB |
Output is correct |
2 |
Correct |
712 ms |
30724 KB |
Output is correct |
3 |
Correct |
692 ms |
30548 KB |
Output is correct |
4 |
Correct |
695 ms |
30560 KB |
Output is correct |
5 |
Correct |
709 ms |
30704 KB |
Output is correct |
6 |
Correct |
717 ms |
30916 KB |
Output is correct |
7 |
Correct |
721 ms |
30952 KB |
Output is correct |
8 |
Correct |
711 ms |
30864 KB |
Output is correct |
9 |
Correct |
728 ms |
30732 KB |
Output is correct |
10 |
Correct |
698 ms |
30656 KB |
Output is correct |
11 |
Correct |
694 ms |
30548 KB |
Output is correct |
12 |
Correct |
703 ms |
30780 KB |
Output is correct |
13 |
Correct |
702 ms |
30800 KB |
Output is correct |
14 |
Correct |
703 ms |
30784 KB |
Output is correct |
15 |
Correct |
719 ms |
30744 KB |
Output is correct |
16 |
Correct |
696 ms |
30712 KB |
Output is correct |
17 |
Correct |
694 ms |
30688 KB |
Output is correct |
18 |
Correct |
762 ms |
30656 KB |
Output is correct |
19 |
Correct |
705 ms |
30608 KB |
Output is correct |
20 |
Correct |
701 ms |
30700 KB |
Output is correct |
21 |
Correct |
704 ms |
30804 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
705 ms |
30800 KB |
Output is correct |
2 |
Correct |
712 ms |
30724 KB |
Output is correct |
3 |
Correct |
692 ms |
30548 KB |
Output is correct |
4 |
Correct |
695 ms |
30560 KB |
Output is correct |
5 |
Correct |
709 ms |
30704 KB |
Output is correct |
6 |
Correct |
717 ms |
30916 KB |
Output is correct |
7 |
Correct |
721 ms |
30952 KB |
Output is correct |
8 |
Correct |
711 ms |
30864 KB |
Output is correct |
9 |
Correct |
728 ms |
30732 KB |
Output is correct |
10 |
Correct |
698 ms |
30656 KB |
Output is correct |
11 |
Correct |
694 ms |
30548 KB |
Output is correct |
12 |
Correct |
703 ms |
30780 KB |
Output is correct |
13 |
Correct |
702 ms |
30800 KB |
Output is correct |
14 |
Correct |
703 ms |
30784 KB |
Output is correct |
15 |
Correct |
719 ms |
30744 KB |
Output is correct |
16 |
Correct |
696 ms |
30712 KB |
Output is correct |
17 |
Correct |
694 ms |
30688 KB |
Output is correct |
18 |
Correct |
762 ms |
30656 KB |
Output is correct |
19 |
Correct |
705 ms |
30608 KB |
Output is correct |
20 |
Correct |
701 ms |
30700 KB |
Output is correct |
21 |
Correct |
704 ms |
30804 KB |
Output is correct |
22 |
Correct |
709 ms |
31572 KB |
Output is correct |
23 |
Correct |
709 ms |
31212 KB |
Output is correct |
24 |
Correct |
694 ms |
31364 KB |
Output is correct |
25 |
Correct |
700 ms |
31316 KB |
Output is correct |
26 |
Correct |
704 ms |
31516 KB |
Output is correct |
27 |
Correct |
697 ms |
31460 KB |
Output is correct |
28 |
Correct |
766 ms |
31500 KB |
Output is correct |
29 |
Correct |
693 ms |
31312 KB |
Output is correct |
30 |
Correct |
723 ms |
31236 KB |
Output is correct |
31 |
Correct |
717 ms |
31828 KB |
Output is correct |
32 |
Correct |
699 ms |
31308 KB |
Output is correct |
33 |
Correct |
709 ms |
31572 KB |
Output is correct |
34 |
Correct |
750 ms |
31316 KB |
Output is correct |
35 |
Correct |
701 ms |
31316 KB |
Output is correct |
36 |
Correct |
706 ms |
31316 KB |
Output is correct |
37 |
Correct |
699 ms |
31316 KB |
Output is correct |
38 |
Correct |
709 ms |
31352 KB |
Output is correct |
39 |
Correct |
702 ms |
31352 KB |
Output is correct |
40 |
Correct |
696 ms |
31288 KB |
Output is correct |
41 |
Correct |
732 ms |
31356 KB |
Output is correct |
42 |
Correct |
737 ms |
31360 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
705 ms |
30800 KB |
Output is correct |
2 |
Correct |
712 ms |
30724 KB |
Output is correct |
3 |
Correct |
692 ms |
30548 KB |
Output is correct |
4 |
Correct |
695 ms |
30560 KB |
Output is correct |
5 |
Correct |
709 ms |
30704 KB |
Output is correct |
6 |
Correct |
717 ms |
30916 KB |
Output is correct |
7 |
Correct |
721 ms |
30952 KB |
Output is correct |
8 |
Correct |
711 ms |
30864 KB |
Output is correct |
9 |
Correct |
728 ms |
30732 KB |
Output is correct |
10 |
Correct |
698 ms |
30656 KB |
Output is correct |
11 |
Correct |
694 ms |
30548 KB |
Output is correct |
12 |
Correct |
703 ms |
30780 KB |
Output is correct |
13 |
Correct |
702 ms |
30800 KB |
Output is correct |
14 |
Correct |
703 ms |
30784 KB |
Output is correct |
15 |
Correct |
719 ms |
30744 KB |
Output is correct |
16 |
Correct |
696 ms |
30712 KB |
Output is correct |
17 |
Correct |
694 ms |
30688 KB |
Output is correct |
18 |
Correct |
762 ms |
30656 KB |
Output is correct |
19 |
Correct |
705 ms |
30608 KB |
Output is correct |
20 |
Correct |
701 ms |
30700 KB |
Output is correct |
21 |
Correct |
704 ms |
30804 KB |
Output is correct |
22 |
Correct |
709 ms |
31572 KB |
Output is correct |
23 |
Correct |
709 ms |
31212 KB |
Output is correct |
24 |
Correct |
694 ms |
31364 KB |
Output is correct |
25 |
Correct |
700 ms |
31316 KB |
Output is correct |
26 |
Correct |
704 ms |
31516 KB |
Output is correct |
27 |
Correct |
697 ms |
31460 KB |
Output is correct |
28 |
Correct |
766 ms |
31500 KB |
Output is correct |
29 |
Correct |
693 ms |
31312 KB |
Output is correct |
30 |
Correct |
723 ms |
31236 KB |
Output is correct |
31 |
Correct |
717 ms |
31828 KB |
Output is correct |
32 |
Correct |
699 ms |
31308 KB |
Output is correct |
33 |
Correct |
709 ms |
31572 KB |
Output is correct |
34 |
Correct |
750 ms |
31316 KB |
Output is correct |
35 |
Correct |
701 ms |
31316 KB |
Output is correct |
36 |
Correct |
706 ms |
31316 KB |
Output is correct |
37 |
Correct |
699 ms |
31316 KB |
Output is correct |
38 |
Correct |
709 ms |
31352 KB |
Output is correct |
39 |
Correct |
702 ms |
31352 KB |
Output is correct |
40 |
Correct |
696 ms |
31288 KB |
Output is correct |
41 |
Correct |
732 ms |
31356 KB |
Output is correct |
42 |
Correct |
737 ms |
31360 KB |
Output is correct |
43 |
Correct |
697 ms |
31624 KB |
Output is correct |
44 |
Correct |
686 ms |
31812 KB |
Output is correct |
45 |
Correct |
697 ms |
31648 KB |
Output is correct |
46 |
Correct |
706 ms |
31576 KB |
Output is correct |
47 |
Correct |
700 ms |
31572 KB |
Output is correct |
48 |
Correct |
716 ms |
31828 KB |
Output is correct |
49 |
Correct |
696 ms |
31572 KB |
Output is correct |
50 |
Correct |
704 ms |
31524 KB |
Output is correct |
51 |
Correct |
714 ms |
31608 KB |
Output is correct |
52 |
Correct |
701 ms |
31572 KB |
Output is correct |
53 |
Correct |
702 ms |
31760 KB |
Output is correct |
54 |
Correct |
700 ms |
31628 KB |
Output is correct |
55 |
Correct |
696 ms |
31604 KB |
Output is correct |
56 |
Correct |
694 ms |
31596 KB |
Output is correct |
57 |
Correct |
707 ms |
31496 KB |
Output is correct |
58 |
Correct |
705 ms |
31432 KB |
Output is correct |
59 |
Correct |
754 ms |
31616 KB |
Output is correct |
60 |
Correct |
713 ms |
31608 KB |
Output is correct |
61 |
Correct |
701 ms |
31660 KB |
Output is correct |
62 |
Correct |
694 ms |
31460 KB |
Output is correct |
63 |
Correct |
713 ms |
31544 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
705 ms |
30800 KB |
Output is correct |
2 |
Correct |
712 ms |
30724 KB |
Output is correct |
3 |
Correct |
692 ms |
30548 KB |
Output is correct |
4 |
Correct |
695 ms |
30560 KB |
Output is correct |
5 |
Correct |
709 ms |
30704 KB |
Output is correct |
6 |
Correct |
717 ms |
30916 KB |
Output is correct |
7 |
Correct |
721 ms |
30952 KB |
Output is correct |
8 |
Correct |
711 ms |
30864 KB |
Output is correct |
9 |
Correct |
728 ms |
30732 KB |
Output is correct |
10 |
Correct |
698 ms |
30656 KB |
Output is correct |
11 |
Correct |
694 ms |
30548 KB |
Output is correct |
12 |
Correct |
703 ms |
30780 KB |
Output is correct |
13 |
Correct |
702 ms |
30800 KB |
Output is correct |
14 |
Correct |
703 ms |
30784 KB |
Output is correct |
15 |
Correct |
719 ms |
30744 KB |
Output is correct |
16 |
Correct |
696 ms |
30712 KB |
Output is correct |
17 |
Correct |
694 ms |
30688 KB |
Output is correct |
18 |
Correct |
762 ms |
30656 KB |
Output is correct |
19 |
Correct |
705 ms |
30608 KB |
Output is correct |
20 |
Correct |
701 ms |
30700 KB |
Output is correct |
21 |
Correct |
704 ms |
30804 KB |
Output is correct |
22 |
Correct |
709 ms |
31572 KB |
Output is correct |
23 |
Correct |
709 ms |
31212 KB |
Output is correct |
24 |
Correct |
694 ms |
31364 KB |
Output is correct |
25 |
Correct |
700 ms |
31316 KB |
Output is correct |
26 |
Correct |
704 ms |
31516 KB |
Output is correct |
27 |
Correct |
697 ms |
31460 KB |
Output is correct |
28 |
Correct |
766 ms |
31500 KB |
Output is correct |
29 |
Correct |
693 ms |
31312 KB |
Output is correct |
30 |
Correct |
723 ms |
31236 KB |
Output is correct |
31 |
Correct |
717 ms |
31828 KB |
Output is correct |
32 |
Correct |
699 ms |
31308 KB |
Output is correct |
33 |
Correct |
709 ms |
31572 KB |
Output is correct |
34 |
Correct |
750 ms |
31316 KB |
Output is correct |
35 |
Correct |
701 ms |
31316 KB |
Output is correct |
36 |
Correct |
706 ms |
31316 KB |
Output is correct |
37 |
Correct |
699 ms |
31316 KB |
Output is correct |
38 |
Correct |
709 ms |
31352 KB |
Output is correct |
39 |
Correct |
702 ms |
31352 KB |
Output is correct |
40 |
Correct |
696 ms |
31288 KB |
Output is correct |
41 |
Correct |
732 ms |
31356 KB |
Output is correct |
42 |
Correct |
737 ms |
31360 KB |
Output is correct |
43 |
Correct |
697 ms |
31624 KB |
Output is correct |
44 |
Correct |
686 ms |
31812 KB |
Output is correct |
45 |
Correct |
697 ms |
31648 KB |
Output is correct |
46 |
Correct |
706 ms |
31576 KB |
Output is correct |
47 |
Correct |
700 ms |
31572 KB |
Output is correct |
48 |
Correct |
716 ms |
31828 KB |
Output is correct |
49 |
Correct |
696 ms |
31572 KB |
Output is correct |
50 |
Correct |
704 ms |
31524 KB |
Output is correct |
51 |
Correct |
714 ms |
31608 KB |
Output is correct |
52 |
Correct |
701 ms |
31572 KB |
Output is correct |
53 |
Correct |
702 ms |
31760 KB |
Output is correct |
54 |
Correct |
700 ms |
31628 KB |
Output is correct |
55 |
Correct |
696 ms |
31604 KB |
Output is correct |
56 |
Correct |
694 ms |
31596 KB |
Output is correct |
57 |
Correct |
707 ms |
31496 KB |
Output is correct |
58 |
Correct |
705 ms |
31432 KB |
Output is correct |
59 |
Correct |
754 ms |
31616 KB |
Output is correct |
60 |
Correct |
713 ms |
31608 KB |
Output is correct |
61 |
Correct |
701 ms |
31660 KB |
Output is correct |
62 |
Correct |
694 ms |
31460 KB |
Output is correct |
63 |
Correct |
713 ms |
31544 KB |
Output is correct |
64 |
Correct |
711 ms |
32132 KB |
Output is correct |
65 |
Correct |
698 ms |
32004 KB |
Output is correct |
66 |
Correct |
698 ms |
31688 KB |
Output is correct |
67 |
Correct |
706 ms |
31900 KB |
Output is correct |
68 |
Correct |
687 ms |
31828 KB |
Output is correct |
69 |
Correct |
715 ms |
31776 KB |
Output is correct |
70 |
Correct |
713 ms |
31672 KB |
Output is correct |
71 |
Correct |
702 ms |
31904 KB |
Output is correct |
72 |
Correct |
702 ms |
31876 KB |
Output is correct |
73 |
Correct |
698 ms |
32084 KB |
Output is correct |
74 |
Correct |
736 ms |
32136 KB |
Output is correct |
75 |
Correct |
699 ms |
31900 KB |
Output is correct |
76 |
Correct |
696 ms |
31828 KB |
Output is correct |
77 |
Correct |
702 ms |
32116 KB |
Output is correct |
78 |
Correct |
726 ms |
31732 KB |
Output is correct |
79 |
Correct |
748 ms |
31720 KB |
Output is correct |
80 |
Correct |
698 ms |
31912 KB |
Output is correct |
81 |
Correct |
705 ms |
32044 KB |
Output is correct |
82 |
Correct |
691 ms |
31828 KB |
Output is correct |
83 |
Correct |
696 ms |
31844 KB |
Output is correct |
84 |
Correct |
695 ms |
31836 KB |
Output is correct |