#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;
constexpr int maxn = 32, mod = 998244353; // subtasks 1-2
int ans;
int edge[11][maxn][maxn];
int value_triad[11][maxn][maxn][maxn];
int id(char c) { if(c >= 'a') return c-'a'; return 16+c-'A'; } // subtaks 1-2
set<string> mark;
void add(int& a, int b) { a += b; if(a >= mod) a -= mod; }
int D[11][maxn][maxn][maxn];
int main() {
int n; cin >> n;
string s;
for(int i = 0; i < n; i++) {
cin >> s;
for(int rep = 0; rep < 2; rep++, reverse(s.begin(), s.end())) if(!mark.count(s)) {
edge[s.size()][id(s[0])][id(s.back())]++;
mark.insert(s);
}
}
for(int sz = 3; sz <= 10; sz++)
for(int a = 0; a < maxn; a++) for(int b = 0; b < maxn; b++) for(int c = 0; c < maxn; c++)
for(int x = 0; x < maxn; x++)
add(D[sz][a][b][c], 1ll * edge[sz][x][a] * edge[sz][x][b] % mod * edge[sz][x][c] % mod);
for(int sz = 3; sz <= 10; sz++) {
for(int a = 0; a < maxn; a++) for(int b = 0; b < maxn; b++) for(int c = 0; c < maxn; c++) for(int d = 0; d < maxn; d++)
add(ans, 1ll * D[sz][a][b][c] * D[sz][a][b][d] % mod * D[sz][a][c][d] % mod * D[sz][b][c][d] % mod);
}
printf("%d\n", ans);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
294 ms |
15916 KB |
Output is correct |
2 |
Correct |
272 ms |
15820 KB |
Output is correct |
3 |
Correct |
272 ms |
15780 KB |
Output is correct |
4 |
Correct |
274 ms |
15944 KB |
Output is correct |
5 |
Correct |
284 ms |
15832 KB |
Output is correct |
6 |
Correct |
273 ms |
15788 KB |
Output is correct |
7 |
Correct |
278 ms |
15800 KB |
Output is correct |
8 |
Correct |
273 ms |
15804 KB |
Output is correct |
9 |
Correct |
270 ms |
15820 KB |
Output is correct |
10 |
Correct |
281 ms |
15788 KB |
Output is correct |
11 |
Correct |
280 ms |
15756 KB |
Output is correct |
12 |
Correct |
274 ms |
15828 KB |
Output is correct |
13 |
Correct |
275 ms |
15896 KB |
Output is correct |
14 |
Correct |
267 ms |
15732 KB |
Output is correct |
15 |
Correct |
290 ms |
15892 KB |
Output is correct |
16 |
Correct |
272 ms |
15800 KB |
Output is correct |
17 |
Correct |
285 ms |
15824 KB |
Output is correct |
18 |
Correct |
330 ms |
15944 KB |
Output is correct |
19 |
Correct |
309 ms |
15788 KB |
Output is correct |
20 |
Correct |
300 ms |
15860 KB |
Output is correct |
21 |
Correct |
328 ms |
15816 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
294 ms |
15916 KB |
Output is correct |
2 |
Correct |
272 ms |
15820 KB |
Output is correct |
3 |
Correct |
272 ms |
15780 KB |
Output is correct |
4 |
Correct |
274 ms |
15944 KB |
Output is correct |
5 |
Correct |
284 ms |
15832 KB |
Output is correct |
6 |
Correct |
273 ms |
15788 KB |
Output is correct |
7 |
Correct |
278 ms |
15800 KB |
Output is correct |
8 |
Correct |
273 ms |
15804 KB |
Output is correct |
9 |
Correct |
270 ms |
15820 KB |
Output is correct |
10 |
Correct |
281 ms |
15788 KB |
Output is correct |
11 |
Correct |
280 ms |
15756 KB |
Output is correct |
12 |
Correct |
274 ms |
15828 KB |
Output is correct |
13 |
Correct |
275 ms |
15896 KB |
Output is correct |
14 |
Correct |
267 ms |
15732 KB |
Output is correct |
15 |
Correct |
290 ms |
15892 KB |
Output is correct |
16 |
Correct |
272 ms |
15800 KB |
Output is correct |
17 |
Correct |
285 ms |
15824 KB |
Output is correct |
18 |
Correct |
330 ms |
15944 KB |
Output is correct |
19 |
Correct |
309 ms |
15788 KB |
Output is correct |
20 |
Correct |
300 ms |
15860 KB |
Output is correct |
21 |
Correct |
328 ms |
15816 KB |
Output is correct |
22 |
Correct |
293 ms |
16476 KB |
Output is correct |
23 |
Correct |
307 ms |
16412 KB |
Output is correct |
24 |
Correct |
290 ms |
16392 KB |
Output is correct |
25 |
Correct |
302 ms |
16380 KB |
Output is correct |
26 |
Correct |
301 ms |
16476 KB |
Output is correct |
27 |
Correct |
337 ms |
16384 KB |
Output is correct |
28 |
Correct |
311 ms |
16404 KB |
Output is correct |
29 |
Correct |
308 ms |
16500 KB |
Output is correct |
30 |
Correct |
302 ms |
16592 KB |
Output is correct |
31 |
Correct |
297 ms |
16416 KB |
Output is correct |
32 |
Correct |
301 ms |
16476 KB |
Output is correct |
33 |
Correct |
289 ms |
16460 KB |
Output is correct |
34 |
Correct |
296 ms |
16384 KB |
Output is correct |
35 |
Correct |
300 ms |
16620 KB |
Output is correct |
36 |
Correct |
277 ms |
16444 KB |
Output is correct |
37 |
Correct |
290 ms |
16488 KB |
Output is correct |
38 |
Correct |
284 ms |
16368 KB |
Output is correct |
39 |
Correct |
299 ms |
16464 KB |
Output is correct |
40 |
Correct |
288 ms |
16372 KB |
Output is correct |
41 |
Correct |
299 ms |
16408 KB |
Output is correct |
42 |
Correct |
291 ms |
16520 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
294 ms |
15916 KB |
Output is correct |
2 |
Correct |
272 ms |
15820 KB |
Output is correct |
3 |
Correct |
272 ms |
15780 KB |
Output is correct |
4 |
Correct |
274 ms |
15944 KB |
Output is correct |
5 |
Correct |
284 ms |
15832 KB |
Output is correct |
6 |
Correct |
273 ms |
15788 KB |
Output is correct |
7 |
Correct |
278 ms |
15800 KB |
Output is correct |
8 |
Correct |
273 ms |
15804 KB |
Output is correct |
9 |
Correct |
270 ms |
15820 KB |
Output is correct |
10 |
Correct |
281 ms |
15788 KB |
Output is correct |
11 |
Correct |
280 ms |
15756 KB |
Output is correct |
12 |
Correct |
274 ms |
15828 KB |
Output is correct |
13 |
Correct |
275 ms |
15896 KB |
Output is correct |
14 |
Correct |
267 ms |
15732 KB |
Output is correct |
15 |
Correct |
290 ms |
15892 KB |
Output is correct |
16 |
Correct |
272 ms |
15800 KB |
Output is correct |
17 |
Correct |
285 ms |
15824 KB |
Output is correct |
18 |
Correct |
330 ms |
15944 KB |
Output is correct |
19 |
Correct |
309 ms |
15788 KB |
Output is correct |
20 |
Correct |
300 ms |
15860 KB |
Output is correct |
21 |
Correct |
328 ms |
15816 KB |
Output is correct |
22 |
Correct |
293 ms |
16476 KB |
Output is correct |
23 |
Correct |
307 ms |
16412 KB |
Output is correct |
24 |
Correct |
290 ms |
16392 KB |
Output is correct |
25 |
Correct |
302 ms |
16380 KB |
Output is correct |
26 |
Correct |
301 ms |
16476 KB |
Output is correct |
27 |
Correct |
337 ms |
16384 KB |
Output is correct |
28 |
Correct |
311 ms |
16404 KB |
Output is correct |
29 |
Correct |
308 ms |
16500 KB |
Output is correct |
30 |
Correct |
302 ms |
16592 KB |
Output is correct |
31 |
Correct |
297 ms |
16416 KB |
Output is correct |
32 |
Correct |
301 ms |
16476 KB |
Output is correct |
33 |
Correct |
289 ms |
16460 KB |
Output is correct |
34 |
Correct |
296 ms |
16384 KB |
Output is correct |
35 |
Correct |
300 ms |
16620 KB |
Output is correct |
36 |
Correct |
277 ms |
16444 KB |
Output is correct |
37 |
Correct |
290 ms |
16488 KB |
Output is correct |
38 |
Correct |
284 ms |
16368 KB |
Output is correct |
39 |
Correct |
299 ms |
16464 KB |
Output is correct |
40 |
Correct |
288 ms |
16372 KB |
Output is correct |
41 |
Correct |
299 ms |
16408 KB |
Output is correct |
42 |
Correct |
291 ms |
16520 KB |
Output is correct |
43 |
Correct |
303 ms |
16684 KB |
Output is correct |
44 |
Correct |
289 ms |
17492 KB |
Output is correct |
45 |
Correct |
303 ms |
17432 KB |
Output is correct |
46 |
Correct |
287 ms |
17448 KB |
Output is correct |
47 |
Correct |
296 ms |
17468 KB |
Output is correct |
48 |
Correct |
312 ms |
17372 KB |
Output is correct |
49 |
Correct |
293 ms |
17484 KB |
Output is correct |
50 |
Correct |
296 ms |
17452 KB |
Output is correct |
51 |
Correct |
294 ms |
17432 KB |
Output is correct |
52 |
Correct |
302 ms |
17448 KB |
Output is correct |
53 |
Correct |
293 ms |
17432 KB |
Output is correct |
54 |
Correct |
315 ms |
17432 KB |
Output is correct |
55 |
Correct |
291 ms |
17356 KB |
Output is correct |
56 |
Correct |
318 ms |
17576 KB |
Output is correct |
57 |
Correct |
294 ms |
17340 KB |
Output is correct |
58 |
Correct |
286 ms |
17532 KB |
Output is correct |
59 |
Correct |
309 ms |
17736 KB |
Output is correct |
60 |
Correct |
292 ms |
17444 KB |
Output is correct |
61 |
Correct |
293 ms |
17612 KB |
Output is correct |
62 |
Correct |
293 ms |
17444 KB |
Output is correct |
63 |
Correct |
309 ms |
17396 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
294 ms |
15916 KB |
Output is correct |
2 |
Correct |
272 ms |
15820 KB |
Output is correct |
3 |
Correct |
272 ms |
15780 KB |
Output is correct |
4 |
Correct |
274 ms |
15944 KB |
Output is correct |
5 |
Correct |
284 ms |
15832 KB |
Output is correct |
6 |
Correct |
273 ms |
15788 KB |
Output is correct |
7 |
Correct |
278 ms |
15800 KB |
Output is correct |
8 |
Correct |
273 ms |
15804 KB |
Output is correct |
9 |
Correct |
270 ms |
15820 KB |
Output is correct |
10 |
Correct |
281 ms |
15788 KB |
Output is correct |
11 |
Correct |
280 ms |
15756 KB |
Output is correct |
12 |
Correct |
274 ms |
15828 KB |
Output is correct |
13 |
Correct |
275 ms |
15896 KB |
Output is correct |
14 |
Correct |
267 ms |
15732 KB |
Output is correct |
15 |
Correct |
290 ms |
15892 KB |
Output is correct |
16 |
Correct |
272 ms |
15800 KB |
Output is correct |
17 |
Correct |
285 ms |
15824 KB |
Output is correct |
18 |
Correct |
330 ms |
15944 KB |
Output is correct |
19 |
Correct |
309 ms |
15788 KB |
Output is correct |
20 |
Correct |
300 ms |
15860 KB |
Output is correct |
21 |
Correct |
328 ms |
15816 KB |
Output is correct |
22 |
Correct |
293 ms |
16476 KB |
Output is correct |
23 |
Correct |
307 ms |
16412 KB |
Output is correct |
24 |
Correct |
290 ms |
16392 KB |
Output is correct |
25 |
Correct |
302 ms |
16380 KB |
Output is correct |
26 |
Correct |
301 ms |
16476 KB |
Output is correct |
27 |
Correct |
337 ms |
16384 KB |
Output is correct |
28 |
Correct |
311 ms |
16404 KB |
Output is correct |
29 |
Correct |
308 ms |
16500 KB |
Output is correct |
30 |
Correct |
302 ms |
16592 KB |
Output is correct |
31 |
Correct |
297 ms |
16416 KB |
Output is correct |
32 |
Correct |
301 ms |
16476 KB |
Output is correct |
33 |
Correct |
289 ms |
16460 KB |
Output is correct |
34 |
Correct |
296 ms |
16384 KB |
Output is correct |
35 |
Correct |
300 ms |
16620 KB |
Output is correct |
36 |
Correct |
277 ms |
16444 KB |
Output is correct |
37 |
Correct |
290 ms |
16488 KB |
Output is correct |
38 |
Correct |
284 ms |
16368 KB |
Output is correct |
39 |
Correct |
299 ms |
16464 KB |
Output is correct |
40 |
Correct |
288 ms |
16372 KB |
Output is correct |
41 |
Correct |
299 ms |
16408 KB |
Output is correct |
42 |
Correct |
291 ms |
16520 KB |
Output is correct |
43 |
Correct |
303 ms |
16684 KB |
Output is correct |
44 |
Correct |
289 ms |
17492 KB |
Output is correct |
45 |
Correct |
303 ms |
17432 KB |
Output is correct |
46 |
Correct |
287 ms |
17448 KB |
Output is correct |
47 |
Correct |
296 ms |
17468 KB |
Output is correct |
48 |
Correct |
312 ms |
17372 KB |
Output is correct |
49 |
Correct |
293 ms |
17484 KB |
Output is correct |
50 |
Correct |
296 ms |
17452 KB |
Output is correct |
51 |
Correct |
294 ms |
17432 KB |
Output is correct |
52 |
Correct |
302 ms |
17448 KB |
Output is correct |
53 |
Correct |
293 ms |
17432 KB |
Output is correct |
54 |
Correct |
315 ms |
17432 KB |
Output is correct |
55 |
Correct |
291 ms |
17356 KB |
Output is correct |
56 |
Correct |
318 ms |
17576 KB |
Output is correct |
57 |
Correct |
294 ms |
17340 KB |
Output is correct |
58 |
Correct |
286 ms |
17532 KB |
Output is correct |
59 |
Correct |
309 ms |
17736 KB |
Output is correct |
60 |
Correct |
292 ms |
17444 KB |
Output is correct |
61 |
Correct |
293 ms |
17612 KB |
Output is correct |
62 |
Correct |
293 ms |
17444 KB |
Output is correct |
63 |
Correct |
309 ms |
17396 KB |
Output is correct |
64 |
Runtime error |
326 ms |
34860 KB |
Execution killed with signal 11 |
65 |
Halted |
0 ms |
0 KB |
- |