# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1025525 |
2024-07-17T06:10:20 Z |
우민규(#10941) |
Cubeword (CEOI19_cubeword) |
C++17 |
|
130 ms |
15860 KB |
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
const int SIGMA = 26;
const int MOD = 998244353;
int mul(int a, int b) { return (int64_t)a * (int64_t)b % MOD; }
int mul(int a, int b, int c) { return mul(mul(a, b), c); }
int mul(int a, int b, int c, int d) { return mul(mul(a, b), mul(c, d)); }
void add(int& a, int b) {
a = ((int64_t)a + (int64_t)b) % MOD;
// if (a >= MOD) a -= MOD;
}
int id(char c) {
if ('a' <= c && c <= 'z') return c - 'a';
if ('A' <= c && c <= 'Z') return c - 'A' + 26;
return c - '0' + 52;
// return 0;
}
int y[SIGMA][SIGMA][SIGMA];
int ways[8][SIGMA][SIGMA];
void solve() {
int n;
cin >> n;
set<string> saw;
for (int i = 0; i < n; ++i) {
string cur;
cin >> cur;
string cur_rev = cur;
reverse(cur_rev.begin(), cur_rev.end());
saw.insert(cur);
saw.insert(cur_rev);
}
for (auto& word : saw) {
int cf = id(word.front()), cb = id(word.back());
ways[word.size() - 3][cf][cb] += 1;
}
int tot_way = 0;
for (auto& way : ways) {
// do threes
fill(&y[0][0][0], &y[0][0][0] + SIGMA * SIGMA * SIGMA, 0);
for (int c1 = 0; c1 < SIGMA; ++c1)
for (int c2 = 0; c2 < SIGMA; ++c2)
for (int c3 = 0; c3 < SIGMA; ++c3)
for (int c4 = 0; c4 < SIGMA; ++c4)
add(y[c1][c2][c3], mul(way[c1][c4], way[c2][c4], way[c3][c4]));
for (int c1 = 0; c1 < SIGMA; ++c1)
for (int c2 = 0; c2 < SIGMA; ++c2)
for (int c3 = 0; c3 < SIGMA; ++c3)
for (int c4 = 0; c4 < SIGMA; ++c4)
add(tot_way, mul(y[c1][c2][c3], y[c1][c2][c4], y[c1][c3][c4],
y[c2][c3][c4]));
}
cout << tot_way << "\n";
}
int main() {
cin.tie(0)->sync_with_stdio(0);
int t = 1;
while (t--) {
solve();
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
113 ms |
14928 KB |
Output is correct |
2 |
Correct |
116 ms |
14928 KB |
Output is correct |
3 |
Correct |
117 ms |
14932 KB |
Output is correct |
4 |
Correct |
115 ms |
14928 KB |
Output is correct |
5 |
Correct |
115 ms |
14932 KB |
Output is correct |
6 |
Correct |
119 ms |
14932 KB |
Output is correct |
7 |
Correct |
117 ms |
14780 KB |
Output is correct |
8 |
Correct |
121 ms |
14908 KB |
Output is correct |
9 |
Correct |
114 ms |
15000 KB |
Output is correct |
10 |
Correct |
123 ms |
14928 KB |
Output is correct |
11 |
Correct |
114 ms |
14932 KB |
Output is correct |
12 |
Correct |
118 ms |
14760 KB |
Output is correct |
13 |
Correct |
117 ms |
14928 KB |
Output is correct |
14 |
Correct |
124 ms |
14932 KB |
Output is correct |
15 |
Correct |
115 ms |
14932 KB |
Output is correct |
16 |
Correct |
119 ms |
14932 KB |
Output is correct |
17 |
Correct |
115 ms |
14928 KB |
Output is correct |
18 |
Correct |
118 ms |
14784 KB |
Output is correct |
19 |
Correct |
115 ms |
14928 KB |
Output is correct |
20 |
Correct |
120 ms |
14932 KB |
Output is correct |
21 |
Correct |
115 ms |
14964 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
113 ms |
14928 KB |
Output is correct |
2 |
Correct |
116 ms |
14928 KB |
Output is correct |
3 |
Correct |
117 ms |
14932 KB |
Output is correct |
4 |
Correct |
115 ms |
14928 KB |
Output is correct |
5 |
Correct |
115 ms |
14932 KB |
Output is correct |
6 |
Correct |
119 ms |
14932 KB |
Output is correct |
7 |
Correct |
117 ms |
14780 KB |
Output is correct |
8 |
Correct |
121 ms |
14908 KB |
Output is correct |
9 |
Correct |
114 ms |
15000 KB |
Output is correct |
10 |
Correct |
123 ms |
14928 KB |
Output is correct |
11 |
Correct |
114 ms |
14932 KB |
Output is correct |
12 |
Correct |
118 ms |
14760 KB |
Output is correct |
13 |
Correct |
117 ms |
14928 KB |
Output is correct |
14 |
Correct |
124 ms |
14932 KB |
Output is correct |
15 |
Correct |
115 ms |
14932 KB |
Output is correct |
16 |
Correct |
119 ms |
14932 KB |
Output is correct |
17 |
Correct |
115 ms |
14928 KB |
Output is correct |
18 |
Correct |
118 ms |
14784 KB |
Output is correct |
19 |
Correct |
115 ms |
14928 KB |
Output is correct |
20 |
Correct |
120 ms |
14932 KB |
Output is correct |
21 |
Correct |
115 ms |
14964 KB |
Output is correct |
22 |
Correct |
119 ms |
15440 KB |
Output is correct |
23 |
Correct |
115 ms |
15584 KB |
Output is correct |
24 |
Correct |
116 ms |
15620 KB |
Output is correct |
25 |
Correct |
115 ms |
15444 KB |
Output is correct |
26 |
Correct |
115 ms |
15444 KB |
Output is correct |
27 |
Correct |
121 ms |
15444 KB |
Output is correct |
28 |
Correct |
116 ms |
15608 KB |
Output is correct |
29 |
Correct |
116 ms |
15444 KB |
Output is correct |
30 |
Correct |
121 ms |
15420 KB |
Output is correct |
31 |
Correct |
130 ms |
15636 KB |
Output is correct |
32 |
Correct |
129 ms |
15444 KB |
Output is correct |
33 |
Correct |
125 ms |
15440 KB |
Output is correct |
34 |
Correct |
124 ms |
15440 KB |
Output is correct |
35 |
Correct |
114 ms |
15444 KB |
Output is correct |
36 |
Correct |
130 ms |
15444 KB |
Output is correct |
37 |
Correct |
118 ms |
15436 KB |
Output is correct |
38 |
Correct |
116 ms |
15552 KB |
Output is correct |
39 |
Correct |
115 ms |
15668 KB |
Output is correct |
40 |
Correct |
112 ms |
15536 KB |
Output is correct |
41 |
Correct |
110 ms |
15444 KB |
Output is correct |
42 |
Correct |
120 ms |
15696 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
113 ms |
14928 KB |
Output is correct |
2 |
Correct |
116 ms |
14928 KB |
Output is correct |
3 |
Correct |
117 ms |
14932 KB |
Output is correct |
4 |
Correct |
115 ms |
14928 KB |
Output is correct |
5 |
Correct |
115 ms |
14932 KB |
Output is correct |
6 |
Correct |
119 ms |
14932 KB |
Output is correct |
7 |
Correct |
117 ms |
14780 KB |
Output is correct |
8 |
Correct |
121 ms |
14908 KB |
Output is correct |
9 |
Correct |
114 ms |
15000 KB |
Output is correct |
10 |
Correct |
123 ms |
14928 KB |
Output is correct |
11 |
Correct |
114 ms |
14932 KB |
Output is correct |
12 |
Correct |
118 ms |
14760 KB |
Output is correct |
13 |
Correct |
117 ms |
14928 KB |
Output is correct |
14 |
Correct |
124 ms |
14932 KB |
Output is correct |
15 |
Correct |
115 ms |
14932 KB |
Output is correct |
16 |
Correct |
119 ms |
14932 KB |
Output is correct |
17 |
Correct |
115 ms |
14928 KB |
Output is correct |
18 |
Correct |
118 ms |
14784 KB |
Output is correct |
19 |
Correct |
115 ms |
14928 KB |
Output is correct |
20 |
Correct |
120 ms |
14932 KB |
Output is correct |
21 |
Correct |
115 ms |
14964 KB |
Output is correct |
22 |
Correct |
119 ms |
15440 KB |
Output is correct |
23 |
Correct |
115 ms |
15584 KB |
Output is correct |
24 |
Correct |
116 ms |
15620 KB |
Output is correct |
25 |
Correct |
115 ms |
15444 KB |
Output is correct |
26 |
Correct |
115 ms |
15444 KB |
Output is correct |
27 |
Correct |
121 ms |
15444 KB |
Output is correct |
28 |
Correct |
116 ms |
15608 KB |
Output is correct |
29 |
Correct |
116 ms |
15444 KB |
Output is correct |
30 |
Correct |
121 ms |
15420 KB |
Output is correct |
31 |
Correct |
130 ms |
15636 KB |
Output is correct |
32 |
Correct |
129 ms |
15444 KB |
Output is correct |
33 |
Correct |
125 ms |
15440 KB |
Output is correct |
34 |
Correct |
124 ms |
15440 KB |
Output is correct |
35 |
Correct |
114 ms |
15444 KB |
Output is correct |
36 |
Correct |
130 ms |
15444 KB |
Output is correct |
37 |
Correct |
118 ms |
15436 KB |
Output is correct |
38 |
Correct |
116 ms |
15552 KB |
Output is correct |
39 |
Correct |
115 ms |
15668 KB |
Output is correct |
40 |
Correct |
112 ms |
15536 KB |
Output is correct |
41 |
Correct |
110 ms |
15444 KB |
Output is correct |
42 |
Correct |
120 ms |
15696 KB |
Output is correct |
43 |
Incorrect |
120 ms |
15860 KB |
Output isn't correct |
44 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
113 ms |
14928 KB |
Output is correct |
2 |
Correct |
116 ms |
14928 KB |
Output is correct |
3 |
Correct |
117 ms |
14932 KB |
Output is correct |
4 |
Correct |
115 ms |
14928 KB |
Output is correct |
5 |
Correct |
115 ms |
14932 KB |
Output is correct |
6 |
Correct |
119 ms |
14932 KB |
Output is correct |
7 |
Correct |
117 ms |
14780 KB |
Output is correct |
8 |
Correct |
121 ms |
14908 KB |
Output is correct |
9 |
Correct |
114 ms |
15000 KB |
Output is correct |
10 |
Correct |
123 ms |
14928 KB |
Output is correct |
11 |
Correct |
114 ms |
14932 KB |
Output is correct |
12 |
Correct |
118 ms |
14760 KB |
Output is correct |
13 |
Correct |
117 ms |
14928 KB |
Output is correct |
14 |
Correct |
124 ms |
14932 KB |
Output is correct |
15 |
Correct |
115 ms |
14932 KB |
Output is correct |
16 |
Correct |
119 ms |
14932 KB |
Output is correct |
17 |
Correct |
115 ms |
14928 KB |
Output is correct |
18 |
Correct |
118 ms |
14784 KB |
Output is correct |
19 |
Correct |
115 ms |
14928 KB |
Output is correct |
20 |
Correct |
120 ms |
14932 KB |
Output is correct |
21 |
Correct |
115 ms |
14964 KB |
Output is correct |
22 |
Correct |
119 ms |
15440 KB |
Output is correct |
23 |
Correct |
115 ms |
15584 KB |
Output is correct |
24 |
Correct |
116 ms |
15620 KB |
Output is correct |
25 |
Correct |
115 ms |
15444 KB |
Output is correct |
26 |
Correct |
115 ms |
15444 KB |
Output is correct |
27 |
Correct |
121 ms |
15444 KB |
Output is correct |
28 |
Correct |
116 ms |
15608 KB |
Output is correct |
29 |
Correct |
116 ms |
15444 KB |
Output is correct |
30 |
Correct |
121 ms |
15420 KB |
Output is correct |
31 |
Correct |
130 ms |
15636 KB |
Output is correct |
32 |
Correct |
129 ms |
15444 KB |
Output is correct |
33 |
Correct |
125 ms |
15440 KB |
Output is correct |
34 |
Correct |
124 ms |
15440 KB |
Output is correct |
35 |
Correct |
114 ms |
15444 KB |
Output is correct |
36 |
Correct |
130 ms |
15444 KB |
Output is correct |
37 |
Correct |
118 ms |
15436 KB |
Output is correct |
38 |
Correct |
116 ms |
15552 KB |
Output is correct |
39 |
Correct |
115 ms |
15668 KB |
Output is correct |
40 |
Correct |
112 ms |
15536 KB |
Output is correct |
41 |
Correct |
110 ms |
15444 KB |
Output is correct |
42 |
Correct |
120 ms |
15696 KB |
Output is correct |
43 |
Incorrect |
120 ms |
15860 KB |
Output isn't correct |
44 |
Halted |
0 ms |
0 KB |
- |