답안 #948531

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
948531 2024-03-18T07:42:42 Z GrandTiger1729 Cubeword (CEOI19_cubeword) C++17
0 / 100
1100 ms 11868 KB
#include <bits/stdc++.h>
using namespace std;

namespace
{
const int N = 11, K = 128, MOD = 998244353;
int cnt[N][K][K]{}, res[K][K][K]{};
const string charset = "0123456789qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM";
inline void addmod(int &x, int y)
{
    x += y;
    if (x > MOD)
    {
        x -= MOD;
    }
}
}
int main()
{
    cin.tie(0)->sync_with_stdio(0);
    int n;
    cin >> n;
    vector<string> a(n);
    for (int i = 0; i < n; i++)
    {
        string s;
        cin >> s;
        string ss = s;
        reverse(ss.begin(), ss.end());
        if (ss < s)
        {
            swap(s, ss);
        }
        a[i] = s;
    }
    sort(a.begin(), a.end());
    a.resize(unique(a.begin(), a.end()) - a.begin());
    n = a.size();
    for (int i = 0; i < n; i++)
    {
        string s = a[i], ss = s;
        reverse(ss.begin(), ss.end());
        if (s == ss)
        {
            cnt[s.size()][s[0]][ss[0]]++;
        }
        else
        {
            cnt[s.size()][s[0]][ss[0]]++;
            cnt[s.size()][ss[0]][s[0]]++;
        }
    }
    int ans = 0;
    for (int t = 3; t < N; t++)
    {
        fill_n(&res[0][0][0], sizeof(res) / sizeof(int), 0);
        for (int i : charset)
        {
            for (int j : charset)
            {
                for (int k : charset)
                {
                    for (int l : charset)
                    {
                        // (res[i][j][k] += 1ll * cnt[t][i][l] * cnt[t][j][l] * cnt[t][k][l]) %= MOD;
                        addmod(res[i][j][k], 1ll * cnt[t][i][l] * cnt[t][j][l] * cnt[t][k][l] % MOD);
                    }
                }
            }
        }
        for (int i : charset)
        {
            for (int j : charset)
            {
                for (int k : charset)
                {
                    for (int l : charset)
                    {
                        // (ans += res[i][j][k] * res[i][j][l] % MOD * res[i][k][l] % MOD * res[j][k][l]) %= MOD;
                        addmod(ans, (__int128_t)1 * res[i][j][k] * res[i][j][l] * res[i][k][l] * res[j][k][l] % MOD);
                    }
                }
            }
        }
    }
    cout << ans << '\n';
    return 0;
}

Compilation message

cubeword.cpp: In function 'int main()':
cubeword.cpp:45:31: warning: array subscript has type 'char' [-Wchar-subscripts]
   45 |             cnt[s.size()][s[0]][ss[0]]++;
      |                               ^
cubeword.cpp:45:38: warning: array subscript has type 'char' [-Wchar-subscripts]
   45 |             cnt[s.size()][s[0]][ss[0]]++;
      |                                      ^
cubeword.cpp:49:31: warning: array subscript has type 'char' [-Wchar-subscripts]
   49 |             cnt[s.size()][s[0]][ss[0]]++;
      |                               ^
cubeword.cpp:49:38: warning: array subscript has type 'char' [-Wchar-subscripts]
   49 |             cnt[s.size()][s[0]][ss[0]]++;
      |                                      ^
cubeword.cpp:50:32: warning: array subscript has type 'char' [-Wchar-subscripts]
   50 |             cnt[s.size()][ss[0]][s[0]]++;
      |                                ^
cubeword.cpp:50:38: warning: array subscript has type 'char' [-Wchar-subscripts]
   50 |             cnt[s.size()][ss[0]][s[0]]++;
      |                                      ^
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1137 ms 11868 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1137 ms 11868 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1137 ms 11868 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1137 ms 11868 KB Time limit exceeded
2 Halted 0 ms 0 KB -