# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
556666 | 2022-05-03T13:46:27 Z | fatemetmhr | Cubeword (CEOI19_cubeword) | C++17 | 985 ms | 26248 KB |
// ~~ Be name khoda ~~ // #include <bits/stdc++.h> #pragma GCC optimize("O3,unroll-loops") #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
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 884 ms | 24884 KB | Output is correct |
2 | Correct | 922 ms | 24920 KB | Output is correct |
3 | Correct | 918 ms | 25116 KB | Output is correct |
4 | Correct | 900 ms | 24860 KB | Output is correct |
5 | Correct | 916 ms | 24876 KB | Output is correct |
6 | Correct | 947 ms | 24880 KB | Output is correct |
7 | Correct | 957 ms | 24932 KB | Output is correct |
8 | Correct | 928 ms | 24880 KB | Output is correct |
9 | Correct | 920 ms | 24868 KB | Output is correct |
10 | Correct | 940 ms | 24956 KB | Output is correct |
11 | Correct | 930 ms | 24876 KB | Output is correct |
12 | Correct | 955 ms | 24860 KB | Output is correct |
13 | Correct | 933 ms | 24888 KB | Output is correct |
14 | Correct | 934 ms | 24884 KB | Output is correct |
15 | Correct | 943 ms | 24936 KB | Output is correct |
16 | Correct | 935 ms | 24864 KB | Output is correct |
17 | Correct | 949 ms | 24888 KB | Output is correct |
18 | Correct | 927 ms | 24940 KB | Output is correct |
19 | Correct | 949 ms | 24864 KB | Output is correct |
20 | Correct | 954 ms | 24908 KB | Output is correct |
21 | Correct | 935 ms | 25012 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 884 ms | 24884 KB | Output is correct |
2 | Correct | 922 ms | 24920 KB | Output is correct |
3 | Correct | 918 ms | 25116 KB | Output is correct |
4 | Correct | 900 ms | 24860 KB | Output is correct |
5 | Correct | 916 ms | 24876 KB | Output is correct |
6 | Correct | 947 ms | 24880 KB | Output is correct |
7 | Correct | 957 ms | 24932 KB | Output is correct |
8 | Correct | 928 ms | 24880 KB | Output is correct |
9 | Correct | 920 ms | 24868 KB | Output is correct |
10 | Correct | 940 ms | 24956 KB | Output is correct |
11 | Correct | 930 ms | 24876 KB | Output is correct |
12 | Correct | 955 ms | 24860 KB | Output is correct |
13 | Correct | 933 ms | 24888 KB | Output is correct |
14 | Correct | 934 ms | 24884 KB | Output is correct |
15 | Correct | 943 ms | 24936 KB | Output is correct |
16 | Correct | 935 ms | 24864 KB | Output is correct |
17 | Correct | 949 ms | 24888 KB | Output is correct |
18 | Correct | 927 ms | 24940 KB | Output is correct |
19 | Correct | 949 ms | 24864 KB | Output is correct |
20 | Correct | 954 ms | 24908 KB | Output is correct |
21 | Correct | 935 ms | 25012 KB | Output is correct |
22 | Correct | 937 ms | 25596 KB | Output is correct |
23 | Correct | 985 ms | 25584 KB | Output is correct |
24 | Correct | 923 ms | 25600 KB | Output is correct |
25 | Correct | 937 ms | 25652 KB | Output is correct |
26 | Correct | 976 ms | 25584 KB | Output is correct |
27 | Correct | 912 ms | 25576 KB | Output is correct |
28 | Correct | 961 ms | 25592 KB | Output is correct |
29 | Correct | 931 ms | 25592 KB | Output is correct |
30 | Correct | 926 ms | 25548 KB | Output is correct |
31 | Correct | 913 ms | 25580 KB | Output is correct |
32 | Correct | 923 ms | 25572 KB | Output is correct |
33 | Correct | 914 ms | 25616 KB | Output is correct |
34 | Correct | 891 ms | 25584 KB | Output is correct |
35 | Correct | 897 ms | 25652 KB | Output is correct |
36 | Correct | 906 ms | 25548 KB | Output is correct |
37 | Correct | 902 ms | 25600 KB | Output is correct |
38 | Correct | 910 ms | 25640 KB | Output is correct |
39 | Correct | 882 ms | 25584 KB | Output is correct |
40 | Correct | 900 ms | 25588 KB | Output is correct |
41 | Correct | 918 ms | 25620 KB | Output is correct |
42 | Correct | 887 ms | 25676 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 884 ms | 24884 KB | Output is correct |
2 | Correct | 922 ms | 24920 KB | Output is correct |
3 | Correct | 918 ms | 25116 KB | Output is correct |
4 | Correct | 900 ms | 24860 KB | Output is correct |
5 | Correct | 916 ms | 24876 KB | Output is correct |
6 | Correct | 947 ms | 24880 KB | Output is correct |
7 | Correct | 957 ms | 24932 KB | Output is correct |
8 | Correct | 928 ms | 24880 KB | Output is correct |
9 | Correct | 920 ms | 24868 KB | Output is correct |
10 | Correct | 940 ms | 24956 KB | Output is correct |
11 | Correct | 930 ms | 24876 KB | Output is correct |
12 | Correct | 955 ms | 24860 KB | Output is correct |
13 | Correct | 933 ms | 24888 KB | Output is correct |
14 | Correct | 934 ms | 24884 KB | Output is correct |
15 | Correct | 943 ms | 24936 KB | Output is correct |
16 | Correct | 935 ms | 24864 KB | Output is correct |
17 | Correct | 949 ms | 24888 KB | Output is correct |
18 | Correct | 927 ms | 24940 KB | Output is correct |
19 | Correct | 949 ms | 24864 KB | Output is correct |
20 | Correct | 954 ms | 24908 KB | Output is correct |
21 | Correct | 935 ms | 25012 KB | Output is correct |
22 | Correct | 937 ms | 25596 KB | Output is correct |
23 | Correct | 985 ms | 25584 KB | Output is correct |
24 | Correct | 923 ms | 25600 KB | Output is correct |
25 | Correct | 937 ms | 25652 KB | Output is correct |
26 | Correct | 976 ms | 25584 KB | Output is correct |
27 | Correct | 912 ms | 25576 KB | Output is correct |
28 | Correct | 961 ms | 25592 KB | Output is correct |
29 | Correct | 931 ms | 25592 KB | Output is correct |
30 | Correct | 926 ms | 25548 KB | Output is correct |
31 | Correct | 913 ms | 25580 KB | Output is correct |
32 | Correct | 923 ms | 25572 KB | Output is correct |
33 | Correct | 914 ms | 25616 KB | Output is correct |
34 | Correct | 891 ms | 25584 KB | Output is correct |
35 | Correct | 897 ms | 25652 KB | Output is correct |
36 | Correct | 906 ms | 25548 KB | Output is correct |
37 | Correct | 902 ms | 25600 KB | Output is correct |
38 | Correct | 910 ms | 25640 KB | Output is correct |
39 | Correct | 882 ms | 25584 KB | Output is correct |
40 | Correct | 900 ms | 25588 KB | Output is correct |
41 | Correct | 918 ms | 25620 KB | Output is correct |
42 | Correct | 887 ms | 25676 KB | Output is correct |
43 | Correct | 906 ms | 25896 KB | Output is correct |
44 | Correct | 875 ms | 25900 KB | Output is correct |
45 | Correct | 878 ms | 25924 KB | Output is correct |
46 | Correct | 875 ms | 25864 KB | Output is correct |
47 | Correct | 905 ms | 25812 KB | Output is correct |
48 | Correct | 885 ms | 25792 KB | Output is correct |
49 | Correct | 883 ms | 25804 KB | Output is correct |
50 | Correct | 883 ms | 25868 KB | Output is correct |
51 | Correct | 894 ms | 25876 KB | Output is correct |
52 | Correct | 886 ms | 25856 KB | Output is correct |
53 | Correct | 897 ms | 25852 KB | Output is correct |
54 | Correct | 882 ms | 25892 KB | Output is correct |
55 | Correct | 879 ms | 25800 KB | Output is correct |
56 | Correct | 882 ms | 25868 KB | Output is correct |
57 | Correct | 877 ms | 25868 KB | Output is correct |
58 | Correct | 901 ms | 25844 KB | Output is correct |
59 | Correct | 893 ms | 25808 KB | Output is correct |
60 | Correct | 884 ms | 25704 KB | Output is correct |
61 | Correct | 890 ms | 25776 KB | Output is correct |
62 | Correct | 886 ms | 25760 KB | Output is correct |
63 | Correct | 877 ms | 25800 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 884 ms | 24884 KB | Output is correct |
2 | Correct | 922 ms | 24920 KB | Output is correct |
3 | Correct | 918 ms | 25116 KB | Output is correct |
4 | Correct | 900 ms | 24860 KB | Output is correct |
5 | Correct | 916 ms | 24876 KB | Output is correct |
6 | Correct | 947 ms | 24880 KB | Output is correct |
7 | Correct | 957 ms | 24932 KB | Output is correct |
8 | Correct | 928 ms | 24880 KB | Output is correct |
9 | Correct | 920 ms | 24868 KB | Output is correct |
10 | Correct | 940 ms | 24956 KB | Output is correct |
11 | Correct | 930 ms | 24876 KB | Output is correct |
12 | Correct | 955 ms | 24860 KB | Output is correct |
13 | Correct | 933 ms | 24888 KB | Output is correct |
14 | Correct | 934 ms | 24884 KB | Output is correct |
15 | Correct | 943 ms | 24936 KB | Output is correct |
16 | Correct | 935 ms | 24864 KB | Output is correct |
17 | Correct | 949 ms | 24888 KB | Output is correct |
18 | Correct | 927 ms | 24940 KB | Output is correct |
19 | Correct | 949 ms | 24864 KB | Output is correct |
20 | Correct | 954 ms | 24908 KB | Output is correct |
21 | Correct | 935 ms | 25012 KB | Output is correct |
22 | Correct | 937 ms | 25596 KB | Output is correct |
23 | Correct | 985 ms | 25584 KB | Output is correct |
24 | Correct | 923 ms | 25600 KB | Output is correct |
25 | Correct | 937 ms | 25652 KB | Output is correct |
26 | Correct | 976 ms | 25584 KB | Output is correct |
27 | Correct | 912 ms | 25576 KB | Output is correct |
28 | Correct | 961 ms | 25592 KB | Output is correct |
29 | Correct | 931 ms | 25592 KB | Output is correct |
30 | Correct | 926 ms | 25548 KB | Output is correct |
31 | Correct | 913 ms | 25580 KB | Output is correct |
32 | Correct | 923 ms | 25572 KB | Output is correct |
33 | Correct | 914 ms | 25616 KB | Output is correct |
34 | Correct | 891 ms | 25584 KB | Output is correct |
35 | Correct | 897 ms | 25652 KB | Output is correct |
36 | Correct | 906 ms | 25548 KB | Output is correct |
37 | Correct | 902 ms | 25600 KB | Output is correct |
38 | Correct | 910 ms | 25640 KB | Output is correct |
39 | Correct | 882 ms | 25584 KB | Output is correct |
40 | Correct | 900 ms | 25588 KB | Output is correct |
41 | Correct | 918 ms | 25620 KB | Output is correct |
42 | Correct | 887 ms | 25676 KB | Output is correct |
43 | Correct | 906 ms | 25896 KB | Output is correct |
44 | Correct | 875 ms | 25900 KB | Output is correct |
45 | Correct | 878 ms | 25924 KB | Output is correct |
46 | Correct | 875 ms | 25864 KB | Output is correct |
47 | Correct | 905 ms | 25812 KB | Output is correct |
48 | Correct | 885 ms | 25792 KB | Output is correct |
49 | Correct | 883 ms | 25804 KB | Output is correct |
50 | Correct | 883 ms | 25868 KB | Output is correct |
51 | Correct | 894 ms | 25876 KB | Output is correct |
52 | Correct | 886 ms | 25856 KB | Output is correct |
53 | Correct | 897 ms | 25852 KB | Output is correct |
54 | Correct | 882 ms | 25892 KB | Output is correct |
55 | Correct | 879 ms | 25800 KB | Output is correct |
56 | Correct | 882 ms | 25868 KB | Output is correct |
57 | Correct | 877 ms | 25868 KB | Output is correct |
58 | Correct | 901 ms | 25844 KB | Output is correct |
59 | Correct | 893 ms | 25808 KB | Output is correct |
60 | Correct | 884 ms | 25704 KB | Output is correct |
61 | Correct | 890 ms | 25776 KB | Output is correct |
62 | Correct | 886 ms | 25760 KB | Output is correct |
63 | Correct | 877 ms | 25800 KB | Output is correct |
64 | Correct | 886 ms | 25984 KB | Output is correct |
65 | Correct | 873 ms | 26136 KB | Output is correct |
66 | Correct | 878 ms | 26104 KB | Output is correct |
67 | Correct | 869 ms | 26052 KB | Output is correct |
68 | Correct | 882 ms | 26056 KB | Output is correct |
69 | Correct | 886 ms | 25976 KB | Output is correct |
70 | Correct | 911 ms | 26060 KB | Output is correct |
71 | Correct | 887 ms | 26048 KB | Output is correct |
72 | Correct | 871 ms | 26104 KB | Output is correct |
73 | Correct | 881 ms | 26180 KB | Output is correct |
74 | Correct | 881 ms | 26060 KB | Output is correct |
75 | Correct | 871 ms | 26040 KB | Output is correct |
76 | Correct | 875 ms | 26048 KB | Output is correct |
77 | Correct | 875 ms | 26060 KB | Output is correct |
78 | Correct | 874 ms | 26060 KB | Output is correct |
79 | Correct | 891 ms | 26052 KB | Output is correct |
80 | Correct | 871 ms | 26056 KB | Output is correct |
81 | Correct | 895 ms | 26088 KB | Output is correct |
82 | Correct | 887 ms | 26072 KB | Output is correct |
83 | Correct | 874 ms | 26056 KB | Output is correct |
84 | Correct | 885 ms | 26248 KB | Output is correct |