답안 #948526

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
948526 2024-03-18T07:36:53 Z GrandTiger1729 Cubeword (CEOI19_cubeword) C++17
0 / 100
1100 ms 21128 KB
#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:38:31: warning: array subscript has type 'char' [-Wchar-subscripts]
   38 |             cnt[s.size()][s[0]][ss[0]]++;
      |                               ^
cubeword.cpp:38:38: warning: array subscript has type 'char' [-Wchar-subscripts]
   38 |             cnt[s.size()][s[0]][ss[0]]++;
      |                                      ^
cubeword.cpp:42:31: warning: array subscript has type 'char' [-Wchar-subscripts]
   42 |             cnt[s.size()][s[0]][ss[0]]++;
      |                               ^
cubeword.cpp:42:38: warning: array subscript has type 'char' [-Wchar-subscripts]
   42 |             cnt[s.size()][s[0]][ss[0]]++;
      |                                      ^
cubeword.cpp:43:32: warning: array subscript has type 'char' [-Wchar-subscripts]
   43 |             cnt[s.size()][ss[0]][s[0]]++;
      |                                ^
cubeword.cpp:43:38: warning: array subscript has type 'char' [-Wchar-subscripts]
   43 |             cnt[s.size()][ss[0]][s[0]]++;
      |                                      ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1079 ms 20308 KB Output is correct
2 Correct 1071 ms 21080 KB Output is correct
3 Correct 1066 ms 21076 KB Output is correct
4 Correct 1086 ms 20992 KB Output is correct
5 Correct 1075 ms 21072 KB Output is correct
6 Correct 1071 ms 21072 KB Output is correct
7 Correct 1082 ms 20860 KB Output is correct
8 Correct 1074 ms 21128 KB Output is correct
9 Correct 1098 ms 21076 KB Output is correct
10 Correct 1078 ms 21076 KB Output is correct
11 Correct 1069 ms 21076 KB Output is correct
12 Correct 1091 ms 21076 KB Output is correct
13 Correct 1069 ms 21072 KB Output is correct
14 Correct 1082 ms 20848 KB Output is correct
15 Correct 1090 ms 20864 KB Output is correct
16 Correct 1078 ms 21088 KB Output is correct
17 Correct 1068 ms 21080 KB Output is correct
18 Correct 1078 ms 21076 KB Output is correct
19 Execution timed out 1104 ms 21072 KB Time limit exceeded
20 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1079 ms 20308 KB Output is correct
2 Correct 1071 ms 21080 KB Output is correct
3 Correct 1066 ms 21076 KB Output is correct
4 Correct 1086 ms 20992 KB Output is correct
5 Correct 1075 ms 21072 KB Output is correct
6 Correct 1071 ms 21072 KB Output is correct
7 Correct 1082 ms 20860 KB Output is correct
8 Correct 1074 ms 21128 KB Output is correct
9 Correct 1098 ms 21076 KB Output is correct
10 Correct 1078 ms 21076 KB Output is correct
11 Correct 1069 ms 21076 KB Output is correct
12 Correct 1091 ms 21076 KB Output is correct
13 Correct 1069 ms 21072 KB Output is correct
14 Correct 1082 ms 20848 KB Output is correct
15 Correct 1090 ms 20864 KB Output is correct
16 Correct 1078 ms 21088 KB Output is correct
17 Correct 1068 ms 21080 KB Output is correct
18 Correct 1078 ms 21076 KB Output is correct
19 Execution timed out 1104 ms 21072 KB Time limit exceeded
20 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1079 ms 20308 KB Output is correct
2 Correct 1071 ms 21080 KB Output is correct
3 Correct 1066 ms 21076 KB Output is correct
4 Correct 1086 ms 20992 KB Output is correct
5 Correct 1075 ms 21072 KB Output is correct
6 Correct 1071 ms 21072 KB Output is correct
7 Correct 1082 ms 20860 KB Output is correct
8 Correct 1074 ms 21128 KB Output is correct
9 Correct 1098 ms 21076 KB Output is correct
10 Correct 1078 ms 21076 KB Output is correct
11 Correct 1069 ms 21076 KB Output is correct
12 Correct 1091 ms 21076 KB Output is correct
13 Correct 1069 ms 21072 KB Output is correct
14 Correct 1082 ms 20848 KB Output is correct
15 Correct 1090 ms 20864 KB Output is correct
16 Correct 1078 ms 21088 KB Output is correct
17 Correct 1068 ms 21080 KB Output is correct
18 Correct 1078 ms 21076 KB Output is correct
19 Execution timed out 1104 ms 21072 KB Time limit exceeded
20 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1079 ms 20308 KB Output is correct
2 Correct 1071 ms 21080 KB Output is correct
3 Correct 1066 ms 21076 KB Output is correct
4 Correct 1086 ms 20992 KB Output is correct
5 Correct 1075 ms 21072 KB Output is correct
6 Correct 1071 ms 21072 KB Output is correct
7 Correct 1082 ms 20860 KB Output is correct
8 Correct 1074 ms 21128 KB Output is correct
9 Correct 1098 ms 21076 KB Output is correct
10 Correct 1078 ms 21076 KB Output is correct
11 Correct 1069 ms 21076 KB Output is correct
12 Correct 1091 ms 21076 KB Output is correct
13 Correct 1069 ms 21072 KB Output is correct
14 Correct 1082 ms 20848 KB Output is correct
15 Correct 1090 ms 20864 KB Output is correct
16 Correct 1078 ms 21088 KB Output is correct
17 Correct 1068 ms 21080 KB Output is correct
18 Correct 1078 ms 21076 KB Output is correct
19 Execution timed out 1104 ms 21072 KB Time limit exceeded
20 Halted 0 ms 0 KB -