Submission #446273

# Submission time Handle Problem Language Result Execution time Memory
446273 2021-07-21T12:08:12 Z benedict0724 Cubeword (CEOI19_cubeword) C++17
0 / 100
378 ms 268 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

ll cnt[6][6][11];
ll ans = 0;
const ll mod = 998244353;
vector<int> k[8];
vector<int> V;

void solve(int dep, int t, ll now)
{
    if(dep == 8)
    {
        ans = (ans + now)%mod;
        return;
    }
    else
    {
        for(int i=0;i<6;i++)
        {
            V.push_back(i);
            ll tmp = now;
            for(int j : k[dep])
            {
                tmp *= cnt[i][V[j]][t];
                tmp %= mod;
            }
            solve(dep+1, t, tmp);
            V.pop_back();
        }
    }
}

int main()
{
    int n; cin >> n;
    for(int i=1;i<=n;i++)
    {
        string s; cin >> s;
        int t = s.size();
        int a = s[0] - 'a';
        int b = s[t-1] - 'a';
        bool flag = true;
        for(int i=0;i<t;i++)
        {
            if(s[i] != s[t-i-1]) flag = false;
        }

        if(a != b) { cnt[a][b][t]++; cnt[b][a][t]++; }
        else if(flag) cnt[a][a][t]++;
        else cnt[a][a][t] += 2;
    }

    k[1].push_back(0);
    k[2].push_back(0);
    k[3].push_back(1); k[3].push_back(2);
    k[4].push_back(0);
    k[5].push_back(1); k[5].push_back(4);
    k[6].push_back(2); k[6].push_back(4);
    k[7].push_back(3); k[7].push_back(5); k[7].push_back(6);

    for(int t=3;t<=10;t++)
    {
        solve(0, t, 1);
    }

    cout << ans;
}
# Verdict Execution time Memory Grader output
1 Incorrect 378 ms 268 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 378 ms 268 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 378 ms 268 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 378 ms 268 KB Output isn't correct
2 Halted 0 ms 0 KB -