# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
533179 |
2022-03-05T04:51:52 Z |
wenqi |
Cubeword (CEOI19_cubeword) |
C++14 |
|
1100 ms |
24140 KB |
// trans rights
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define MOD 998244353
#define H 62
int N;
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++)
{
for (int z = 0; z < H; z++)
{
cnt[sz][x][y][z] += mul(A[x], A[y], A[z]);
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][w][z], cnt[sz][y][z][w]);
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 |
131 ms |
15556 KB |
Output is correct |
2 |
Correct |
124 ms |
16452 KB |
Output is correct |
3 |
Correct |
164 ms |
16460 KB |
Output is correct |
4 |
Correct |
176 ms |
16444 KB |
Output is correct |
5 |
Correct |
123 ms |
16380 KB |
Output is correct |
6 |
Correct |
132 ms |
16484 KB |
Output is correct |
7 |
Correct |
155 ms |
16504 KB |
Output is correct |
8 |
Correct |
128 ms |
16492 KB |
Output is correct |
9 |
Correct |
126 ms |
16436 KB |
Output is correct |
10 |
Correct |
149 ms |
16492 KB |
Output is correct |
11 |
Correct |
130 ms |
16432 KB |
Output is correct |
12 |
Correct |
128 ms |
16372 KB |
Output is correct |
13 |
Correct |
135 ms |
16472 KB |
Output is correct |
14 |
Correct |
172 ms |
16400 KB |
Output is correct |
15 |
Correct |
125 ms |
16524 KB |
Output is correct |
16 |
Correct |
135 ms |
16484 KB |
Output is correct |
17 |
Correct |
134 ms |
16388 KB |
Output is correct |
18 |
Correct |
137 ms |
16448 KB |
Output is correct |
19 |
Correct |
122 ms |
16408 KB |
Output is correct |
20 |
Correct |
133 ms |
16708 KB |
Output is correct |
21 |
Correct |
137 ms |
16484 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
131 ms |
15556 KB |
Output is correct |
2 |
Correct |
124 ms |
16452 KB |
Output is correct |
3 |
Correct |
164 ms |
16460 KB |
Output is correct |
4 |
Correct |
176 ms |
16444 KB |
Output is correct |
5 |
Correct |
123 ms |
16380 KB |
Output is correct |
6 |
Correct |
132 ms |
16484 KB |
Output is correct |
7 |
Correct |
155 ms |
16504 KB |
Output is correct |
8 |
Correct |
128 ms |
16492 KB |
Output is correct |
9 |
Correct |
126 ms |
16436 KB |
Output is correct |
10 |
Correct |
149 ms |
16492 KB |
Output is correct |
11 |
Correct |
130 ms |
16432 KB |
Output is correct |
12 |
Correct |
128 ms |
16372 KB |
Output is correct |
13 |
Correct |
135 ms |
16472 KB |
Output is correct |
14 |
Correct |
172 ms |
16400 KB |
Output is correct |
15 |
Correct |
125 ms |
16524 KB |
Output is correct |
16 |
Correct |
135 ms |
16484 KB |
Output is correct |
17 |
Correct |
134 ms |
16388 KB |
Output is correct |
18 |
Correct |
137 ms |
16448 KB |
Output is correct |
19 |
Correct |
122 ms |
16408 KB |
Output is correct |
20 |
Correct |
133 ms |
16708 KB |
Output is correct |
21 |
Correct |
137 ms |
16484 KB |
Output is correct |
22 |
Correct |
170 ms |
18288 KB |
Output is correct |
23 |
Correct |
167 ms |
18368 KB |
Output is correct |
24 |
Correct |
174 ms |
18184 KB |
Output is correct |
25 |
Correct |
168 ms |
18272 KB |
Output is correct |
26 |
Correct |
162 ms |
18248 KB |
Output is correct |
27 |
Correct |
173 ms |
18280 KB |
Output is correct |
28 |
Correct |
172 ms |
18296 KB |
Output is correct |
29 |
Correct |
157 ms |
18232 KB |
Output is correct |
30 |
Correct |
180 ms |
18252 KB |
Output is correct |
31 |
Correct |
161 ms |
18260 KB |
Output is correct |
32 |
Correct |
157 ms |
18204 KB |
Output is correct |
33 |
Correct |
176 ms |
18268 KB |
Output is correct |
34 |
Correct |
174 ms |
18244 KB |
Output is correct |
35 |
Correct |
156 ms |
18300 KB |
Output is correct |
36 |
Correct |
195 ms |
18248 KB |
Output is correct |
37 |
Correct |
198 ms |
18312 KB |
Output is correct |
38 |
Correct |
155 ms |
18244 KB |
Output is correct |
39 |
Correct |
168 ms |
18208 KB |
Output is correct |
40 |
Correct |
192 ms |
18272 KB |
Output is correct |
41 |
Correct |
175 ms |
18328 KB |
Output is correct |
42 |
Correct |
164 ms |
18188 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
131 ms |
15556 KB |
Output is correct |
2 |
Correct |
124 ms |
16452 KB |
Output is correct |
3 |
Correct |
164 ms |
16460 KB |
Output is correct |
4 |
Correct |
176 ms |
16444 KB |
Output is correct |
5 |
Correct |
123 ms |
16380 KB |
Output is correct |
6 |
Correct |
132 ms |
16484 KB |
Output is correct |
7 |
Correct |
155 ms |
16504 KB |
Output is correct |
8 |
Correct |
128 ms |
16492 KB |
Output is correct |
9 |
Correct |
126 ms |
16436 KB |
Output is correct |
10 |
Correct |
149 ms |
16492 KB |
Output is correct |
11 |
Correct |
130 ms |
16432 KB |
Output is correct |
12 |
Correct |
128 ms |
16372 KB |
Output is correct |
13 |
Correct |
135 ms |
16472 KB |
Output is correct |
14 |
Correct |
172 ms |
16400 KB |
Output is correct |
15 |
Correct |
125 ms |
16524 KB |
Output is correct |
16 |
Correct |
135 ms |
16484 KB |
Output is correct |
17 |
Correct |
134 ms |
16388 KB |
Output is correct |
18 |
Correct |
137 ms |
16448 KB |
Output is correct |
19 |
Correct |
122 ms |
16408 KB |
Output is correct |
20 |
Correct |
133 ms |
16708 KB |
Output is correct |
21 |
Correct |
137 ms |
16484 KB |
Output is correct |
22 |
Correct |
170 ms |
18288 KB |
Output is correct |
23 |
Correct |
167 ms |
18368 KB |
Output is correct |
24 |
Correct |
174 ms |
18184 KB |
Output is correct |
25 |
Correct |
168 ms |
18272 KB |
Output is correct |
26 |
Correct |
162 ms |
18248 KB |
Output is correct |
27 |
Correct |
173 ms |
18280 KB |
Output is correct |
28 |
Correct |
172 ms |
18296 KB |
Output is correct |
29 |
Correct |
157 ms |
18232 KB |
Output is correct |
30 |
Correct |
180 ms |
18252 KB |
Output is correct |
31 |
Correct |
161 ms |
18260 KB |
Output is correct |
32 |
Correct |
157 ms |
18204 KB |
Output is correct |
33 |
Correct |
176 ms |
18268 KB |
Output is correct |
34 |
Correct |
174 ms |
18244 KB |
Output is correct |
35 |
Correct |
156 ms |
18300 KB |
Output is correct |
36 |
Correct |
195 ms |
18248 KB |
Output is correct |
37 |
Correct |
198 ms |
18312 KB |
Output is correct |
38 |
Correct |
155 ms |
18244 KB |
Output is correct |
39 |
Correct |
168 ms |
18208 KB |
Output is correct |
40 |
Correct |
192 ms |
18272 KB |
Output is correct |
41 |
Correct |
175 ms |
18328 KB |
Output is correct |
42 |
Correct |
164 ms |
18188 KB |
Output is correct |
43 |
Correct |
381 ms |
20476 KB |
Output is correct |
44 |
Correct |
350 ms |
20380 KB |
Output is correct |
45 |
Correct |
367 ms |
20464 KB |
Output is correct |
46 |
Correct |
341 ms |
20472 KB |
Output is correct |
47 |
Correct |
450 ms |
20460 KB |
Output is correct |
48 |
Correct |
389 ms |
20472 KB |
Output is correct |
49 |
Correct |
340 ms |
20472 KB |
Output is correct |
50 |
Correct |
382 ms |
20416 KB |
Output is correct |
51 |
Correct |
404 ms |
20464 KB |
Output is correct |
52 |
Correct |
361 ms |
20460 KB |
Output is correct |
53 |
Correct |
383 ms |
20476 KB |
Output is correct |
54 |
Correct |
367 ms |
20500 KB |
Output is correct |
55 |
Correct |
361 ms |
20380 KB |
Output is correct |
56 |
Correct |
367 ms |
20476 KB |
Output is correct |
57 |
Correct |
345 ms |
20448 KB |
Output is correct |
58 |
Correct |
361 ms |
20460 KB |
Output is correct |
59 |
Correct |
362 ms |
20404 KB |
Output is correct |
60 |
Correct |
404 ms |
20456 KB |
Output is correct |
61 |
Correct |
362 ms |
20468 KB |
Output is correct |
62 |
Correct |
401 ms |
20356 KB |
Output is correct |
63 |
Correct |
356 ms |
20472 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
131 ms |
15556 KB |
Output is correct |
2 |
Correct |
124 ms |
16452 KB |
Output is correct |
3 |
Correct |
164 ms |
16460 KB |
Output is correct |
4 |
Correct |
176 ms |
16444 KB |
Output is correct |
5 |
Correct |
123 ms |
16380 KB |
Output is correct |
6 |
Correct |
132 ms |
16484 KB |
Output is correct |
7 |
Correct |
155 ms |
16504 KB |
Output is correct |
8 |
Correct |
128 ms |
16492 KB |
Output is correct |
9 |
Correct |
126 ms |
16436 KB |
Output is correct |
10 |
Correct |
149 ms |
16492 KB |
Output is correct |
11 |
Correct |
130 ms |
16432 KB |
Output is correct |
12 |
Correct |
128 ms |
16372 KB |
Output is correct |
13 |
Correct |
135 ms |
16472 KB |
Output is correct |
14 |
Correct |
172 ms |
16400 KB |
Output is correct |
15 |
Correct |
125 ms |
16524 KB |
Output is correct |
16 |
Correct |
135 ms |
16484 KB |
Output is correct |
17 |
Correct |
134 ms |
16388 KB |
Output is correct |
18 |
Correct |
137 ms |
16448 KB |
Output is correct |
19 |
Correct |
122 ms |
16408 KB |
Output is correct |
20 |
Correct |
133 ms |
16708 KB |
Output is correct |
21 |
Correct |
137 ms |
16484 KB |
Output is correct |
22 |
Correct |
170 ms |
18288 KB |
Output is correct |
23 |
Correct |
167 ms |
18368 KB |
Output is correct |
24 |
Correct |
174 ms |
18184 KB |
Output is correct |
25 |
Correct |
168 ms |
18272 KB |
Output is correct |
26 |
Correct |
162 ms |
18248 KB |
Output is correct |
27 |
Correct |
173 ms |
18280 KB |
Output is correct |
28 |
Correct |
172 ms |
18296 KB |
Output is correct |
29 |
Correct |
157 ms |
18232 KB |
Output is correct |
30 |
Correct |
180 ms |
18252 KB |
Output is correct |
31 |
Correct |
161 ms |
18260 KB |
Output is correct |
32 |
Correct |
157 ms |
18204 KB |
Output is correct |
33 |
Correct |
176 ms |
18268 KB |
Output is correct |
34 |
Correct |
174 ms |
18244 KB |
Output is correct |
35 |
Correct |
156 ms |
18300 KB |
Output is correct |
36 |
Correct |
195 ms |
18248 KB |
Output is correct |
37 |
Correct |
198 ms |
18312 KB |
Output is correct |
38 |
Correct |
155 ms |
18244 KB |
Output is correct |
39 |
Correct |
168 ms |
18208 KB |
Output is correct |
40 |
Correct |
192 ms |
18272 KB |
Output is correct |
41 |
Correct |
175 ms |
18328 KB |
Output is correct |
42 |
Correct |
164 ms |
18188 KB |
Output is correct |
43 |
Correct |
381 ms |
20476 KB |
Output is correct |
44 |
Correct |
350 ms |
20380 KB |
Output is correct |
45 |
Correct |
367 ms |
20464 KB |
Output is correct |
46 |
Correct |
341 ms |
20472 KB |
Output is correct |
47 |
Correct |
450 ms |
20460 KB |
Output is correct |
48 |
Correct |
389 ms |
20472 KB |
Output is correct |
49 |
Correct |
340 ms |
20472 KB |
Output is correct |
50 |
Correct |
382 ms |
20416 KB |
Output is correct |
51 |
Correct |
404 ms |
20464 KB |
Output is correct |
52 |
Correct |
361 ms |
20460 KB |
Output is correct |
53 |
Correct |
383 ms |
20476 KB |
Output is correct |
54 |
Correct |
367 ms |
20500 KB |
Output is correct |
55 |
Correct |
361 ms |
20380 KB |
Output is correct |
56 |
Correct |
367 ms |
20476 KB |
Output is correct |
57 |
Correct |
345 ms |
20448 KB |
Output is correct |
58 |
Correct |
361 ms |
20460 KB |
Output is correct |
59 |
Correct |
362 ms |
20404 KB |
Output is correct |
60 |
Correct |
404 ms |
20456 KB |
Output is correct |
61 |
Correct |
362 ms |
20468 KB |
Output is correct |
62 |
Correct |
401 ms |
20356 KB |
Output is correct |
63 |
Correct |
356 ms |
20472 KB |
Output is correct |
64 |
Execution timed out |
1177 ms |
24140 KB |
Time limit exceeded |
65 |
Halted |
0 ms |
0 KB |
- |