#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;
#define int int64_t
#define F(X) for(X = 0; X < B; X++)
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[11];
int i, j, k, l, x;
#define c(i, j, k, l) ((b[L][i][j][l] * b[L][j][k][l]) % M)
int32_t main() {
ios::sync_with_stdio(0), cin.tie(0);
cin >> n;
while(n--) {
string s; cin >> s;
if(get(s[0]) > get(end(s)[-1]))
reverse(begin(s), end(s));
i = size(s);
if(inp[i][s]) continue;
inp[i][s] = 1;
string t = s;
reverse(begin(t), end(t));
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 < 8; L++) {
memset(b, 0, sizeof b);
F(i) F(j) F(k) F(x)
b[L][i][j][k] += _a[L][i][x] * _a[L][j][x] * _a[L][k][x];
F(i) F(j) F(k)
b[L][i][j][k] %= M;
F(i) F(j) F(k) F(l)
(res += c(i, j, k, l) * c(l, k, j, i)) %= M;
}
cout << res;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
882 ms |
23516 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
882 ms |
23516 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
882 ms |
23516 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
882 ms |
23516 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |