# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
779939 |
2023-07-12T03:32:41 Z |
mmk |
Cubeword (CEOI19_cubeword) |
C++14 |
|
989 ms |
17760 KB |
#include <bits/stdc++.h>
using namespace std;
#define int long long int
const int ALP = 62;
const int MOD = 998244353;
unordered_set<string> s[15];
int32_t main(void){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n; cin >> n;
for(int i = 1; i <= n; i++){
string cur; cin >> cur;
s[cur.size()].emplace(cur);
reverse(cur.begin(), cur.end());
s[cur.size()].emplace(cur);
}
auto getId = [&](char c)
{
if(c <= '9') return c - '0';
if(c <= 'Z') return ('9' - '0' + 1) + c - 'A';
return ('9' - '0' + 1) + ('Z' - 'A') + 1 + c - 'a';
};
auto solve = [&](int tam)
{
int dp[ALP][ALP][ALP] = { 0 };
int freq[ALP][ALP] = { 0 };
for(auto x : s[tam]){
int i = getId(x[0]), j = getId(x.back());
freq[i][j]++;
}
for(int a = 0; a < ALP; a++)
for(int b = 0; b < ALP; b++)
for(int c = 0; c < ALP; c++)
for(int i = 0; i < ALP; i++)
dp[a][b][c] = (dp[a][b][c] + (freq[a][i] * freq[b][i] * freq[c][i]) % MOD) % MOD;
int ret = 0;
for(int a = 0; a < ALP; a++){
for(int b = 0; b < ALP; b++){
for(int c = 0; c < ALP; c++){
for(int d = 0; d < ALP; d++){
int curAdd = 1;
curAdd = (curAdd * dp[a][b][c]) % MOD;
curAdd = (curAdd * dp[b][c][d]) % MOD;
curAdd = (curAdd * dp[a][b][d]) % MOD;
curAdd = (curAdd * dp[a][c][d]) % MOD;
ret += curAdd;
}
}
}
}
return ret;
};
int ans = 0;
for(int i = 1; i <= 10; i++)
{
if(s[i].empty()) continue;
ans = (ans + solve(i)) % MOD;
}
cout << ans << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
960 ms |
15580 KB |
Output is correct |
2 |
Correct |
955 ms |
16420 KB |
Output is correct |
3 |
Correct |
957 ms |
16428 KB |
Output is correct |
4 |
Correct |
965 ms |
16416 KB |
Output is correct |
5 |
Correct |
955 ms |
16408 KB |
Output is correct |
6 |
Correct |
961 ms |
16432 KB |
Output is correct |
7 |
Correct |
959 ms |
16432 KB |
Output is correct |
8 |
Correct |
967 ms |
16432 KB |
Output is correct |
9 |
Correct |
975 ms |
16424 KB |
Output is correct |
10 |
Correct |
954 ms |
16432 KB |
Output is correct |
11 |
Correct |
950 ms |
16424 KB |
Output is correct |
12 |
Correct |
960 ms |
16412 KB |
Output is correct |
13 |
Correct |
953 ms |
16428 KB |
Output is correct |
14 |
Correct |
963 ms |
16424 KB |
Output is correct |
15 |
Correct |
963 ms |
16436 KB |
Output is correct |
16 |
Correct |
959 ms |
16424 KB |
Output is correct |
17 |
Correct |
963 ms |
16428 KB |
Output is correct |
18 |
Correct |
965 ms |
16420 KB |
Output is correct |
19 |
Correct |
965 ms |
16520 KB |
Output is correct |
20 |
Correct |
960 ms |
16432 KB |
Output is correct |
21 |
Correct |
962 ms |
16412 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
960 ms |
15580 KB |
Output is correct |
2 |
Correct |
955 ms |
16420 KB |
Output is correct |
3 |
Correct |
957 ms |
16428 KB |
Output is correct |
4 |
Correct |
965 ms |
16416 KB |
Output is correct |
5 |
Correct |
955 ms |
16408 KB |
Output is correct |
6 |
Correct |
961 ms |
16432 KB |
Output is correct |
7 |
Correct |
959 ms |
16432 KB |
Output is correct |
8 |
Correct |
967 ms |
16432 KB |
Output is correct |
9 |
Correct |
975 ms |
16424 KB |
Output is correct |
10 |
Correct |
954 ms |
16432 KB |
Output is correct |
11 |
Correct |
950 ms |
16424 KB |
Output is correct |
12 |
Correct |
960 ms |
16412 KB |
Output is correct |
13 |
Correct |
953 ms |
16428 KB |
Output is correct |
14 |
Correct |
963 ms |
16424 KB |
Output is correct |
15 |
Correct |
963 ms |
16436 KB |
Output is correct |
16 |
Correct |
959 ms |
16424 KB |
Output is correct |
17 |
Correct |
963 ms |
16428 KB |
Output is correct |
18 |
Correct |
965 ms |
16420 KB |
Output is correct |
19 |
Correct |
965 ms |
16520 KB |
Output is correct |
20 |
Correct |
960 ms |
16432 KB |
Output is correct |
21 |
Correct |
962 ms |
16412 KB |
Output is correct |
22 |
Correct |
957 ms |
17476 KB |
Output is correct |
23 |
Correct |
961 ms |
17472 KB |
Output is correct |
24 |
Correct |
961 ms |
17524 KB |
Output is correct |
25 |
Correct |
961 ms |
17488 KB |
Output is correct |
26 |
Correct |
967 ms |
17472 KB |
Output is correct |
27 |
Correct |
967 ms |
17528 KB |
Output is correct |
28 |
Correct |
958 ms |
17472 KB |
Output is correct |
29 |
Correct |
961 ms |
17480 KB |
Output is correct |
30 |
Correct |
960 ms |
17468 KB |
Output is correct |
31 |
Correct |
964 ms |
17476 KB |
Output is correct |
32 |
Correct |
971 ms |
17460 KB |
Output is correct |
33 |
Correct |
959 ms |
17468 KB |
Output is correct |
34 |
Correct |
958 ms |
17360 KB |
Output is correct |
35 |
Correct |
979 ms |
17472 KB |
Output is correct |
36 |
Correct |
956 ms |
17476 KB |
Output is correct |
37 |
Correct |
951 ms |
17524 KB |
Output is correct |
38 |
Correct |
957 ms |
17472 KB |
Output is correct |
39 |
Correct |
953 ms |
17472 KB |
Output is correct |
40 |
Correct |
961 ms |
17468 KB |
Output is correct |
41 |
Correct |
957 ms |
17472 KB |
Output is correct |
42 |
Correct |
963 ms |
17492 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
960 ms |
15580 KB |
Output is correct |
2 |
Correct |
955 ms |
16420 KB |
Output is correct |
3 |
Correct |
957 ms |
16428 KB |
Output is correct |
4 |
Correct |
965 ms |
16416 KB |
Output is correct |
5 |
Correct |
955 ms |
16408 KB |
Output is correct |
6 |
Correct |
961 ms |
16432 KB |
Output is correct |
7 |
Correct |
959 ms |
16432 KB |
Output is correct |
8 |
Correct |
967 ms |
16432 KB |
Output is correct |
9 |
Correct |
975 ms |
16424 KB |
Output is correct |
10 |
Correct |
954 ms |
16432 KB |
Output is correct |
11 |
Correct |
950 ms |
16424 KB |
Output is correct |
12 |
Correct |
960 ms |
16412 KB |
Output is correct |
13 |
Correct |
953 ms |
16428 KB |
Output is correct |
14 |
Correct |
963 ms |
16424 KB |
Output is correct |
15 |
Correct |
963 ms |
16436 KB |
Output is correct |
16 |
Correct |
959 ms |
16424 KB |
Output is correct |
17 |
Correct |
963 ms |
16428 KB |
Output is correct |
18 |
Correct |
965 ms |
16420 KB |
Output is correct |
19 |
Correct |
965 ms |
16520 KB |
Output is correct |
20 |
Correct |
960 ms |
16432 KB |
Output is correct |
21 |
Correct |
962 ms |
16412 KB |
Output is correct |
22 |
Correct |
957 ms |
17476 KB |
Output is correct |
23 |
Correct |
961 ms |
17472 KB |
Output is correct |
24 |
Correct |
961 ms |
17524 KB |
Output is correct |
25 |
Correct |
961 ms |
17488 KB |
Output is correct |
26 |
Correct |
967 ms |
17472 KB |
Output is correct |
27 |
Correct |
967 ms |
17528 KB |
Output is correct |
28 |
Correct |
958 ms |
17472 KB |
Output is correct |
29 |
Correct |
961 ms |
17480 KB |
Output is correct |
30 |
Correct |
960 ms |
17468 KB |
Output is correct |
31 |
Correct |
964 ms |
17476 KB |
Output is correct |
32 |
Correct |
971 ms |
17460 KB |
Output is correct |
33 |
Correct |
959 ms |
17468 KB |
Output is correct |
34 |
Correct |
958 ms |
17360 KB |
Output is correct |
35 |
Correct |
979 ms |
17472 KB |
Output is correct |
36 |
Correct |
956 ms |
17476 KB |
Output is correct |
37 |
Correct |
951 ms |
17524 KB |
Output is correct |
38 |
Correct |
957 ms |
17472 KB |
Output is correct |
39 |
Correct |
953 ms |
17472 KB |
Output is correct |
40 |
Correct |
961 ms |
17468 KB |
Output is correct |
41 |
Correct |
957 ms |
17472 KB |
Output is correct |
42 |
Correct |
963 ms |
17492 KB |
Output is correct |
43 |
Correct |
965 ms |
17740 KB |
Output is correct |
44 |
Correct |
958 ms |
17752 KB |
Output is correct |
45 |
Correct |
958 ms |
17656 KB |
Output is correct |
46 |
Correct |
955 ms |
17696 KB |
Output is correct |
47 |
Correct |
958 ms |
17604 KB |
Output is correct |
48 |
Correct |
959 ms |
17744 KB |
Output is correct |
49 |
Correct |
953 ms |
17652 KB |
Output is correct |
50 |
Correct |
961 ms |
17752 KB |
Output is correct |
51 |
Correct |
961 ms |
17756 KB |
Output is correct |
52 |
Correct |
972 ms |
17760 KB |
Output is correct |
53 |
Correct |
962 ms |
17736 KB |
Output is correct |
54 |
Correct |
961 ms |
17740 KB |
Output is correct |
55 |
Correct |
958 ms |
17740 KB |
Output is correct |
56 |
Correct |
964 ms |
17744 KB |
Output is correct |
57 |
Correct |
953 ms |
17720 KB |
Output is correct |
58 |
Correct |
965 ms |
17752 KB |
Output is correct |
59 |
Correct |
957 ms |
17736 KB |
Output is correct |
60 |
Correct |
962 ms |
17732 KB |
Output is correct |
61 |
Correct |
957 ms |
17732 KB |
Output is correct |
62 |
Correct |
967 ms |
17616 KB |
Output is correct |
63 |
Correct |
960 ms |
17632 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
960 ms |
15580 KB |
Output is correct |
2 |
Correct |
955 ms |
16420 KB |
Output is correct |
3 |
Correct |
957 ms |
16428 KB |
Output is correct |
4 |
Correct |
965 ms |
16416 KB |
Output is correct |
5 |
Correct |
955 ms |
16408 KB |
Output is correct |
6 |
Correct |
961 ms |
16432 KB |
Output is correct |
7 |
Correct |
959 ms |
16432 KB |
Output is correct |
8 |
Correct |
967 ms |
16432 KB |
Output is correct |
9 |
Correct |
975 ms |
16424 KB |
Output is correct |
10 |
Correct |
954 ms |
16432 KB |
Output is correct |
11 |
Correct |
950 ms |
16424 KB |
Output is correct |
12 |
Correct |
960 ms |
16412 KB |
Output is correct |
13 |
Correct |
953 ms |
16428 KB |
Output is correct |
14 |
Correct |
963 ms |
16424 KB |
Output is correct |
15 |
Correct |
963 ms |
16436 KB |
Output is correct |
16 |
Correct |
959 ms |
16424 KB |
Output is correct |
17 |
Correct |
963 ms |
16428 KB |
Output is correct |
18 |
Correct |
965 ms |
16420 KB |
Output is correct |
19 |
Correct |
965 ms |
16520 KB |
Output is correct |
20 |
Correct |
960 ms |
16432 KB |
Output is correct |
21 |
Correct |
962 ms |
16412 KB |
Output is correct |
22 |
Correct |
957 ms |
17476 KB |
Output is correct |
23 |
Correct |
961 ms |
17472 KB |
Output is correct |
24 |
Correct |
961 ms |
17524 KB |
Output is correct |
25 |
Correct |
961 ms |
17488 KB |
Output is correct |
26 |
Correct |
967 ms |
17472 KB |
Output is correct |
27 |
Correct |
967 ms |
17528 KB |
Output is correct |
28 |
Correct |
958 ms |
17472 KB |
Output is correct |
29 |
Correct |
961 ms |
17480 KB |
Output is correct |
30 |
Correct |
960 ms |
17468 KB |
Output is correct |
31 |
Correct |
964 ms |
17476 KB |
Output is correct |
32 |
Correct |
971 ms |
17460 KB |
Output is correct |
33 |
Correct |
959 ms |
17468 KB |
Output is correct |
34 |
Correct |
958 ms |
17360 KB |
Output is correct |
35 |
Correct |
979 ms |
17472 KB |
Output is correct |
36 |
Correct |
956 ms |
17476 KB |
Output is correct |
37 |
Correct |
951 ms |
17524 KB |
Output is correct |
38 |
Correct |
957 ms |
17472 KB |
Output is correct |
39 |
Correct |
953 ms |
17472 KB |
Output is correct |
40 |
Correct |
961 ms |
17468 KB |
Output is correct |
41 |
Correct |
957 ms |
17472 KB |
Output is correct |
42 |
Correct |
963 ms |
17492 KB |
Output is correct |
43 |
Correct |
965 ms |
17740 KB |
Output is correct |
44 |
Correct |
958 ms |
17752 KB |
Output is correct |
45 |
Correct |
958 ms |
17656 KB |
Output is correct |
46 |
Correct |
955 ms |
17696 KB |
Output is correct |
47 |
Correct |
958 ms |
17604 KB |
Output is correct |
48 |
Correct |
959 ms |
17744 KB |
Output is correct |
49 |
Correct |
953 ms |
17652 KB |
Output is correct |
50 |
Correct |
961 ms |
17752 KB |
Output is correct |
51 |
Correct |
961 ms |
17756 KB |
Output is correct |
52 |
Correct |
972 ms |
17760 KB |
Output is correct |
53 |
Correct |
962 ms |
17736 KB |
Output is correct |
54 |
Correct |
961 ms |
17740 KB |
Output is correct |
55 |
Correct |
958 ms |
17740 KB |
Output is correct |
56 |
Correct |
964 ms |
17744 KB |
Output is correct |
57 |
Correct |
953 ms |
17720 KB |
Output is correct |
58 |
Correct |
965 ms |
17752 KB |
Output is correct |
59 |
Correct |
957 ms |
17736 KB |
Output is correct |
60 |
Correct |
962 ms |
17732 KB |
Output is correct |
61 |
Correct |
957 ms |
17732 KB |
Output is correct |
62 |
Correct |
967 ms |
17616 KB |
Output is correct |
63 |
Correct |
960 ms |
17632 KB |
Output is correct |
64 |
Correct |
967 ms |
17732 KB |
Output is correct |
65 |
Correct |
970 ms |
17400 KB |
Output is correct |
66 |
Correct |
980 ms |
17356 KB |
Output is correct |
67 |
Correct |
960 ms |
17352 KB |
Output is correct |
68 |
Correct |
963 ms |
17352 KB |
Output is correct |
69 |
Correct |
973 ms |
17356 KB |
Output is correct |
70 |
Correct |
954 ms |
17360 KB |
Output is correct |
71 |
Correct |
989 ms |
17244 KB |
Output is correct |
72 |
Correct |
948 ms |
17404 KB |
Output is correct |
73 |
Correct |
952 ms |
17348 KB |
Output is correct |
74 |
Correct |
960 ms |
17356 KB |
Output is correct |
75 |
Correct |
954 ms |
17460 KB |
Output is correct |
76 |
Correct |
959 ms |
17344 KB |
Output is correct |
77 |
Correct |
955 ms |
17328 KB |
Output is correct |
78 |
Correct |
958 ms |
17356 KB |
Output is correct |
79 |
Correct |
949 ms |
17352 KB |
Output is correct |
80 |
Correct |
965 ms |
17352 KB |
Output is correct |
81 |
Correct |
961 ms |
17456 KB |
Output is correct |
82 |
Correct |
962 ms |
17344 KB |
Output is correct |
83 |
Correct |
972 ms |
17456 KB |
Output is correct |
84 |
Correct |
966 ms |
17352 KB |
Output is correct |