# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
556664 | 2022-05-03T13:43:23 Z | fatemetmhr | Cubeword (CEOI19_cubeword) | C++17 | 995 ms | 26904 KB |
// ~~ Be name khoda ~~ // #include <bits/stdc++.h> #pragma GCC optimize("O3,unroll-loops,no-tree-loop-distribute-patterns") #pragma GCC target("avx2") using namespace std; typedef long long ll; #define all(x) x.begin(), x.end() #define fi first #define se second #define pb push_back const int al = 65; const int szz = 10; const int mod = 998244353; const int maxn5 = 1e5 + 10; set <string> av; int id[maxn5]; int have[al][al][al][szz]; int cnt[szz][al][al]; int main(){ ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n; cin >> n; for(int i = 0; i < n; i++){ string s; cin >> s; av.insert(s); reverse(all(s)); av.insert(s); } int ind = 0; for(int i = 0; i < 26; i++){ id[i + 'a'] = ind++; id[i + 'A'] = ind++; if(i < 10) id[i + '0'] = ind++; } for(auto it = av.begin(); it != av.end(); it++){ string s = (*it); cnt[s.size() - 3][id[s[0]]][id[s[s.size() - 1]]]++; } for(int i = 0; i < ind; i++) for(int j = i; j < ind; j++) for(int k = j; k < ind; k++) for(int sz = 0; sz <= 8; sz++){ for(int z = 0; z < ind; z++) have[i][j][k][sz] = (have[i][j][k][sz] + (ll(cnt[sz][i][z]) * cnt[sz][j][z] % mod) * cnt[sz][k][z]) % mod; have[i][k][j][sz] = have[j][i][k][sz] = have[j][k][i][sz] = have[k][i][j][sz] = have[k][j][i][sz] = have[i][j][k][sz]; } ll ans = 0; for(int i = 0; i < ind; i++) for(int j = 0; j < ind; j++) for(int k = 0; k < ind; k++) for(int z = 0; z < ind; z++) for(int sz = 0; sz <= 8; sz++) ans = (ans + ((ll(have[i][j][k][sz]) * have[i][j][z][sz] % mod) * have[i][k][z][sz] % mod) * have[j][k][z][sz]) % mod; cout << ans << endl; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 931 ms | 24944 KB | Output is correct |
2 | Correct | 928 ms | 25752 KB | Output is correct |
3 | Correct | 930 ms | 25744 KB | Output is correct |
4 | Correct | 946 ms | 25732 KB | Output is correct |
5 | Correct | 948 ms | 25752 KB | Output is correct |
6 | Correct | 944 ms | 25848 KB | Output is correct |
7 | Correct | 950 ms | 25752 KB | Output is correct |
8 | Correct | 957 ms | 25744 KB | Output is correct |
9 | Correct | 995 ms | 25736 KB | Output is correct |
10 | Correct | 962 ms | 25752 KB | Output is correct |
11 | Correct | 950 ms | 25740 KB | Output is correct |
12 | Correct | 960 ms | 25604 KB | Output is correct |
13 | Correct | 942 ms | 25752 KB | Output is correct |
14 | Correct | 928 ms | 25736 KB | Output is correct |
15 | Correct | 922 ms | 25744 KB | Output is correct |
16 | Correct | 938 ms | 25736 KB | Output is correct |
17 | Correct | 945 ms | 25744 KB | Output is correct |
18 | Correct | 946 ms | 25728 KB | Output is correct |
19 | Correct | 937 ms | 25732 KB | Output is correct |
20 | Correct | 934 ms | 25796 KB | Output is correct |
21 | Correct | 945 ms | 25732 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 931 ms | 24944 KB | Output is correct |
2 | Correct | 928 ms | 25752 KB | Output is correct |
3 | Correct | 930 ms | 25744 KB | Output is correct |
4 | Correct | 946 ms | 25732 KB | Output is correct |
5 | Correct | 948 ms | 25752 KB | Output is correct |
6 | Correct | 944 ms | 25848 KB | Output is correct |
7 | Correct | 950 ms | 25752 KB | Output is correct |
8 | Correct | 957 ms | 25744 KB | Output is correct |
9 | Correct | 995 ms | 25736 KB | Output is correct |
10 | Correct | 962 ms | 25752 KB | Output is correct |
11 | Correct | 950 ms | 25740 KB | Output is correct |
12 | Correct | 960 ms | 25604 KB | Output is correct |
13 | Correct | 942 ms | 25752 KB | Output is correct |
14 | Correct | 928 ms | 25736 KB | Output is correct |
15 | Correct | 922 ms | 25744 KB | Output is correct |
16 | Correct | 938 ms | 25736 KB | Output is correct |
17 | Correct | 945 ms | 25744 KB | Output is correct |
18 | Correct | 946 ms | 25728 KB | Output is correct |
19 | Correct | 937 ms | 25732 KB | Output is correct |
20 | Correct | 934 ms | 25796 KB | Output is correct |
21 | Correct | 945 ms | 25732 KB | Output is correct |
22 | Correct | 928 ms | 26376 KB | Output is correct |
23 | Correct | 896 ms | 26444 KB | Output is correct |
24 | Correct | 918 ms | 26372 KB | Output is correct |
25 | Correct | 929 ms | 26360 KB | Output is correct |
26 | Correct | 945 ms | 26352 KB | Output is correct |
27 | Correct | 933 ms | 26348 KB | Output is correct |
28 | Correct | 915 ms | 26368 KB | Output is correct |
29 | Correct | 920 ms | 26424 KB | Output is correct |
30 | Correct | 915 ms | 26472 KB | Output is correct |
31 | Correct | 928 ms | 26340 KB | Output is correct |
32 | Correct | 901 ms | 26308 KB | Output is correct |
33 | Correct | 888 ms | 26284 KB | Output is correct |
34 | Correct | 879 ms | 26360 KB | Output is correct |
35 | Correct | 872 ms | 26364 KB | Output is correct |
36 | Correct | 886 ms | 26372 KB | Output is correct |
37 | Correct | 881 ms | 26356 KB | Output is correct |
38 | Correct | 869 ms | 26444 KB | Output is correct |
39 | Correct | 902 ms | 26480 KB | Output is correct |
40 | Correct | 886 ms | 26440 KB | Output is correct |
41 | Correct | 915 ms | 26588 KB | Output is correct |
42 | Correct | 913 ms | 26316 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 931 ms | 24944 KB | Output is correct |
2 | Correct | 928 ms | 25752 KB | Output is correct |
3 | Correct | 930 ms | 25744 KB | Output is correct |
4 | Correct | 946 ms | 25732 KB | Output is correct |
5 | Correct | 948 ms | 25752 KB | Output is correct |
6 | Correct | 944 ms | 25848 KB | Output is correct |
7 | Correct | 950 ms | 25752 KB | Output is correct |
8 | Correct | 957 ms | 25744 KB | Output is correct |
9 | Correct | 995 ms | 25736 KB | Output is correct |
10 | Correct | 962 ms | 25752 KB | Output is correct |
11 | Correct | 950 ms | 25740 KB | Output is correct |
12 | Correct | 960 ms | 25604 KB | Output is correct |
13 | Correct | 942 ms | 25752 KB | Output is correct |
14 | Correct | 928 ms | 25736 KB | Output is correct |
15 | Correct | 922 ms | 25744 KB | Output is correct |
16 | Correct | 938 ms | 25736 KB | Output is correct |
17 | Correct | 945 ms | 25744 KB | Output is correct |
18 | Correct | 946 ms | 25728 KB | Output is correct |
19 | Correct | 937 ms | 25732 KB | Output is correct |
20 | Correct | 934 ms | 25796 KB | Output is correct |
21 | Correct | 945 ms | 25732 KB | Output is correct |
22 | Correct | 928 ms | 26376 KB | Output is correct |
23 | Correct | 896 ms | 26444 KB | Output is correct |
24 | Correct | 918 ms | 26372 KB | Output is correct |
25 | Correct | 929 ms | 26360 KB | Output is correct |
26 | Correct | 945 ms | 26352 KB | Output is correct |
27 | Correct | 933 ms | 26348 KB | Output is correct |
28 | Correct | 915 ms | 26368 KB | Output is correct |
29 | Correct | 920 ms | 26424 KB | Output is correct |
30 | Correct | 915 ms | 26472 KB | Output is correct |
31 | Correct | 928 ms | 26340 KB | Output is correct |
32 | Correct | 901 ms | 26308 KB | Output is correct |
33 | Correct | 888 ms | 26284 KB | Output is correct |
34 | Correct | 879 ms | 26360 KB | Output is correct |
35 | Correct | 872 ms | 26364 KB | Output is correct |
36 | Correct | 886 ms | 26372 KB | Output is correct |
37 | Correct | 881 ms | 26356 KB | Output is correct |
38 | Correct | 869 ms | 26444 KB | Output is correct |
39 | Correct | 902 ms | 26480 KB | Output is correct |
40 | Correct | 886 ms | 26440 KB | Output is correct |
41 | Correct | 915 ms | 26588 KB | Output is correct |
42 | Correct | 913 ms | 26316 KB | Output is correct |
43 | Correct | 911 ms | 26552 KB | Output is correct |
44 | Correct | 906 ms | 26572 KB | Output is correct |
45 | Correct | 905 ms | 26548 KB | Output is correct |
46 | Correct | 907 ms | 26548 KB | Output is correct |
47 | Correct | 880 ms | 26584 KB | Output is correct |
48 | Correct | 878 ms | 26660 KB | Output is correct |
49 | Correct | 871 ms | 26664 KB | Output is correct |
50 | Correct | 887 ms | 26564 KB | Output is correct |
51 | Correct | 877 ms | 26436 KB | Output is correct |
52 | Correct | 875 ms | 26664 KB | Output is correct |
53 | Correct | 878 ms | 26448 KB | Output is correct |
54 | Correct | 886 ms | 26444 KB | Output is correct |
55 | Correct | 884 ms | 26572 KB | Output is correct |
56 | Correct | 894 ms | 26556 KB | Output is correct |
57 | Correct | 883 ms | 26572 KB | Output is correct |
58 | Correct | 897 ms | 26592 KB | Output is correct |
59 | Correct | 892 ms | 26552 KB | Output is correct |
60 | Correct | 885 ms | 26540 KB | Output is correct |
61 | Correct | 887 ms | 26548 KB | Output is correct |
62 | Correct | 885 ms | 26648 KB | Output is correct |
63 | Correct | 877 ms | 26616 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 931 ms | 24944 KB | Output is correct |
2 | Correct | 928 ms | 25752 KB | Output is correct |
3 | Correct | 930 ms | 25744 KB | Output is correct |
4 | Correct | 946 ms | 25732 KB | Output is correct |
5 | Correct | 948 ms | 25752 KB | Output is correct |
6 | Correct | 944 ms | 25848 KB | Output is correct |
7 | Correct | 950 ms | 25752 KB | Output is correct |
8 | Correct | 957 ms | 25744 KB | Output is correct |
9 | Correct | 995 ms | 25736 KB | Output is correct |
10 | Correct | 962 ms | 25752 KB | Output is correct |
11 | Correct | 950 ms | 25740 KB | Output is correct |
12 | Correct | 960 ms | 25604 KB | Output is correct |
13 | Correct | 942 ms | 25752 KB | Output is correct |
14 | Correct | 928 ms | 25736 KB | Output is correct |
15 | Correct | 922 ms | 25744 KB | Output is correct |
16 | Correct | 938 ms | 25736 KB | Output is correct |
17 | Correct | 945 ms | 25744 KB | Output is correct |
18 | Correct | 946 ms | 25728 KB | Output is correct |
19 | Correct | 937 ms | 25732 KB | Output is correct |
20 | Correct | 934 ms | 25796 KB | Output is correct |
21 | Correct | 945 ms | 25732 KB | Output is correct |
22 | Correct | 928 ms | 26376 KB | Output is correct |
23 | Correct | 896 ms | 26444 KB | Output is correct |
24 | Correct | 918 ms | 26372 KB | Output is correct |
25 | Correct | 929 ms | 26360 KB | Output is correct |
26 | Correct | 945 ms | 26352 KB | Output is correct |
27 | Correct | 933 ms | 26348 KB | Output is correct |
28 | Correct | 915 ms | 26368 KB | Output is correct |
29 | Correct | 920 ms | 26424 KB | Output is correct |
30 | Correct | 915 ms | 26472 KB | Output is correct |
31 | Correct | 928 ms | 26340 KB | Output is correct |
32 | Correct | 901 ms | 26308 KB | Output is correct |
33 | Correct | 888 ms | 26284 KB | Output is correct |
34 | Correct | 879 ms | 26360 KB | Output is correct |
35 | Correct | 872 ms | 26364 KB | Output is correct |
36 | Correct | 886 ms | 26372 KB | Output is correct |
37 | Correct | 881 ms | 26356 KB | Output is correct |
38 | Correct | 869 ms | 26444 KB | Output is correct |
39 | Correct | 902 ms | 26480 KB | Output is correct |
40 | Correct | 886 ms | 26440 KB | Output is correct |
41 | Correct | 915 ms | 26588 KB | Output is correct |
42 | Correct | 913 ms | 26316 KB | Output is correct |
43 | Correct | 911 ms | 26552 KB | Output is correct |
44 | Correct | 906 ms | 26572 KB | Output is correct |
45 | Correct | 905 ms | 26548 KB | Output is correct |
46 | Correct | 907 ms | 26548 KB | Output is correct |
47 | Correct | 880 ms | 26584 KB | Output is correct |
48 | Correct | 878 ms | 26660 KB | Output is correct |
49 | Correct | 871 ms | 26664 KB | Output is correct |
50 | Correct | 887 ms | 26564 KB | Output is correct |
51 | Correct | 877 ms | 26436 KB | Output is correct |
52 | Correct | 875 ms | 26664 KB | Output is correct |
53 | Correct | 878 ms | 26448 KB | Output is correct |
54 | Correct | 886 ms | 26444 KB | Output is correct |
55 | Correct | 884 ms | 26572 KB | Output is correct |
56 | Correct | 894 ms | 26556 KB | Output is correct |
57 | Correct | 883 ms | 26572 KB | Output is correct |
58 | Correct | 897 ms | 26592 KB | Output is correct |
59 | Correct | 892 ms | 26552 KB | Output is correct |
60 | Correct | 885 ms | 26540 KB | Output is correct |
61 | Correct | 887 ms | 26548 KB | Output is correct |
62 | Correct | 885 ms | 26648 KB | Output is correct |
63 | Correct | 877 ms | 26616 KB | Output is correct |
64 | Correct | 897 ms | 26796 KB | Output is correct |
65 | Correct | 881 ms | 26800 KB | Output is correct |
66 | Correct | 884 ms | 26904 KB | Output is correct |
67 | Correct | 888 ms | 26700 KB | Output is correct |
68 | Correct | 880 ms | 26796 KB | Output is correct |
69 | Correct | 874 ms | 26792 KB | Output is correct |
70 | Correct | 884 ms | 26800 KB | Output is correct |
71 | Correct | 887 ms | 26792 KB | Output is correct |
72 | Correct | 890 ms | 26872 KB | Output is correct |
73 | Correct | 897 ms | 26792 KB | Output is correct |
74 | Correct | 879 ms | 26904 KB | Output is correct |
75 | Correct | 883 ms | 26784 KB | Output is correct |
76 | Correct | 880 ms | 26828 KB | Output is correct |
77 | Correct | 881 ms | 26788 KB | Output is correct |
78 | Correct | 888 ms | 26792 KB | Output is correct |
79 | Correct | 885 ms | 26824 KB | Output is correct |
80 | Correct | 893 ms | 26812 KB | Output is correct |
81 | Correct | 886 ms | 26904 KB | Output is correct |
82 | Correct | 892 ms | 26784 KB | Output is correct |
83 | Correct | 899 ms | 26764 KB | Output is correct |
84 | Correct | 893 ms | 26844 KB | Output is correct |