# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
572327 |
2022-06-04T09:13:26 Z |
piOOE |
Cubeword (CEOI19_cubeword) |
C++17 |
|
1100 ms |
16200 KB |
#include <bits/stdc++.h>
using namespace std;
#define sz(x) ((int)size(x))
#define all(x) begin(x), end(x)
#define trace(x) cout << #x << ": " << (x) << endl;
typedef long long ll;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
int rand(int l, int r) { return (int) ((ll) rnd() % (r - l + 1)) + l; }
const int N = 8, A = 26, L = 11, mod = 998244353;
const ll infL = 3e18;
int g[N][3] = {{1, 2, 4},
{0, 3, 5},
{0, 3, 6},
{1, 2, 7},
{0, 5, 6},
{1, 4, 7},
{2, 4, 7},
{3, 5, 6}};
int n;
int cnt[A][A][L], used[N];
int ans = 0, len = 0;
void rec(int i, int val) {
if (val == 0) {
return;
}
if (i == N) {
ans = (ans + val) % mod;
return;
}
for (int x = 0; x < A; ++x) {
used[i] = x;
int nw = val;
for (int to: g[i]) {
if (used[to] == -1) continue;
nw = (nw * (ll) cnt[used[i]][used[to]][len]) % mod;
}
rec(i + 1, nw);
}
used[i] = -1;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n;
set<string> stt;
for (int i = 0; i < n; ++i) {
string s;
cin >> s;
string ss = s;
reverse(all(ss));
stt.insert(ss);
stt.insert(s);
}
for (string s: stt) {
++cnt[s[0] - 'a'][s.back() - 'a'][sz(s)];
}
memset(used, -1, sizeof(used));
for (len = 1; len < L; ++len) {
rec(0, 1);
}
cout << ans;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
878 ms |
14816 KB |
Output is correct |
2 |
Correct |
862 ms |
15660 KB |
Output is correct |
3 |
Correct |
879 ms |
15672 KB |
Output is correct |
4 |
Correct |
873 ms |
15648 KB |
Output is correct |
5 |
Correct |
875 ms |
15668 KB |
Output is correct |
6 |
Correct |
863 ms |
15560 KB |
Output is correct |
7 |
Correct |
863 ms |
15680 KB |
Output is correct |
8 |
Correct |
874 ms |
15692 KB |
Output is correct |
9 |
Correct |
866 ms |
15560 KB |
Output is correct |
10 |
Correct |
860 ms |
15676 KB |
Output is correct |
11 |
Correct |
879 ms |
15644 KB |
Output is correct |
12 |
Correct |
866 ms |
15656 KB |
Output is correct |
13 |
Correct |
870 ms |
15680 KB |
Output is correct |
14 |
Correct |
868 ms |
15664 KB |
Output is correct |
15 |
Correct |
866 ms |
15704 KB |
Output is correct |
16 |
Correct |
870 ms |
15660 KB |
Output is correct |
17 |
Correct |
876 ms |
15672 KB |
Output is correct |
18 |
Correct |
868 ms |
15656 KB |
Output is correct |
19 |
Correct |
869 ms |
15648 KB |
Output is correct |
20 |
Correct |
862 ms |
15692 KB |
Output is correct |
21 |
Correct |
854 ms |
15692 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
878 ms |
14816 KB |
Output is correct |
2 |
Correct |
862 ms |
15660 KB |
Output is correct |
3 |
Correct |
879 ms |
15672 KB |
Output is correct |
4 |
Correct |
873 ms |
15648 KB |
Output is correct |
5 |
Correct |
875 ms |
15668 KB |
Output is correct |
6 |
Correct |
863 ms |
15560 KB |
Output is correct |
7 |
Correct |
863 ms |
15680 KB |
Output is correct |
8 |
Correct |
874 ms |
15692 KB |
Output is correct |
9 |
Correct |
866 ms |
15560 KB |
Output is correct |
10 |
Correct |
860 ms |
15676 KB |
Output is correct |
11 |
Correct |
879 ms |
15644 KB |
Output is correct |
12 |
Correct |
866 ms |
15656 KB |
Output is correct |
13 |
Correct |
870 ms |
15680 KB |
Output is correct |
14 |
Correct |
868 ms |
15664 KB |
Output is correct |
15 |
Correct |
866 ms |
15704 KB |
Output is correct |
16 |
Correct |
870 ms |
15660 KB |
Output is correct |
17 |
Correct |
876 ms |
15672 KB |
Output is correct |
18 |
Correct |
868 ms |
15656 KB |
Output is correct |
19 |
Correct |
869 ms |
15648 KB |
Output is correct |
20 |
Correct |
862 ms |
15692 KB |
Output is correct |
21 |
Correct |
854 ms |
15692 KB |
Output is correct |
22 |
Execution timed out |
1168 ms |
16200 KB |
Time limit exceeded |
23 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
878 ms |
14816 KB |
Output is correct |
2 |
Correct |
862 ms |
15660 KB |
Output is correct |
3 |
Correct |
879 ms |
15672 KB |
Output is correct |
4 |
Correct |
873 ms |
15648 KB |
Output is correct |
5 |
Correct |
875 ms |
15668 KB |
Output is correct |
6 |
Correct |
863 ms |
15560 KB |
Output is correct |
7 |
Correct |
863 ms |
15680 KB |
Output is correct |
8 |
Correct |
874 ms |
15692 KB |
Output is correct |
9 |
Correct |
866 ms |
15560 KB |
Output is correct |
10 |
Correct |
860 ms |
15676 KB |
Output is correct |
11 |
Correct |
879 ms |
15644 KB |
Output is correct |
12 |
Correct |
866 ms |
15656 KB |
Output is correct |
13 |
Correct |
870 ms |
15680 KB |
Output is correct |
14 |
Correct |
868 ms |
15664 KB |
Output is correct |
15 |
Correct |
866 ms |
15704 KB |
Output is correct |
16 |
Correct |
870 ms |
15660 KB |
Output is correct |
17 |
Correct |
876 ms |
15672 KB |
Output is correct |
18 |
Correct |
868 ms |
15656 KB |
Output is correct |
19 |
Correct |
869 ms |
15648 KB |
Output is correct |
20 |
Correct |
862 ms |
15692 KB |
Output is correct |
21 |
Correct |
854 ms |
15692 KB |
Output is correct |
22 |
Execution timed out |
1168 ms |
16200 KB |
Time limit exceeded |
23 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
878 ms |
14816 KB |
Output is correct |
2 |
Correct |
862 ms |
15660 KB |
Output is correct |
3 |
Correct |
879 ms |
15672 KB |
Output is correct |
4 |
Correct |
873 ms |
15648 KB |
Output is correct |
5 |
Correct |
875 ms |
15668 KB |
Output is correct |
6 |
Correct |
863 ms |
15560 KB |
Output is correct |
7 |
Correct |
863 ms |
15680 KB |
Output is correct |
8 |
Correct |
874 ms |
15692 KB |
Output is correct |
9 |
Correct |
866 ms |
15560 KB |
Output is correct |
10 |
Correct |
860 ms |
15676 KB |
Output is correct |
11 |
Correct |
879 ms |
15644 KB |
Output is correct |
12 |
Correct |
866 ms |
15656 KB |
Output is correct |
13 |
Correct |
870 ms |
15680 KB |
Output is correct |
14 |
Correct |
868 ms |
15664 KB |
Output is correct |
15 |
Correct |
866 ms |
15704 KB |
Output is correct |
16 |
Correct |
870 ms |
15660 KB |
Output is correct |
17 |
Correct |
876 ms |
15672 KB |
Output is correct |
18 |
Correct |
868 ms |
15656 KB |
Output is correct |
19 |
Correct |
869 ms |
15648 KB |
Output is correct |
20 |
Correct |
862 ms |
15692 KB |
Output is correct |
21 |
Correct |
854 ms |
15692 KB |
Output is correct |
22 |
Execution timed out |
1168 ms |
16200 KB |
Time limit exceeded |
23 |
Halted |
0 ms |
0 KB |
- |