답안 #960811

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
960811 2024-04-11T04:40:39 Z ALTAKEXE Cubeword (CEOI19_cubeword) C++17
100 / 100
1051 ms 9040 KB
#include <bits/stdc++.h>
 
using namespace std;
 
const int MAX_ID = 62;
const int MIN_LEN = 3;
const int MAX_LEN = 10;
const int MOD = 998244353;
vector<string> s[MAX_LEN + 1];
unordered_map<char, int> id;
int m;
int coef[MAX_ID][MAX_ID], prod[MAX_ID][MAX_ID][MAX_ID];
 
int solve() {
    int ans = 0;
 
    for ( int a = 0; a < m; a++ ) {
        for ( int b = 0; b < m; b++ ) {
            for ( int c = 0; c < m; c++ ) {
                prod[a][b][c] = 0;
                for ( int i = 0; i < m; i++ )
                    prod[a][b][c] = (prod[a][b][c] + (long long)coef[a][i] * coef[b][i] % MOD * coef[c][i]) % MOD;
            }
        }
    }
 
 
    for ( int a = 0; a < m; a++ ) {
        for ( int b = 0; b < m; b++ ) {
            for ( int c = 0; c < m; c++ ) {
                for ( int d = 0; d < m; d++ )
                    ans = (ans + prod[a][b][c] * (long long)prod[a][b][d] % MOD * prod[a][c][d] % MOD * prod[b][c][d]) % MOD;
            }
        }
    }
 
    return ans;
}
 
int main() {
    cin.tie( NULL );
    ios_base::sync_with_stdio( false );
 
    int n;
 
    cin >> n;
    for ( int i = 0; i < n; i++ ) {
        string t;
        cin >> t;
        s[t.size()].push_back( t );
        string w = t;
        reverse( w.begin(), w.end() );
        if ( w != t )
            s[t.size()].push_back( w );
        for ( int i = 0; i < t.size(); i++ )
            id[t[i]] = 1;
    }
 
    m = 0;
    for ( auto p: id )
        id[p.first] = m++;
 
    int ans = 0;
    for ( int l = MIN_LEN; l <= MAX_LEN; l++ ) {
        if ( s[l].size() == 0 )
            continue;
 
        for ( int i = 0; i < m; i++ ) {
            for ( int j = 0; j < m; j++ )
                coef[i][j] = 0;
        }
        sort( s[l].begin(), s[l].end() );
        for ( int i = 0; i < s[l].size(); i++ ) {
            if ( i == 0 || s[l][i] != s[l][i - 1])
                coef[id[s[l][i][0]]][id[s[l][i].back()]]++;
        }
 
        ans = (ans + solve()) % MOD;
    }
 
    cout << ans;
 
    return 0;
}

Compilation message

cubeword.cpp: In function 'int main()':
cubeword.cpp:55:28: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |         for ( int i = 0; i < t.size(); i++ )
      |                          ~~^~~~~~~~~~
