#include <bits/stdc++.h>
#include "trilib.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 = 'f' - 'a' + 1, 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;
for (int i = 0; i < n; ++i) {
string s;
cin >> s;
string ss = s;
reverse(all(ss));
if (ss == s) {
++cnt[s[0] - 'a'][s[0] - 'a'][sz(s)];
} else {
++cnt[s[0] - 'a'][s[sz(s) - 1] - 'a'][sz(s)];
++cnt[s[sz(s) - 1] - 'a'][s[0] - 'a'][sz(s)];
}
}
memset(used, -1, sizeof(used));
for (len = 1; len < L; ++len) {
rec(0, 1);
}
cout << ans;
return 0;
}
Compilation message
cubeword.cpp:2:10: fatal error: trilib.h: No such file or directory
2 | #include "trilib.h"
| ^~~~~~~~~~
compilation terminated.