답안 #446306

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
446306 2021-07-21T14:17:14 Z qwerasdfzxcl Cubeword (CEOI19_cubeword) C++14
84 / 100
1100 ms 22936 KB
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("avx,avx2,fma")
#define MX 62

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[11];

    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()], len = s.size();
        cnt[len][idx1][idx2]++;
        cnt[len][idx2][idx1]++;
        if (st[len].find(s)!=st[len].end()){
            cnt[len][idx1][idx2]--;
            cnt[len][idx2][idx1]--;
            continue;
        }
        reverse(s.begin(), s.end());
        if (st[len].find(s)!=st[len].end()){
            cnt[len][idx1][idx2]--;
            cnt[len][idx2][idx1]--;
            continue;
        }
        if (chk(s)) cnt[(int)s.size()][idx2][idx1]--;
        st[len].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];
                        if (tmp>=MOD) tmp %= MOD;
                        tmp *= cnt[len][k][l];
                        if (tmp>=MOD) tmp %= 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];
                        if (tmp>=MOD) tmp %= MOD;
                        tmp = tmp*val[len][i][k][l];
                        if (tmp>=MOD) tmp %= MOD;
                        tmp = tmp*val[len][j][k][l];
                        if (tmp>=MOD) tmp %= MOD;
                        ans += tmp;
                        if (ans>=MOD) ans -= MOD;
                    }
                }
            }
        }
    }
    printf("%d\n", ans);
    return 0;
}

Compilation message

cubeword.cpp: In function 'int main()':
cubeword.cpp:42:27: warning: array subscript has type 'char' [-Wchar-subscripts]
   42 |         int idx1 = mp[s[0]], idx2 = mp[s.back()], len = s.size();
      |                           ^
cubeword.cpp:42:46: warning: array subscript has type 'char' [-Wchar-subscripts]
   42 |         int idx1 = mp[s[0]], idx2 = mp[s.back()], len = s.size();
      |                                        ~~~~~~^~
