제출 #533176

#제출 시각아이디문제언어결과실행 시간메모리
533176wenqiCubeword (CEOI19_cubeword)C++17
0 / 100
1145 ms25068 KiB
// 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());
}

int mul(int x, int y)
{
    return ((ll) x * y) % MOD;
}

template <typename ...Args>
int mul(int x, int 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++)
            {
                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++)
                {
                    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;
}

컴파일 시 표준 에러 (stderr) 메시지

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...