# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
533210 |
2022-03-05T06:36:36 Z |
wenqi |
Cubeword (CEOI19_cubeword) |
C++17 |
|
1100 ms |
23228 KB |
// trans rights
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define MOD 998244353
#define H 62
int N;
unordered_set<string> problems[11][H];
int pre[11][H][H];
int cnt[11][H][H][H];
int mapping[256];
bool is_palindrome(const string& word)
{
return equal(word.begin(), word.end(), word.rbegin());
}
ll mul(ll x, ll y)
{
return (x * y) % MOD;
}
template <typename ...Args>
ll mul(ll x, ll y, Args&&... args)
{
return mul(mul(x, y), forward<Args>(args)...);
}
int main(int argc, const char *argv[])
{
ios_base::sync_with_stdio(0);
cin.tie(0);
for (int x = 'a'; x <= 'z'; x++)
{
mapping[x] = x - 'a';
}
for (int x = 'A'; x <= 'Z'; x++)
{
mapping[x] = x - 'A' + 26;
}
for (int x = '0'; x <= '9'; x++)
{
mapping[x] = x - '0' + 52;
}
cin >> N;
for (int k = 0; k < N; k++)
{
string word;
cin >> word;
problems[word.size()][mapping[word[0]]].insert(word);
reverse(word.begin(), word.end());
problems[word.size()][mapping[word[0]]].insert(word);
}
int ans = 0;
for (int sz = 1; sz <= 10; sz++)
{
for (int start = 0; start < H; start++)
{
for (auto &word : problems[sz][start])
{
pre[sz][start][mapping[word.back()]]++;
}
}
}
for (int sz = 1; sz <= 10; sz++)
{
for (int start = 0; start < H; start++)
{
auto &A = pre[sz][start];
for (int x = 0; x < H; x++)
{
if (A[x] == 0)
continue;
for (int y = 0; y < H; y++)
{
if (A[y] == 0)
continue;
for (int z = 0; z < H; z++)
{
cnt[sz][x][y][z] += mul(A[x], A[y], A[z]);
if (cnt[sz][x][y][z] >= MOD) cnt[sz][x][y][z] -= MOD;
}
}
}
}
}
for (int sz = 1; sz <= 10; sz++)
{
for (int x = 0; x < H; x++)
{
for (int y = 0; y < H; y++)
{
for (int z = 0; z < H; z++)
{
if (cnt[sz][x][y][z] == 0)
continue;
for (int w = 0; w < H; w++)
{
ans += mul(cnt[sz][x][y][z], cnt[sz][x][y][w], cnt[sz][x][z][w], cnt[sz][y][z][w]);
if (ans >= MOD) ans -= MOD;
}
}
}
}
}
cout << ans;
return 0;
}
Compilation message
cubeword.cpp: In function 'int main(int, const char**)':
cubeword.cpp:54:46: warning: array subscript has type 'char' [-Wchar-subscripts]
54 | problems[word.size()][mapping[word[0]]].insert(word);
| ^
cubeword.cpp:57:46: warning: array subscript has type 'char' [-Wchar-subscripts]
57 | problems[word.size()][mapping[word[0]]].insert(word);
| ^
cubeword.cpp:67:49: warning: array subscript has type 'char' [-Wchar-subscripts]
67 | pre[sz][start][mapping[word.back()]]++;
| ~~~~~~~~~^~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
107 ms |
15300 KB |
Output is correct |
2 |
Correct |
90 ms |
15336 KB |
Output is correct |
3 |
Correct |
89 ms |
15352 KB |
Output is correct |
4 |
Correct |
103 ms |
15376 KB |
Output is correct |
5 |
Correct |
133 ms |
15368 KB |
Output is correct |
6 |
Correct |
91 ms |
15300 KB |
Output is correct |
7 |
Correct |
97 ms |
15404 KB |
Output is correct |
8 |
Correct |
112 ms |
15312 KB |
Output is correct |
9 |
Correct |
116 ms |
15400 KB |
Output is correct |
10 |
Correct |
120 ms |
15340 KB |
Output is correct |
11 |
Correct |
113 ms |
15372 KB |
Output is correct |
12 |
Correct |
124 ms |
15284 KB |
Output is correct |
13 |
Correct |
85 ms |
15396 KB |
Output is correct |
14 |
Correct |
95 ms |
15352 KB |
Output is correct |
15 |
Correct |
88 ms |
15300 KB |
Output is correct |
16 |
Correct |
113 ms |
15316 KB |
Output is correct |
17 |
Correct |
105 ms |
15388 KB |
Output is correct |
18 |
Correct |
92 ms |
15376 KB |
Output is correct |
19 |
Correct |
104 ms |
15344 KB |
Output is correct |
20 |
Correct |
109 ms |
15332 KB |
Output is correct |
21 |
Correct |
97 ms |
15384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
107 ms |
15300 KB |
Output is correct |
2 |
Correct |
90 ms |
15336 KB |
Output is correct |
3 |
Correct |
89 ms |
15352 KB |
Output is correct |
4 |
Correct |
103 ms |
15376 KB |
Output is correct |
5 |
Correct |
133 ms |
15368 KB |
Output is correct |
6 |
Correct |
91 ms |
15300 KB |
Output is correct |
7 |
Correct |
97 ms |
15404 KB |
Output is correct |
8 |
Correct |
112 ms |
15312 KB |
Output is correct |
9 |
Correct |
116 ms |
15400 KB |
Output is correct |
10 |
Correct |
120 ms |
15340 KB |
Output is correct |
11 |
Correct |
113 ms |
15372 KB |
Output is correct |
12 |
Correct |
124 ms |
15284 KB |
Output is correct |
13 |
Correct |
85 ms |
15396 KB |
Output is correct |
14 |
Correct |
95 ms |
15352 KB |
Output is correct |
15 |
Correct |
88 ms |
15300 KB |
Output is correct |
16 |
Correct |
113 ms |
15316 KB |
Output is correct |
17 |
Correct |
105 ms |
15388 KB |
Output is correct |
18 |
Correct |
92 ms |
15376 KB |
Output is correct |
19 |
Correct |
104 ms |
15344 KB |
Output is correct |
20 |
Correct |
109 ms |
15332 KB |
Output is correct |
21 |
Correct |
97 ms |
15384 KB |
Output is correct |
22 |
Correct |
113 ms |
16468 KB |
Output is correct |
23 |
Correct |
120 ms |
16336 KB |
Output is correct |
24 |
Correct |
120 ms |
16364 KB |
Output is correct |
25 |
Correct |
109 ms |
16348 KB |
Output is correct |
26 |
Correct |
113 ms |
16500 KB |
Output is correct |
27 |
Correct |
131 ms |
16484 KB |
Output is correct |
28 |
Correct |
109 ms |
16328 KB |
Output is correct |
29 |
Correct |
108 ms |
16360 KB |
Output is correct |
30 |
Correct |
119 ms |
16380 KB |
Output is correct |
31 |
Correct |
121 ms |
16416 KB |
Output is correct |
32 |
Correct |
151 ms |
16444 KB |
Output is correct |
33 |
Correct |
110 ms |
16380 KB |
Output is correct |
34 |
Correct |
111 ms |
16364 KB |
Output is correct |
35 |
Correct |
124 ms |
16508 KB |
Output is correct |
36 |
Correct |
156 ms |
16432 KB |
Output is correct |
37 |
Correct |
112 ms |
16380 KB |
Output is correct |
38 |
Correct |
106 ms |
16428 KB |
Output is correct |
39 |
Correct |
116 ms |
16452 KB |
Output is correct |
40 |
Correct |
140 ms |
16504 KB |
Output is correct |
41 |
Correct |
113 ms |
16428 KB |
Output is correct |
42 |
Correct |
107 ms |
16452 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
107 ms |
15300 KB |
Output is correct |
2 |
Correct |
90 ms |
15336 KB |
Output is correct |
3 |
Correct |
89 ms |
15352 KB |
Output is correct |
4 |
Correct |
103 ms |
15376 KB |
Output is correct |
5 |
Correct |
133 ms |
15368 KB |
Output is correct |
6 |
Correct |
91 ms |
15300 KB |
Output is correct |
7 |
Correct |
97 ms |
15404 KB |
Output is correct |
8 |
Correct |
112 ms |
15312 KB |
Output is correct |
9 |
Correct |
116 ms |
15400 KB |
Output is correct |
10 |
Correct |
120 ms |
15340 KB |
Output is correct |
11 |
Correct |
113 ms |
15372 KB |
Output is correct |
12 |
Correct |
124 ms |
15284 KB |
Output is correct |
13 |
Correct |
85 ms |
15396 KB |
Output is correct |
14 |
Correct |
95 ms |
15352 KB |
Output is correct |
15 |
Correct |
88 ms |
15300 KB |
Output is correct |
16 |
Correct |
113 ms |
15316 KB |
Output is correct |
17 |
Correct |
105 ms |
15388 KB |
Output is correct |
18 |
Correct |
92 ms |
15376 KB |
Output is correct |
19 |
Correct |
104 ms |
15344 KB |
Output is correct |
20 |
Correct |
109 ms |
15332 KB |
Output is correct |
21 |
Correct |
97 ms |
15384 KB |
Output is correct |
22 |
Correct |
113 ms |
16468 KB |
Output is correct |
23 |
Correct |
120 ms |
16336 KB |
Output is correct |
24 |
Correct |
120 ms |
16364 KB |
Output is correct |
25 |
Correct |
109 ms |
16348 KB |
Output is correct |
26 |
Correct |
113 ms |
16500 KB |
Output is correct |
27 |
Correct |
131 ms |
16484 KB |
Output is correct |
28 |
Correct |
109 ms |
16328 KB |
Output is correct |
29 |
Correct |
108 ms |
16360 KB |
Output is correct |
30 |
Correct |
119 ms |
16380 KB |
Output is correct |
31 |
Correct |
121 ms |
16416 KB |
Output is correct |
32 |
Correct |
151 ms |
16444 KB |
Output is correct |
33 |
Correct |
110 ms |
16380 KB |
Output is correct |
34 |
Correct |
111 ms |
16364 KB |
Output is correct |
35 |
Correct |
124 ms |
16508 KB |
Output is correct |
36 |
Correct |
156 ms |
16432 KB |
Output is correct |
37 |
Correct |
112 ms |
16380 KB |
Output is correct |
38 |
Correct |
106 ms |
16428 KB |
Output is correct |
39 |
Correct |
116 ms |
16452 KB |
Output is correct |
40 |
Correct |
140 ms |
16504 KB |
Output is correct |
41 |
Correct |
113 ms |
16428 KB |
Output is correct |
42 |
Correct |
107 ms |
16452 KB |
Output is correct |
43 |
Correct |
273 ms |
19432 KB |
Output is correct |
44 |
Correct |
299 ms |
19344 KB |
Output is correct |
45 |
Correct |
235 ms |
19396 KB |
Output is correct |
46 |
Correct |
245 ms |
19268 KB |
Output is correct |
47 |
Correct |
265 ms |
19244 KB |
Output is correct |
48 |
Correct |
265 ms |
19420 KB |
Output is correct |
49 |
Correct |
272 ms |
19292 KB |
Output is correct |
50 |
Correct |
241 ms |
19344 KB |
Output is correct |
51 |
Correct |
263 ms |
19412 KB |
Output is correct |
52 |
Correct |
264 ms |
19336 KB |
Output is correct |
53 |
Correct |
275 ms |
19440 KB |
Output is correct |
54 |
Correct |
259 ms |
19248 KB |
Output is correct |
55 |
Correct |
257 ms |
19348 KB |
Output is correct |
56 |
Correct |
263 ms |
19344 KB |
Output is correct |
57 |
Correct |
269 ms |
19252 KB |
Output is correct |
58 |
Correct |
321 ms |
19328 KB |
Output is correct |
59 |
Correct |
259 ms |
19356 KB |
Output is correct |
60 |
Correct |
281 ms |
19348 KB |
Output is correct |
61 |
Correct |
280 ms |
19348 KB |
Output is correct |
62 |
Correct |
290 ms |
19244 KB |
Output is correct |
63 |
Correct |
297 ms |
19304 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
107 ms |
15300 KB |
Output is correct |
2 |
Correct |
90 ms |
15336 KB |
Output is correct |
3 |
Correct |
89 ms |
15352 KB |
Output is correct |
4 |
Correct |
103 ms |
15376 KB |
Output is correct |
5 |
Correct |
133 ms |
15368 KB |
Output is correct |
6 |
Correct |
91 ms |
15300 KB |
Output is correct |
7 |
Correct |
97 ms |
15404 KB |
Output is correct |
8 |
Correct |
112 ms |
15312 KB |
Output is correct |
9 |
Correct |
116 ms |
15400 KB |
Output is correct |
10 |
Correct |
120 ms |
15340 KB |
Output is correct |
11 |
Correct |
113 ms |
15372 KB |
Output is correct |
12 |
Correct |
124 ms |
15284 KB |
Output is correct |
13 |
Correct |
85 ms |
15396 KB |
Output is correct |
14 |
Correct |
95 ms |
15352 KB |
Output is correct |
15 |
Correct |
88 ms |
15300 KB |
Output is correct |
16 |
Correct |
113 ms |
15316 KB |
Output is correct |
17 |
Correct |
105 ms |
15388 KB |
Output is correct |
18 |
Correct |
92 ms |
15376 KB |
Output is correct |
19 |
Correct |
104 ms |
15344 KB |
Output is correct |
20 |
Correct |
109 ms |
15332 KB |
Output is correct |
21 |
Correct |
97 ms |
15384 KB |
Output is correct |
22 |
Correct |
113 ms |
16468 KB |
Output is correct |
23 |
Correct |
120 ms |
16336 KB |
Output is correct |
24 |
Correct |
120 ms |
16364 KB |
Output is correct |
25 |
Correct |
109 ms |
16348 KB |
Output is correct |
26 |
Correct |
113 ms |
16500 KB |
Output is correct |
27 |
Correct |
131 ms |
16484 KB |
Output is correct |
28 |
Correct |
109 ms |
16328 KB |
Output is correct |
29 |
Correct |
108 ms |
16360 KB |
Output is correct |
30 |
Correct |
119 ms |
16380 KB |
Output is correct |
31 |
Correct |
121 ms |
16416 KB |
Output is correct |
32 |
Correct |
151 ms |
16444 KB |
Output is correct |
33 |
Correct |
110 ms |
16380 KB |
Output is correct |
34 |
Correct |
111 ms |
16364 KB |
Output is correct |
35 |
Correct |
124 ms |
16508 KB |
Output is correct |
36 |
Correct |
156 ms |
16432 KB |
Output is correct |
37 |
Correct |
112 ms |
16380 KB |
Output is correct |
38 |
Correct |
106 ms |
16428 KB |
Output is correct |
39 |
Correct |
116 ms |
16452 KB |
Output is correct |
40 |
Correct |
140 ms |
16504 KB |
Output is correct |
41 |
Correct |
113 ms |
16428 KB |
Output is correct |
42 |
Correct |
107 ms |
16452 KB |
Output is correct |
43 |
Correct |
273 ms |
19432 KB |
Output is correct |
44 |
Correct |
299 ms |
19344 KB |
Output is correct |
45 |
Correct |
235 ms |
19396 KB |
Output is correct |
46 |
Correct |
245 ms |
19268 KB |
Output is correct |
47 |
Correct |
265 ms |
19244 KB |
Output is correct |
48 |
Correct |
265 ms |
19420 KB |
Output is correct |
49 |
Correct |
272 ms |
19292 KB |
Output is correct |
50 |
Correct |
241 ms |
19344 KB |
Output is correct |
51 |
Correct |
263 ms |
19412 KB |
Output is correct |
52 |
Correct |
264 ms |
19336 KB |
Output is correct |
53 |
Correct |
275 ms |
19440 KB |
Output is correct |
54 |
Correct |
259 ms |
19248 KB |
Output is correct |
55 |
Correct |
257 ms |
19348 KB |
Output is correct |
56 |
Correct |
263 ms |
19344 KB |
Output is correct |
57 |
Correct |
269 ms |
19252 KB |
Output is correct |
58 |
Correct |
321 ms |
19328 KB |
Output is correct |
59 |
Correct |
259 ms |
19356 KB |
Output is correct |
60 |
Correct |
281 ms |
19348 KB |
Output is correct |
61 |
Correct |
280 ms |
19348 KB |
Output is correct |
62 |
Correct |
290 ms |
19244 KB |
Output is correct |
63 |
Correct |
297 ms |
19304 KB |
Output is correct |
64 |
Execution timed out |
1188 ms |
23228 KB |
Time limit exceeded |
65 |
Halted |
0 ms |
0 KB |
- |