# 결과 실행 시간 메모리 Grader output
1 Correct 876 ms 21064 KB Output is correct
2 Correct 852 ms 21144 KB Output is correct
3 Correct 785 ms 21148 KB Output is correct
4 Correct 772 ms 21144 KB Output is correct
5 Correct 751 ms 21036 KB Output is correct
6 Correct 760 ms 21060 KB Output is correct
7 Correct 758 ms 21056 KB Output is correct
8 Correct 764 ms 21152 KB Output is correct
9 Correct 798 ms 21140 KB Output is correct
10 Correct 794 ms 21088 KB Output is correct
11 Correct 779 ms 21144 KB Output is correct
12 Correct 769 ms 21048 KB Output is correct
13 Correct 770 ms 21160 KB Output is correct
14 Correct 756 ms 21152 KB Output is correct
15 Correct 785 ms 21064 KB Output is correct
16 Correct 780 ms 21148 KB Output is correct
17 Correct 789 ms 21036 KB Output is correct
18 Correct 796 ms 21100 KB Output is correct
19 Correct 841 ms 21144 KB Output is correct
20 Correct 774 ms 21124 KB Output is correct
21 Correct 785 ms 21160 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 876 ms 21064 KB Output is correct
2 Correct 852 ms 21144 KB Output is correct
3 Correct 785 ms 21148 KB Output is correct
4 Correct 772 ms 21144 KB Output is correct
5 Correct 751 ms 21036 KB Output is correct
6 Correct 760 ms 21060 KB Output is correct
7 Correct 758 ms 21056 KB Output is correct
8 Correct 764 ms 21152 KB Output is correct
9 Correct 798 ms 21140 KB Output is correct
10 Correct 794 ms 21088 KB Output is correct
11 Correct 779 ms 21144 KB Output is correct
12 Correct 769 ms 21048 KB Output is correct
13 Correct 770 ms 21160 KB Output is correct
14 Correct 756 ms 21152 KB Output is correct
15 Correct 785 ms 21064 KB Output is correct
16 Correct 780 ms 21148 KB Output is correct
17 Correct 789 ms 21036 KB Output is correct
18 Correct 796 ms 21100 KB Output is correct
19 Correct 841 ms 21144 KB Output is correct
20 Correct 774 ms 21124 KB Output is correct
21 Correct 785 ms 21160 KB Output is correct
22 Correct 773 ms 21884 KB Output is correct
23 Correct 779 ms 21656 KB Output is correct
24 Correct 796 ms 21696 KB Output is correct
25 Correct 873 ms 21708 KB Output is correct
26 Correct 774 ms 21644 KB Output is correct
27 Correct 795 ms 21736 KB Output is correct
28 Correct 841 ms 21736 KB Output is correct
29 Correct 777 ms 21736 KB Output is correct
30 Correct 773 ms 21740 KB Output is correct
31 Correct 794 ms 21656 KB Output is correct
32 Correct 761 ms 21640 KB Output is correct
33 Correct 820 ms 21640 KB Output is correct
34 Correct 782 ms 21744 KB Output is correct
35 Correct 769 ms 21620 KB Output is correct
36 Correct 844 ms 21744 KB Output is correct
37 Correct 789 ms 21740 KB Output is correct
38 Correct 867 ms 21744 KB Output is correct
39 Correct 807 ms 21664 KB Output is correct
40 Correct 780 ms 21764 KB Output is correct
41 Correct 765 ms 21700 KB Output is correct
42 Correct 818 ms 21712 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 876 ms 21064 KB Output is correct
2 Correct 852 ms 21144 KB Output is correct
3 Correct 785 ms 21148 KB Output is correct
4 Correct 772 ms 21144 KB Output is correct
5 Correct 751 ms 21036 KB Output is correct
6 Correct 760 ms 21060 KB Output is correct
7 Correct 758 ms 21056 KB Output is correct
8 Correct 764 ms 21152 KB Output is correct
9 Correct 798 ms 21140 KB Output is correct
10 Correct 794 ms 21088 KB Output is correct
11 Correct 779 ms 21144 KB Output is correct
12 Correct 769 ms 21048 KB Output is correct
13 Correct 770 ms 21160 KB Output is correct
14 Correct 756 ms 21152 KB Output is correct
15 Correct 785 ms 21064 KB Output is correct
16 Correct 780 ms 21148 KB Output is correct
17 Correct 789 ms 21036 KB Output is correct
18 Correct 796 ms 21100 KB Output is correct
19 Correct 841 ms 21144 KB Output is correct
20 Correct 774 ms 21124 KB Output is correct
21 Correct 785 ms 21160 KB Output is correct
22 Correct 773 ms 21884 KB Output is correct
23 Correct 779 ms 21656 KB Output is correct
24 Correct 796 ms 21696 KB Output is correct
25 Correct 873 ms 21708 KB Output is correct
26 Correct 774 ms 21644 KB Output is correct
27 Correct 795 ms 21736 KB Output is correct
28 Correct 841 ms 21736 KB Output is correct
29 Correct 777 ms 21736 KB Output is correct
30 Correct 773 ms 21740 KB Output is correct
31 Correct 794 ms 21656 KB Output is correct
32 Correct 761 ms 21640 KB Output is correct
33 Correct 820 ms 21640 KB Output is correct
34 Correct 782 ms 21744 KB Output is correct
35 Correct 769 ms 21620 KB Output is correct
36 Correct 844 ms 21744 KB Output is correct
37 Correct 789 ms 21740 KB Output is correct
38 Correct 867 ms 21744 KB Output is correct
39 Correct 807 ms 21664 KB Output is correct
40 Correct 780 ms 21764 KB Output is correct
41 Correct 765 ms 21700 KB Output is correct
42 Correct 818 ms 21712 KB Output is correct
43 Correct 842 ms 21904 KB Output is correct
44 Correct 835 ms 22060 KB Output is correct
45 Correct 844 ms 22052 KB Output is correct
46 Correct 826 ms 21972 KB Output is correct
47 Correct 914 ms 22048 KB Output is correct
48 Correct 828 ms 22052 KB Output is correct
49 Correct 839 ms 21988 KB Output is correct
50 Correct 878 ms 21948 KB Output is correct
51 Correct 834 ms 22048 KB Output is correct
52 Correct 932 ms 21964 KB Output is correct
53 Correct 828 ms 21968 KB Output is correct
54 Correct 852 ms 22120 KB Output is correct
55 Correct 819 ms 22112 KB Output is correct
56 Correct 837 ms 22364 KB Output is correct
57 Correct 833 ms 22612 KB Output is correct
58 Correct 825 ms 22708 KB Output is correct
59 Correct 837 ms 22716 KB Output is correct
60 Correct 848 ms 22696 KB Output is correct
61 Correct 834 ms 22716 KB Output is correct
62 Correct 846 ms 22716 KB Output is correct
63 Correct 926 ms 22712 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 876 ms 21064 KB Output is correct
2 Correct 852 ms 21144 KB Output is correct
3 Correct 785 ms 21148 KB Output is correct
4 Correct 772 ms 21144 KB Output is correct
5 Correct 751 ms 21036 KB Output is correct
6 Correct 760 ms 21060 KB Output is correct
7 Correct 758 ms 21056 KB Output is correct
8 Correct 764 ms 21152 KB Output is correct
9 Correct 798 ms 21140 KB Output is correct
10 Correct 794 ms 21088 KB Output is correct
11 Correct 779 ms 21144 KB Output is correct
12 Correct 769 ms 21048 KB Output is correct
13 Correct 770 ms 21160 KB Output is correct
14 Correct 756 ms 21152 KB Output is correct
15 Correct 785 ms 21064 KB Output is correct
16 Correct 780 ms 21148 KB Output is correct
17 Correct 789 ms 21036 KB Output is correct
18 Correct 796 ms 21100 KB Output is correct
19 Correct 841 ms 21144 KB Output is correct
20 Correct 774 ms 21124 KB Output is correct
21 Correct 785 ms 21160 KB Output is correct
22 Correct 773 ms 21884 KB Output is correct
23 Correct 779 ms 21656 KB Output is correct
24 Correct 796 ms 21696 KB Output is correct
25 Correct 873 ms 21708 KB Output is correct
26 Correct 774 ms 21644 KB Output is correct
27 Correct 795 ms 21736 KB Output is correct
28 Correct 841 ms 21736 KB Output is correct
29 Correct 777 ms 21736 KB Output is correct
30 Correct 773 ms 21740 KB Output is correct
31 Correct 794 ms 21656 KB Output is correct
32 Correct 761 ms 21640 KB Output is correct
33 Correct 820 ms 21640 KB Output is correct
34 Correct 782 ms 21744 KB Output is correct
35 Correct 769 ms 21620 KB Output is correct
36 Correct 844 ms 21744 KB Output is correct
37 Correct 789 ms 21740 KB Output is correct
38 Correct 867 ms 21744 KB Output is correct
39 Correct 807 ms 21664 KB Output is correct
40 Correct 780 ms 21764 KB Output is correct
41 Correct 765 ms 21700 KB Output is correct
42 Correct 818 ms 21712 KB Output is correct
43 Correct 842 ms 21904 KB Output is correct
44 Correct 835 ms 22060 KB Output is correct
45 Correct 844 ms 22052 KB Output is correct
46 Correct 826 ms 21972 KB Output is correct
47 Correct 914 ms 22048 KB Output is correct
48 Correct 828 ms 22052 KB Output is correct
49 Correct 839 ms 21988 KB Output is correct
50 Correct 878 ms 21948 KB Output is correct
51 Correct 834 ms 22048 KB Output is correct
52 Correct 932 ms 21964 KB Output is correct
53 Correct 828 ms 21968 KB Output is correct
54 Correct 852 ms 22120 KB Output is correct
55 Correct 819 ms 22112 KB Output is correct
56 Correct 837 ms 22364 KB Output is correct
57 Correct 833 ms 22612 KB Output is correct
58 Correct 825 ms 22708 KB Output is correct
59 Correct 837 ms 22716 KB Output is correct
60 Correct 848 ms 22696 KB Output is correct
61 Correct 834 ms 22716 KB Output is correct
62 Correct 846 ms 22716 KB Output is correct
63 Correct 926 ms 22712 KB Output is correct
64 Execution timed out 1188 ms 22936 KB Time limit exceeded
65 Halted 0 ms 0 KB -