cubeword.cpp:73:28: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::__cxx11::basic_string<char> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   73 |         for ( int i = 0; i < s[l].size(); i++ ) {
      |                          ~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 55 ms 7424 KB Output is correct
2 Correct 47 ms 8124 KB Output is correct
3 Correct 47 ms 8228 KB Output is correct
4 Correct 48 ms 8260 KB Output is correct
5 Correct 48 ms 8360 KB Output is correct
6 Correct 54 ms 8340 KB Output is correct
7 Correct 47 ms 8200 KB Output is correct
8 Correct 47 ms 8376 KB Output is correct
9 Correct 53 ms 8160 KB Output is correct
10 Correct 47 ms 8236 KB Output is correct
11 Correct 49 ms 8336 KB Output is correct
12 Correct 47 ms 8124 KB Output is correct
13 Correct 49 ms 8120 KB Output is correct
14 Correct 47 ms 7984 KB Output is correct
15 Correct 46 ms 8076 KB Output is correct
16 Correct 47 ms 8116 KB Output is correct
17 Correct 55 ms 8184 KB Output is correct
18 Correct 46 ms 8092 KB Output is correct
19 Correct 47 ms 8180 KB Output is correct
20 Correct 54 ms 8180 KB Output is correct
21 Correct 48 ms 8104 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 55 ms 7424 KB Output is correct
2 Correct 47 ms 8124 KB Output is correct
3 Correct 47 ms 8228 KB Output is correct
4 Correct 48 ms 8260 KB Output is correct
5 Correct 48 ms 8360 KB Output is correct
6 Correct 54 ms 8340 KB Output is correct
7 Correct 47 ms 8200 KB Output is correct
8 Correct 47 ms 8376 KB Output is correct
9 Correct 53 ms 8160 KB Output is correct
10 Correct 47 ms 8236 KB Output is correct
11 Correct 49 ms 8336 KB Output is correct
12 Correct 47 ms 8124 KB Output is correct
13 Correct 49 ms 8120 KB Output is correct
14 Correct 47 ms 7984 KB Output is correct
15 Correct 46 ms 8076 KB Output is correct
16 Correct 47 ms 8116 KB Output is correct
17 Correct 55 ms 8184 KB Output is correct
18 Correct 46 ms 8092 KB Output is correct
19 Correct 47 ms 8180 KB Output is correct
20 Correct 54 ms 8180 KB Output is correct
21 Correct 48 ms 8104 KB Output is correct
22 Correct 52 ms 7644 KB Output is correct
23 Correct 52 ms 7780 KB Output is correct
24 Correct 54 ms 7772 KB Output is correct
25 Correct 50 ms 7828 KB Output is correct
26 Correct 49 ms 7840 KB Output is correct
27 Correct 50 ms 7964 KB Output is correct
28 Correct 57 ms 7788 KB Output is correct
29 Correct 49 ms 7612 KB Output is correct
30 Correct 51 ms 7560 KB Output is correct
31 Correct 49 ms 7788 KB Output is correct
32 Correct 50 ms 7708 KB Output is correct
33 Correct 50 ms 7768 KB Output is correct
34 Correct 50 ms 7844 KB Output is correct
35 Correct 50 ms 7632 KB Output is correct
36 Correct 50 ms 7856 KB Output is correct
37 Correct 54 ms 7788 KB Output is correct
38 Correct 49 ms 7688 KB Output is correct
39 Correct 50 ms 7916 KB Output is correct
40 Correct 51 ms 7792 KB Output is correct
41 Correct 49 ms 7956 KB Output is correct
42 Correct 49 ms 7768 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 55 ms 7424 KB Output is correct
2 Correct 47 ms 8124 KB Output is correct
3 Correct 47 ms 8228 KB Output is correct
4 Correct 48 ms 8260 KB Output is correct
5 Correct 48 ms 8360 KB Output is correct
6 Correct 54 ms 8340 KB Output is correct
7 Correct 47 ms 8200 KB Output is correct
8 Correct 47 ms 8376 KB Output is correct
9 Correct 53 ms 8160 KB Output is correct
10 Correct 47 ms 8236 KB Output is correct
11 Correct 49 ms 8336 KB Output is correct
12 Correct 47 ms 8124 KB Output is correct
13 Correct 49 ms 8120 KB Output is correct
14 Correct 47 ms 7984 KB Output is correct
15 Correct 46 ms 8076 KB Output is correct
16 Correct 47 ms 8116 KB Output is correct
17 Correct 55 ms 8184 KB Output is correct
18 Correct 46 ms 8092 KB Output is correct
19 Correct 47 ms 8180 KB Output is correct
20 Correct 54 ms 8180 KB Output is correct
21 Correct 48 ms 8104 KB Output is correct
22 Correct 52 ms 7644 KB Output is correct
23 Correct 52 ms 7780 KB Output is correct
24 Correct 54 ms 7772 KB Output is correct
25 Correct 50 ms 7828 KB Output is correct
26 Correct 49 ms 7840 KB Output is correct
27 Correct 50 ms 7964 KB Output is correct
28 Correct 57 ms 7788 KB Output is correct
29 Correct 49 ms 7612 KB Output is correct
30 Correct 51 ms 7560 KB Output is correct
31 Correct 49 ms 7788 KB Output is correct
32 Correct 50 ms 7708 KB Output is correct
33 Correct 50 ms 7768 KB Output is correct
34 Correct 50 ms 7844 KB Output is correct
35 Correct 50 ms 7632 KB Output is correct
36 Correct 50 ms 7856 KB Output is correct
37 Correct 54 ms 7788 KB Output is correct
38 Correct 49 ms 7688 KB Output is correct
39 Correct 50 ms 7916 KB Output is correct
40 Correct 51 ms 7792 KB Output is correct
41 Correct 49 ms 7956 KB Output is correct
42 Correct 49 ms 7768 KB Output is correct
43 Correct 116 ms 8008 KB Output is correct
44 Correct 124 ms 8016 KB Output is correct
45 Correct 115 ms 7860 KB Output is correct
46 Correct 116 ms 8012 KB Output is correct
47 Correct 114 ms 7900 KB Output is correct
48 Correct 115 ms 8280 KB Output is correct
49 Correct 119 ms 7860 KB Output is correct
50 Correct 114 ms 8352 KB Output is correct
51 Correct 114 ms 8104 KB Output is correct
52 Correct 114 ms 8000 KB Output is correct
53 Correct 117 ms 7820 KB Output is correct
54 Correct 121 ms 8076 KB Output is correct
55 Correct 118 ms 7944 KB Output is correct
56 Correct 114 ms 8012 KB Output is correct
57 Correct 115 ms 8076 KB Output is correct
58 Correct 115 ms 8396 KB Output is correct
59 Correct 115 ms 8140 KB Output is correct
60 Correct 117 ms 8252 KB Output is correct
61 Correct 115 ms 8012 KB Output is correct
62 Correct 114 ms 8156 KB Output is correct
63 Correct 120 ms 8356 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 55 ms 7424 KB Output is correct
2 Correct 47 ms 8124 KB Output is correct
3 Correct 47 ms 8228 KB Output is correct
4 Correct 48 ms 8260 KB Output is correct
5 Correct 48 ms 8360 KB Output is correct
6 Correct 54 ms 8340 KB Output is correct
7 Correct 47 ms 8200 KB Output is correct
8 Correct 47 ms 8376 KB Output is correct
9 Correct 53 ms 8160 KB Output is correct
10 Correct 47 ms 8236 KB Output is correct
11 Correct 49 ms 8336 KB Output is correct
12 Correct 47 ms 8124 KB Output is correct
13 Correct 49 ms 8120 KB Output is correct
14 Correct 47 ms 7984 KB Output is correct
15 Correct 46 ms 8076 KB Output is correct
16 Correct 47 ms 8116 KB Output is correct
17 Correct 55 ms 8184 KB Output is correct
18 Correct 46 ms 8092 KB Output is correct
19 Correct 47 ms 8180 KB Output is correct
20 Correct 54 ms 8180 KB Output is correct
21 Correct 48 ms 8104 KB Output is correct
22 Correct 52 ms 7644 KB Output is correct
23 Correct 52 ms 7780 KB Output is correct
24 Correct 54 ms 7772 KB Output is correct
25 Correct 50 ms 7828 KB Output is correct
26 Correct 49 ms 7840 KB Output is correct
27 Correct 50 ms 7964 KB Output is correct
28 Correct 57 ms 7788 KB Output is correct
29 Correct 49 ms 7612 KB Output is correct
30 Correct 51 ms 7560 KB Output is correct
31 Correct 49 ms 7788 KB Output is correct
32 Correct 50 ms 7708 KB Output is correct
33 Correct 50 ms 7768 KB Output is correct
34 Correct 50 ms 7844 KB Output is correct
35 Correct 50 ms 7632 KB Output is correct
36 Correct 50 ms 7856 KB Output is correct
37 Correct 54 ms 7788 KB Output is correct
38 Correct 49 ms 7688 KB Output is correct
39 Correct 50 ms 7916 KB Output is correct
40 Correct 51 ms 7792 KB Output is correct
41 Correct 49 ms 7956 KB Output is correct
42 Correct 49 ms 7768 KB Output is correct
43 Correct 116 ms 8008 KB Output is correct
44 Correct 124 ms 8016 KB Output is correct
45 Correct 115 ms 7860 KB Output is correct
46 Correct 116 ms 8012 KB Output is correct
47 Correct 114 ms 7900 KB Output is correct
48 Correct 115 ms 8280 KB Output is correct
49 Correct 119 ms 7860 KB Output is correct
50 Correct 114 ms 8352 KB Output is correct
51 Correct 114 ms 8104 KB Output is correct
52 Correct 114 ms 8000 KB Output is correct
53 Correct 117 ms 7820 KB Output is correct
54 Correct 121 ms 8076 KB Output is correct
55 Correct 118 ms 7944 KB Output is correct
56 Correct 114 ms 8012 KB Output is correct
57 Correct 115 ms 8076 KB Output is correct
58 Correct 115 ms 8396 KB Output is correct
59 Correct 115 ms 8140 KB Output is correct
60 Correct 117 ms 8252 KB Output is correct
61 Correct 115 ms 8012 KB Output is correct
62 Correct 114 ms 8156 KB Output is correct
63 Correct 120 ms 8356 KB Output is correct
64 Correct 1031 ms 8872 KB Output is correct
65 Correct 1038 ms 9012 KB Output is correct
66 Correct 1035 ms 8816 KB Output is correct
67 Correct 1044 ms 8708 KB Output is correct
68 Correct 1033 ms 8640 KB Output is correct
69 Correct 1040 ms 8828 KB Output is correct
70 Correct 1040 ms 8640 KB Output is correct
71 Correct 1051 ms 8560 KB Output is correct
72 Correct 1045 ms 8552 KB Output is correct
73 Correct 1042 ms 8564 KB Output is correct
74 Correct 1040 ms 8560 KB Output is correct
75 Correct 1042 ms 8420 KB Output is correct
76 Correct 1042 ms 8812 KB Output is correct
77 Correct 1047 ms 8560 KB Output is correct
78 Correct 1032 ms 8564 KB Output is correct
79 Correct 1030 ms 8552 KB Output is correct
80 Correct 1034 ms 8820 KB Output is correct
81 Correct 1038 ms 8820 KB Output is correct
82 Correct 1041 ms 8812 KB Output is correct
83 Correct 1036 ms 8688 KB Output is correct
84 Correct 1035 ms 9040 KB Output is correct