Submission #446294

# Submission time Handle Problem Language Result Execution time Memory
446294 2021-07-21T13:52:28 Z qwerasdfzxcl Cubeword (CEOI19_cubeword) C++14
84 / 100
889 ms 19008 KB
#include <bits/stdc++.h>
#define MX 52

typedef long long ll;
using namespace std;
const int MOD = 998244353;
int cnt[101][101][101];
int a[8], b[12] = {0, 1, 2, 3, 0, 1, 2, 3, 4, 5, 6, 7}, c[12] = {1, 2, 3, 0, 4, 5, 6, 7, 5, 6, 7, 4};
int mp[505], val[11][101][101][101];

bool chk(string &s){
    int n = s.size();
    for (int i=0;i<n;i++){
        int j = n-1-i;
        if (i>j) break;
        if (s[i]!=s[j]) return 0;
    }
    return 1;
}

int main(){
    cin.tie(NULL);
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    unordered_set<string> st;

    for (int i='a';i<='z';i++){
        mp[i] = i-'a';
    }
    for (int i='A';i<='Z';i++){
        mp[i] = i-'A'+26;
    }
    for (int i='0';i<='9';i++){
        mp[i] = i-'0'+52;
    }
    for (int i=0;i<n;i++){
        string s;
        cin >> s;
        int idx1 = mp[s[0]], idx2 = mp[s.back()];
        cnt[(int)s.size()][idx1][idx2]++;
        cnt[(int)s.size()][idx2][idx1]++;
        if (st.find(s)!=st.end()){
            cnt[(int)s.size()][idx1][idx2]--;
            cnt[(int)s.size()][idx2][idx1]--;
            continue;
        }
        reverse(s.begin(), s.end());
        if (st.find(s)!=st.end()){
            cnt[(int)s.size()][idx1][idx2]--;
            cnt[(int)s.size()][idx2][idx1]--;
            continue;
        }
        if (chk(s)) cnt[(int)s.size()][idx2][idx1]--;
        st.insert(s);
    }

    for (int len=3;len<=10;len++){
        for (int i=0;i<MX;i++){
            for (int j=0;j<MX;j++){
                for (int k=0;k<MX;k++){
                    for (int l=0;l<MX;l++){
                        ll tmp = (ll)cnt[len][i][l] * cnt[len][j][l] %MOD;
                        tmp = (tmp*cnt[len][k][l])%MOD;
                        val[len][i][j][k] += tmp;
                        if (val[len][i][j][k]>=MOD) val[len][i][j][k] -= MOD;
                    }
                }
            }
        }
    }
    int ans = 0;
    for (int len=3;len<=10;len++){
        for (int i=0;i<MX;i++){
            for (int j=0;j<MX;j++){
                for (int k=0;k<MX;k++){
                    for (int l=0;l<MX;l++){
                        ll tmp = val[len][i][j][k];
                        tmp = (tmp*val[len][i][j][l])%MOD;
                        tmp = (tmp*val[len][i][k][l])%MOD;
                        tmp = (tmp*val[len][j][k][l])%MOD;
                        ans += tmp;
                        if (ans>=MOD) ans -= MOD;
                    }
                }
            }
        }
    }
    printf("%d\n", ans);
    return 0;
}

Compilation message

cubeword.cpp: In function 'int main()':
cubeword.cpp:40:27: warning: array subscript has type 'char' [-Wchar-subscripts]
   40 |         int idx1 = mp[s[0]], idx2 = mp[s.back()];
      |                           ^
cubeword.cpp:40:46: warning: array subscript has type 'char' [-Wchar-subscripts]
   40 |         int idx1 = mp[s[0]], idx2 = mp[s.back()];
      |                                        ~~~~~~^~
