답안 #572421

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
572421 2022-06-04T10:52:13 Z piOOE Cubeword (CEOI19_cubeword) C++17
100 / 100
958 ms 11376 KB
#include <bits/stdc++.h>

using namespace std;

#define sz(x) ((int)size(x))
#define all(x) begin(x), end(x)
#define trace(x) cout << #x << ": " << (x) << endl;

typedef long long ll;

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

int rand(int l, int r) { return (int) ((ll) rnd() % (r - l + 1)) + l; }

const int N = 8, A = 62, L = 8, mod = 998244353;
const ll infL = 3e18;

int g[N][3] = {{1, 2, 4},
               {0, 3, 5},
               {0, 3, 6},
               {1, 2, 7},
               {0, 5, 6},
               {1, 4, 7},
               {2, 4, 7},
               {3, 5, 6}};

int n;
int cnt[L][A][A], dp2[A][A][A], dp7[A][A][A], dp1[A][A][A], dp4[A][A][A];
int ans = 0;
int len = 0;

int get(char c) {
    if ('a' <= c && c <= 'z') {
        return c - 'a';
    }
    if ('A' <= c && c <= 'Z') {
        return (c - 'A') + 26;
    }
    return (c - '0') + 52;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n;
    vector<string> stt;
    for (int i = 0; i < n; ++i) {
        string s;
        cin >> s;
        string ss = s;
        reverse(all(ss));
        if (ss != s)
            stt.push_back(ss);
        stt.push_back(s);
    }
    sort(all(stt));
    stt.resize(unique(all(stt)) - begin(stt));
    for (string s: stt) {
        ++cnt[sz(s) - 3][get(s[0])][get(s.back())];
    }
    for (len = 0; len < L; ++len) {
        for (int x0 = 0; x0 < A; ++x0) {
            for (int x3 = 0; x3 < A; ++x3) {
                for (int x6 = 0; x6 < A; ++x6) {
                    ll sum = 0;
                    for (int x = 0; x < A; ++x) {
                        sum += cnt[len][x][x0] * cnt[len][x][x3] * cnt[len][x][x6];
                    }
                    dp2[x0][x3][x6] = dp7[x0][x3][x6] = dp1[x0][x3][x6] = dp4[x0][x3][x6] = sum % mod;
                }
            }
        }
        for (int x0 = 0; x0 < A; ++x0) {
            for (int x3 = 0; x3 < A; ++x3) {
                for (int x5 = 0; x5 < A; ++x5) {
                    for (int x6 = 0; x6 < A; ++x6) {
                        ans = (ans + dp4[x0][x5][x6] * (ll) dp7[x3][x5][x6] % mod * dp1[x0][x3][x5] % mod *
                                     dp2[x0][x3][x6]) % mod;
                    }
                }
            }
        }
    }
    cout << ans;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 872 ms 11280 KB Output is correct
2 Correct 873 ms 11276 KB Output is correct
3 Correct 875 ms 11312 KB Output is correct
4 Correct 906 ms 11300 KB Output is correct
5 Correct 899 ms 11308 KB Output is correct
6 Correct 888 ms 11376 KB Output is correct
7 Correct 922 ms 11308 KB Output is correct
8 Correct 895 ms 11308 KB Output is correct
9 Correct 906 ms 11308 KB Output is correct
10 Correct 903 ms 11304 KB Output is correct
11 Correct 890 ms 11284 KB Output is correct
12 Correct 882 ms 11228 KB Output is correct
13 Correct 888 ms 11268 KB Output is correct
14 Correct 860 ms 11284 KB Output is correct
15 Correct 880 ms 11280 KB Output is correct
16 Correct 908 ms 11276 KB Output is correct
17 Correct 891 ms 11204 KB Output is correct
18 Correct 907 ms 11308 KB Output is correct
19 Correct 873 ms 11288 KB Output is correct
20 Correct 856 ms 11280 KB Output is correct
21 Correct 863 ms 11288 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 872 ms 11280 KB Output is correct
2 Correct 873 ms 11276 KB Output is correct
3 Correct 875 ms 11312 KB Output is correct
4 Correct 906 ms 11300 KB Output is correct
5 Correct 899 ms 11308 KB Output is correct
6 Correct 888 ms 11376 KB Output is correct
7 Correct 922 ms 11308 KB Output is correct
8 Correct 895 ms 11308 KB Output is correct
9 Correct 906 ms 11308 KB Output is correct
10 Correct 903 ms 11304 KB Output is correct
11 Correct 890 ms 11284 KB Output is correct
12 Correct 882 ms 11228 KB Output is correct
13 Correct 888 ms 11268 KB Output is correct
14 Correct 860 ms 11284 KB Output is correct
15 Correct 880 ms 11280 KB Output is correct
16 Correct 908 ms 11276 KB Output is correct
17 Correct 891 ms 11204 KB Output is correct
18 Correct 907 ms 11308 KB Output is correct
19 Correct 873 ms 11288 KB Output is correct
20 Correct 856 ms 11280 KB Output is correct
21 Correct 863 ms 11288 KB Output is correct
22 Correct 844 ms 11260 KB Output is correct
23 Correct 903 ms 11280 KB Output is correct
24 Correct 845 ms 11196 KB Output is correct
25 Correct 872 ms 11196 KB Output is correct
26 Correct 848 ms 11192 KB Output is correct
27 Correct 839 ms 11284 KB Output is correct
28 Correct 842 ms 11180 KB Output is correct
29 Correct 849 ms 11180 KB Output is correct
30 Correct 837 ms 11264 KB Output is correct
31 Correct 845 ms 11308 KB Output is correct
32 Correct 847 ms 11256 KB Output is correct
33 Correct 863 ms 11172 KB Output is correct
34 Correct 880 ms 11204 KB Output is correct
35 Correct 840 ms 11196 KB Output is correct
36 Correct 841 ms 11292 KB Output is correct
37 Correct 843 ms 11196 KB Output is correct
38 Correct 842 ms 11172 KB Output is correct
39 Correct 844 ms 11192 KB Output is correct
40 Correct 843 ms 11240 KB Output is correct
41 Correct 841 ms 11180 KB Output is correct
42 Correct 841 ms 11200 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 872 ms 11280 KB Output is correct
2 Correct 873 ms 11276 KB Output is correct
3 Correct 875 ms 11312 KB Output is correct
4 Correct 906 ms 11300 KB Output is correct
5 Correct 899 ms 11308 KB Output is correct
6 Correct 888 ms 11376 KB Output is correct
7 Correct 922 ms 11308 KB Output is correct
8 Correct 895 ms 11308 KB Output is correct
9 Correct 906 ms 11308 KB Output is correct
10 Correct 903 ms 11304 KB Output is correct
11 Correct 890 ms 11284 KB Output is correct
12 Correct 882 ms 11228 KB Output is correct
13 Correct 888 ms 11268 KB Output is correct
14 Correct 860 ms 11284 KB Output is correct
15 Correct 880 ms 11280 KB Output is correct
16 Correct 908 ms 11276 KB Output is correct
17 Correct 891 ms 11204 KB Output is correct
18 Correct 907 ms 11308 KB Output is correct
19 Correct 873 ms 11288 KB Output is correct
20 Correct 856 ms 11280 KB Output is correct
21 Correct 863 ms 11288 KB Output is correct
22 Correct 844 ms 11260 KB Output is correct
23 Correct 903 ms 11280 KB Output is correct
24 Correct 845 ms 11196 KB Output is correct
25 Correct 872 ms 11196 KB Output is correct
26 Correct 848 ms 11192 KB Output is correct
27 Correct 839 ms 11284 KB Output is correct
28 Correct 842 ms 11180 KB Output is correct
29 Correct 849 ms 11180 KB Output is correct
30 Correct 837 ms 11264 KB Output is correct
31 Correct 845 ms 11308 KB Output is correct
32 Correct 847 ms 11256 KB Output is correct
33 Correct 863 ms 11172 KB Output is correct
34 Correct 880 ms 11204 KB Output is correct
35 Correct 840 ms 11196 KB Output is correct
36 Correct 841 ms 11292 KB Output is correct
37 Correct 843 ms 11196 KB Output is correct
38 Correct 842 ms 11172 KB Output is correct
39 Correct 844 ms 11192 KB Output is correct
40 Correct 843 ms 11240 KB Output is correct
41 Correct 841 ms 11180 KB Output is correct
42 Correct 841 ms 11200 KB Output is correct
43 Correct 828 ms 11180 KB Output is correct
44 Correct 826 ms 11176 KB Output is correct
45 Correct 818 ms 11172 KB Output is correct
46 Correct 820 ms 11168 KB Output is correct
47 Correct 826 ms 11240 KB Output is correct
48 Correct 853 ms 11172 KB Output is correct
49 Correct 821 ms 11188 KB Output is correct
50 Correct 958 ms 11164 KB Output is correct
51 Correct 854 ms 11184 KB Output is correct
52 Correct 838 ms 11184 KB Output is correct
53 Correct 833 ms 11176 KB Output is correct
54 Correct 825 ms 11164 KB Output is correct
55 Correct 836 ms 11168 KB Output is correct
56 Correct 845 ms 11176 KB Output is correct
57 Correct 826 ms 11160 KB Output is correct
58 Correct 827 ms 11168 KB Output is correct
59 Correct 836 ms 11164 KB Output is correct
60 Correct 821 ms 11164 KB Output is correct
61 Correct 864 ms 11176 KB Output is correct
62 Correct 830 ms 11164 KB Output is correct
63 Correct 829 ms 11184 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 872 ms 11280 KB Output is correct
2 Correct 873 ms 11276 KB Output is correct
3 Correct 875 ms 11312 KB Output is correct
4 Correct 906 ms 11300 KB Output is correct
5 Correct 899 ms 11308 KB Output is correct
6 Correct 888 ms 11376 KB Output is correct
7 Correct 922 ms 11308 KB Output is correct
8 Correct 895 ms 11308 KB Output is correct
9 Correct 906 ms 11308 KB Output is correct
10 Correct 903 ms 11304 KB Output is correct
11 Correct 890 ms 11284 KB Output is correct
12 Correct 882 ms 11228 KB Output is correct
13 Correct 888 ms 11268 KB Output is correct
14 Correct 860 ms 11284 KB Output is correct
15 Correct 880 ms 11280 KB Output is correct
16 Correct 908 ms 11276 KB Output is correct
17 Correct 891 ms 11204 KB Output is correct
18 Correct 907 ms 11308 KB Output is correct
19 Correct 873 ms 11288 KB Output is correct
20 Correct 856 ms 11280 KB Output is correct
21 Correct 863 ms 11288 KB Output is correct
22 Correct 844 ms 11260 KB Output is correct
23 Correct 903 ms 11280 KB Output is correct
24 Correct 845 ms 11196 KB Output is correct
25 Correct 872 ms 11196 KB Output is correct
26 Correct 848 ms 11192 KB Output is correct
27 Correct 839 ms 11284 KB Output is correct
28 Correct 842 ms 11180 KB Output is correct
29 Correct 849 ms 11180 KB Output is correct
30 Correct 837 ms 11264 KB Output is correct
31 Correct 845 ms 11308 KB Output is correct
32 Correct 847 ms 11256 KB Output is correct
33 Correct 863 ms 11172 KB Output is correct
34 Correct 880 ms 11204 KB Output is correct
35 Correct 840 ms 11196 KB Output is correct
36 Correct 841 ms 11292 KB Output is correct
37 Correct 843 ms 11196 KB Output is correct
38 Correct 842 ms 11172 KB Output is correct
39 Correct 844 ms 11192 KB Output is correct
40 Correct 843 ms 11240 KB Output is correct
41 Correct 841 ms 11180 KB Output is correct
42 Correct 841 ms 11200 KB Output is correct
43 Correct 828 ms 11180 KB Output is correct
44 Correct 826 ms 11176 KB Output is correct
45 Correct 818 ms 11172 KB Output is correct
46 Correct 820 ms 11168 KB Output is correct
47 Correct 826 ms 11240 KB Output is correct
48 Correct 853 ms 11172 KB Output is correct
49 Correct 821 ms 11188 KB Output is correct
50 Correct 958 ms 11164 KB Output is correct
51 Correct 854 ms 11184 KB Output is correct
52 Correct 838 ms 11184 KB Output is correct
53 Correct 833 ms 11176 KB Output is correct
54 Correct 825 ms 11164 KB Output is correct
55 Correct 836 ms 11168 KB Output is correct
56 Correct 845 ms 11176 KB Output is correct
57 Correct 826 ms 11160 KB Output is correct
58 Correct 827 ms 11168 KB Output is correct
59 Correct 836 ms 11164 KB Output is correct
60 Correct 821 ms 11164 KB Output is correct
61 Correct 864 ms 11176 KB Output is correct
62 Correct 830 ms 11164 KB Output is correct
63 Correct 829 ms 11184 KB Output is correct
64 Correct 833 ms 11292 KB Output is correct
65 Correct 843 ms 11216 KB Output is correct
66 Correct 832 ms 11244 KB Output is correct
67 Correct 825 ms 11300 KB Output is correct
68 Correct 842 ms 11296 KB Output is correct
69 Correct 828 ms 11300 KB Output is correct
70 Correct 877 ms 11180 KB Output is correct
71 Correct 892 ms 11308 KB Output is correct
72 Correct 867 ms 11180 KB Output is correct
73 Correct 851 ms 11300 KB Output is correct
74 Correct 849 ms 11296 KB Output is correct
75 Correct 876 ms 11288 KB Output is correct
76 Correct 866 ms 11300 KB Output is correct
77 Correct 857 ms 11300 KB Output is correct
78 Correct 846 ms 11296 KB Output is correct
79 Correct 830 ms 11252 KB Output is correct
80 Correct 880 ms 11176 KB Output is correct
81 Correct 930 ms 11176 KB Output is correct
82 Correct 840 ms 11292 KB Output is correct
83 Correct 814 ms 11296 KB Output is correct
84 Correct 835 ms 11176 KB Output is correct