답안 #948527

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
948527 2024-03-18T07:39:13 Z GrandTiger1729 Cubeword (CEOI19_cubeword) C++17
0 / 100
1100 ms 20052 KB
#pragma GCC optimize("O3")
#pragma GCC target("avx2")
#include <bits/stdc++.h>
using namespace std;

namespace
{
const int N = 11, K = 128, MOD = 998244353;
int cnt[N][K][K]{};
long long res[K][K][K]{};
const string charset = "0123456789qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM";
}
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]]++;
        }
    }
    long long ans = 0;
    for (int t = 3; t < N; t++)
    {
        fill_n(&res[0][0][0], sizeof(res) / sizeof(long long), 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;
                    }
                }
            }
        }
        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;
                    }
                }
            }
        }
    }
    cout << ans << '\n';
    return 0;
}

Compilation message

cubeword.cpp: In function 'int main()':
cubeword.cpp:40:31: warning: array subscript has type 'char' [-Wchar-subscripts]
   40 |             cnt[s.size()][s[0]][ss[0]]++;
      |                               ^
cubeword.cpp:40:38: warning: array subscript has type 'char' [-Wchar-subscripts]
   40 |             cnt[s.size()][s[0]][ss[0]]++;
      |                                      ^
cubeword.cpp:44:31: warning: array subscript has type 'char' [-Wchar-subscripts]
   44 |             cnt[s.size()][s[0]][ss[0]]++;
      |                               ^
cubeword.cpp:44:38: warning: array subscript has type 'char' [-Wchar-subscripts]
   44 |             cnt[s.size()][s[0]][ss[0]]++;
      |                                      ^
cubeword.cpp:45:32: warning: array subscript has type 'char' [-Wchar-subscripts]
   45 |             cnt[s.size()][ss[0]][s[0]]++;
      |                                ^
cubeword.cpp:45:38: warning: array subscript has type 'char' [-Wchar-subscripts]
   45 |             cnt[s.size()][ss[0]][s[0]]++;
      |                                      ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1088 ms 20048 KB Output is correct
2 Correct 1081 ms 20048 KB Output is correct
3 Correct 1097 ms 20052 KB Output is correct
4 Correct 1096 ms 20052 KB Output is correct
5 Correct 1094 ms 20048 KB Output is correct
6 Execution timed out 1105 ms 20052 KB Time limit exceeded
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1088 ms 20048 KB Output is correct
2 Correct 1081 ms 20048 KB Output is correct
3 Correct 1097 ms 20052 KB Output is correct
4 Correct 1096 ms 20052 KB Output is correct
5 Correct 1094 ms 20048 KB Output is correct
6 Execution timed out 1105 ms 20052 KB Time limit exceeded
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1088 ms 20048 KB Output is correct
2 Correct 1081 ms 20048 KB Output is correct
3 Correct 1097 ms 20052 KB Output is correct
4 Correct 1096 ms 20052 KB Output is correct
5 Correct 1094 ms 20048 KB Output is correct
6 Execution timed out 1105 ms 20052 KB Time limit exceeded
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1088 ms 20048 KB Output is correct
2 Correct 1081 ms 20048 KB Output is correct
3 Correct 1097 ms 20052 KB Output is correct
4 Correct 1096 ms 20052 KB Output is correct
5 Correct 1094 ms 20048 KB Output is correct
6 Execution timed out 1105 ms 20052 KB Time limit exceeded
7 Halted 0 ms 0 KB -