# Verdict Execution time Memory Grader output
1 Correct 820 ms 17760 KB Output is correct
2 Correct 817 ms 17904 KB Output is correct
3 Correct 823 ms 17792 KB Output is correct
4 Correct 829 ms 17784 KB Output is correct
5 Correct 821 ms 17832 KB Output is correct
6 Correct 830 ms 17856 KB Output is correct
7 Correct 831 ms 17736 KB Output is correct
8 Correct 829 ms 17796 KB Output is correct
9 Correct 817 ms 17788 KB Output is correct
10 Correct 835 ms 17824 KB Output is correct
11 Correct 825 ms 17792 KB Output is correct
12 Correct 827 ms 17848 KB Output is correct
13 Correct 828 ms 17916 KB Output is correct
14 Correct 860 ms 17876 KB Output is correct
15 Correct 830 ms 17796 KB Output is correct
16 Correct 820 ms 17784 KB Output is correct
17 Correct 838 ms 17848 KB Output is correct
18 Correct 828 ms 17780 KB Output is correct
19 Correct 810 ms 17848 KB Output is correct
20 Correct 816 ms 17796 KB Output is correct
21 Correct 810 ms 17832 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 820 ms 17760 KB Output is correct
2 Correct 817 ms 17904 KB Output is correct
3 Correct 823 ms 17792 KB Output is correct
4 Correct 829 ms 17784 KB Output is correct
5 Correct 821 ms 17832 KB Output is correct
6 Correct 830 ms 17856 KB Output is correct
7 Correct 831 ms 17736 KB Output is correct
8 Correct 829 ms 17796 KB Output is correct
9 Correct 817 ms 17788 KB Output is correct
10 Correct 835 ms 17824 KB Output is correct
11 Correct 825 ms 17792 KB Output is correct
12 Correct 827 ms 17848 KB Output is correct
13 Correct 828 ms 17916 KB Output is correct
14 Correct 860 ms 17876 KB Output is correct
15 Correct 830 ms 17796 KB Output is correct
16 Correct 820 ms 17784 KB Output is correct
17 Correct 838 ms 17848 KB Output is correct
18 Correct 828 ms 17780 KB Output is correct
19 Correct 810 ms 17848 KB Output is correct
20 Correct 816 ms 17796 KB Output is correct
21 Correct 810 ms 17832 KB Output is correct
22 Correct 824 ms 18004 KB Output is correct
23 Correct 832 ms 18684 KB Output is correct
24 Correct 815 ms 18764 KB Output is correct
25 Correct 807 ms 18752 KB Output is correct
26 Correct 825 ms 18868 KB Output is correct
27 Correct 827 ms 18648 KB Output is correct
28 Correct 834 ms 18760 KB Output is correct
29 Correct 828 ms 18760 KB Output is correct
30 Correct 812 ms 18792 KB Output is correct
31 Correct 821 ms 18872 KB Output is correct
32 Correct 868 ms 18744 KB Output is correct
33 Correct 887 ms 18764 KB Output is correct
34 Correct 819 ms 18864 KB Output is correct
35 Correct 817 ms 18872 KB Output is correct
36 Correct 822 ms 18764 KB Output is correct
37 Correct 817 ms 18756 KB Output is correct
38 Correct 815 ms 18756 KB Output is correct
39 Correct 807 ms 18736 KB Output is correct
40 Correct 814 ms 18788 KB Output is correct
41 Correct 821 ms 18764 KB Output is correct
42 Correct 824 ms 18756 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 820 ms 17760 KB Output is correct
2 Correct 817 ms 17904 KB Output is correct
3 Correct 823 ms 17792 KB Output is correct
4 Correct 829 ms 17784 KB Output is correct
5 Correct 821 ms 17832 KB Output is correct
6 Correct 830 ms 17856 KB Output is correct
7 Correct 831 ms 17736 KB Output is correct
8 Correct 829 ms 17796 KB Output is correct
9 Correct 817 ms 17788 KB Output is correct
10 Correct 835 ms 17824 KB Output is correct
11 Correct 825 ms 17792 KB Output is correct
12 Correct 827 ms 17848 KB Output is correct
13 Correct 828 ms 17916 KB Output is correct
14 Correct 860 ms 17876 KB Output is correct
15 Correct 830 ms 17796 KB Output is correct
16 Correct 820 ms 17784 KB Output is correct
17 Correct 838 ms 17848 KB Output is correct
18 Correct 828 ms 17780 KB Output is correct
19 Correct 810 ms 17848 KB Output is correct
20 Correct 816 ms 17796 KB Output is correct
21 Correct 810 ms 17832 KB Output is correct
22 Correct 824 ms 18004 KB Output is correct
23 Correct 832 ms 18684 KB Output is correct
24 Correct 815 ms 18764 KB Output is correct
25 Correct 807 ms 18752 KB Output is correct
26 Correct 825 ms 18868 KB Output is correct
27 Correct 827 ms 18648 KB Output is correct
28 Correct 834 ms 18760 KB Output is correct
29 Correct 828 ms 18760 KB Output is correct
30 Correct 812 ms 18792 KB Output is correct
31 Correct 821 ms 18872 KB Output is correct
32 Correct 868 ms 18744 KB Output is correct
33 Correct 887 ms 18764 KB Output is correct
34 Correct 819 ms 18864 KB Output is correct
35 Correct 817 ms 18872 KB Output is correct
36 Correct 822 ms 18764 KB Output is correct
37 Correct 817 ms 18756 KB Output is correct
38 Correct 815 ms 18756 KB Output is correct
39 Correct 807 ms 18736 KB Output is correct
40 Correct 814 ms 18788 KB Output is correct
41 Correct 821 ms 18764 KB Output is correct
42 Correct 824 ms 18756 KB Output is correct
43 Correct 819 ms 18904 KB Output is correct
44 Correct 823 ms 18916 KB Output is correct
45 Correct 818 ms 18908 KB Output is correct
46 Correct 818 ms 18992 KB Output is correct
47 Correct 815 ms 18908 KB Output is correct
48 Correct 837 ms 18892 KB Output is correct
49 Correct 845 ms 18956 KB Output is correct
50 Correct 815 ms 19000 KB Output is correct
51 Correct 808 ms 18824 KB Output is correct
52 Correct 843 ms 18908 KB Output is correct
53 Correct 824 ms 19000 KB Output is correct
54 Correct 830 ms 18912 KB Output is correct
55 Correct 889 ms 18904 KB Output is correct
56 Correct 867 ms 18868 KB Output is correct
57 Correct 827 ms 19008 KB Output is correct
58 Correct 808 ms 18900 KB Output is correct
59 Correct 847 ms 18904 KB Output is correct
60 Correct 818 ms 18976 KB Output is correct
61 Correct 832 ms 18996 KB Output is correct
62 Correct 816 ms 18884 KB Output is correct
63 Correct 812 ms 18812 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 820 ms 17760 KB Output is correct
2 Correct 817 ms 17904 KB Output is correct
3 Correct 823 ms 17792 KB Output is correct
4 Correct 829 ms 17784 KB Output is correct
5 Correct 821 ms 17832 KB Output is correct
6 Correct 830 ms 17856 KB Output is correct
7 Correct 831 ms 17736 KB Output is correct
8 Correct 829 ms 17796 KB Output is correct
9 Correct 817 ms 17788 KB Output is correct
10 Correct 835 ms 17824 KB Output is correct
11 Correct 825 ms 17792 KB Output is correct
12 Correct 827 ms 17848 KB Output is correct
13 Correct 828 ms 17916 KB Output is correct
14 Correct 860 ms 17876 KB Output is correct
15 Correct 830 ms 17796 KB Output is correct
16 Correct 820 ms 17784 KB Output is correct
17 Correct 838 ms 17848 KB Output is correct
18 Correct 828 ms 17780 KB Output is correct
19 Correct 810 ms 17848 KB Output is correct
20 Correct 816 ms 17796 KB Output is correct
21 Correct 810 ms 17832 KB Output is correct
22 Correct 824 ms 18004 KB Output is correct
23 Correct 832 ms 18684 KB Output is correct
24 Correct 815 ms 18764 KB Output is correct
25 Correct 807 ms 18752 KB Output is correct
26 Correct 825 ms 18868 KB Output is correct
27 Correct 827 ms 18648 KB Output is correct
28 Correct 834 ms 18760 KB Output is correct
29 Correct 828 ms 18760 KB Output is correct
30 Correct 812 ms 18792 KB Output is correct
31 Correct 821 ms 18872 KB Output is correct
32 Correct 868 ms 18744 KB Output is correct
33 Correct 887 ms 18764 KB Output is correct
34 Correct 819 ms 18864 KB Output is correct
35 Correct 817 ms 18872 KB Output is correct
36 Correct 822 ms 18764 KB Output is correct
37 Correct 817 ms 18756 KB Output is correct
38 Correct 815 ms 18756 KB Output is correct
39 Correct 807 ms 18736 KB Output is correct
40 Correct 814 ms 18788 KB Output is correct
41 Correct 821 ms 18764 KB Output is correct
42 Correct 824 ms 18756 KB Output is correct
43 Correct 819 ms 18904 KB Output is correct
44 Correct 823 ms 18916 KB Output is correct
45 Correct 818 ms 18908 KB Output is correct
46 Correct 818 ms 18992 KB Output is correct
47 Correct 815 ms 18908 KB Output is correct
48 Correct 837 ms 18892 KB Output is correct
49 Correct 845 ms 18956 KB Output is correct
50 Correct 815 ms 19000 KB Output is correct
51 Correct 808 ms 18824 KB Output is correct
52 Correct 843 ms 18908 KB Output is correct
53 Correct 824 ms 19000 KB Output is correct
54 Correct 830 ms 18912 KB Output is correct
55 Correct 889 ms 18904 KB Output is correct
56 Correct 867 ms 18868 KB Output is correct
57 Correct 827 ms 19008 KB Output is correct
58 Correct 808 ms 18900 KB Output is correct
59 Correct 847 ms 18904 KB Output is correct
60 Correct 818 ms 18976 KB Output is correct
61 Correct 832 ms 18996 KB Output is correct
62 Correct 816 ms 18884 KB Output is correct
63 Correct 812 ms 18812 KB Output is correct
64 Incorrect 814 ms 18996 KB Output isn't correct
65 Halted 0 ms 0 KB -