답안 #949440

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
949440 2024-03-19T08:50:00 Z gaga999 Cubeword (CEOI19_cubeword) C++17
100 / 100
1073 ms 15480 KB
#include<bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5, mod = 998244353;

int n, ans;
int cnt[11];
int v[11][63][63];
int f[11][63][63][63];

int tran(char c) {
	if (c >= 'a' && c <= 'z') return c - 96;
	else if (c >= 'A' && c <= 'Z') return c - 38;
	else if (c >= '0' && c <= '9') return c + 5;
	else return 0;
}

string s[maxn];

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> s[i];
		s[i + n] = s[i];
		reverse(s[i + n].begin(), s[i + n].end());
	}
	n *= 2;
	sort(s + 1, s + 1 + n);
	n = unique(s + 1, s + n + 1) - s - 1;//去重
	for (int i = 1; i <= n; i++) {
		cnt[s[i].size()]++;
		v[s[i].size()][tran(s[i][0])][tran(s[i][s[i].size() - 1])]++;
	}
	for (int len = 3; len <= 10; len++) {
		if (!cnt[len]) continue;
		for (int l = 1; l <= 62; l++) {
			for (int i = 1; i <= 62; i++) {
				if (!v[len][l][i]) continue;
				for (int j = 1; j <= 62; j++) {
					if (!v[len][l][j]) continue;
					for (int k = 1; k <= 62; k++) {
						if (!v[len][l][k]) continue;
						(f[len][i][j][k] += 1ll * v[len][l][i] * v[len][l][j] % mod * v[len][l][k] % mod) %= mod;
					}
				}
			}
		}
		for (int l = 1; l <= 62; l++) {
			for (int i = 1; i <= 62; i++) {
				for (int j = 1; j <= 62; j++) {
					for (int k = 1; k <= 62; k++) {
						(ans += 1ll * f[len][i][j][k] * f[len][i][j][l] % mod * f[len][i][k][l] % mod * f[len][j][k][l] % mod) %= mod;
					}
				}
			}
		}
	}
	cout << ans;
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 745 ms 8016 KB Output is correct
2 Correct 749 ms 7808 KB Output is correct
3 Correct 753 ms 7708 KB Output is correct
4 Correct 743 ms 7808 KB Output is correct
5 Correct 760 ms 7836 KB Output is correct
6 Correct 742 ms 7840 KB Output is correct
7 Correct 740 ms 7740 KB Output is correct
8 Correct 734 ms 7900 KB Output is correct
9 Correct 743 ms 7920 KB Output is correct
10 Correct 742 ms 8044 KB Output is correct
11 Correct 728 ms 7764 KB Output is correct
12 Correct 735 ms 7836 KB Output is correct
13 Correct 739 ms 7708 KB Output is correct
14 Correct 739 ms 7864 KB Output is correct
15 Correct 739 ms 7804 KB Output is correct
16 Correct 744 ms 7736 KB Output is correct
17 Correct 750 ms 7828 KB Output is correct
18 Correct 742 ms 7776 KB Output is correct
19 Correct 752 ms 8020 KB Output is correct
20 Correct 744 ms 8024 KB Output is correct
21 Correct 735 ms 7748 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 745 ms 8016 KB Output is correct
2 Correct 749 ms 7808 KB Output is correct
3 Correct 753 ms 7708 KB Output is correct
4 Correct 743 ms 7808 KB Output is correct
5 Correct 760 ms 7836 KB Output is correct
6 Correct 742 ms 7840 KB Output is correct
7 Correct 740 ms 7740 KB Output is correct
8 Correct 734 ms 7900 KB Output is correct
9 Correct 743 ms 7920 KB Output is correct
10 Correct 742 ms 8044 KB Output is correct
11 Correct 728 ms 7764 KB Output is correct
12 Correct 735 ms 7836 KB Output is correct
13 Correct 739 ms 7708 KB Output is correct
14 Correct 739 ms 7864 KB Output is correct
15 Correct 739 ms 7804 KB Output is correct
16 Correct 744 ms 7736 KB Output is correct
17 Correct 750 ms 7828 KB Output is correct
18 Correct 742 ms 7776 KB Output is correct
19 Correct 752 ms 8020 KB Output is correct
20 Correct 744 ms 8024 KB Output is correct
21 Correct 735 ms 7748 KB Output is correct
22 Correct 746 ms 8600 KB Output is correct
23 Correct 738 ms 8600 KB Output is correct
24 Correct 785 ms 8356 KB Output is correct
25 Correct 761 ms 8600 KB Output is correct
26 Correct 738 ms 8484 KB Output is correct
27 Correct 737 ms 8600 KB Output is correct
28 Correct 733 ms 8364 KB Output is correct
29 Correct 726 ms 8532 KB Output is correct
30 Correct 727 ms 8560 KB Output is correct
31 Correct 734 ms 8352 KB Output is correct
32 Correct 735 ms 8360 KB Output is correct
33 Correct 730 ms 8600 KB Output is correct
34 Correct 743 ms 8472 KB Output is correct
35 Correct 731 ms 8532 KB Output is correct
36 Correct 728 ms 8724 KB Output is correct
37 Correct 730 ms 8352 KB Output is correct
38 Correct 724 ms 8528 KB Output is correct
39 Correct 743 ms 8528 KB Output is correct
40 Correct 727 ms 8596 KB Output is correct
41 Correct 731 ms 8532 KB Output is correct
42 Correct 729 ms 8596 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 745 ms 8016 KB Output is correct
2 Correct 749 ms 7808 KB Output is correct
3 Correct 753 ms 7708 KB Output is correct
4 Correct 743 ms 7808 KB Output is correct
5 Correct 760 ms 7836 KB Output is correct
6 Correct 742 ms 7840 KB Output is correct
7 Correct 740 ms 7740 KB Output is correct
8 Correct 734 ms 7900 KB Output is correct
9 Correct 743 ms 7920 KB Output is correct
10 Correct 742 ms 8044 KB Output is correct
11 Correct 728 ms 7764 KB Output is correct
12 Correct 735 ms 7836 KB Output is correct
13 Correct 739 ms 7708 KB Output is correct
14 Correct 739 ms 7864 KB Output is correct
15 Correct 739 ms 7804 KB Output is correct
16 Correct 744 ms 7736 KB Output is correct
17 Correct 750 ms 7828 KB Output is correct
18 Correct 742 ms 7776 KB Output is correct
19 Correct 752 ms 8020 KB Output is correct
20 Correct 744 ms 8024 KB Output is correct
21 Correct 735 ms 7748 KB Output is correct
22 Correct 746 ms 8600 KB Output is correct
23 Correct 738 ms 8600 KB Output is correct
24 Correct 785 ms 8356 KB Output is correct
25 Correct 761 ms 8600 KB Output is correct
26 Correct 738 ms 8484 KB Output is correct
27 Correct 737 ms 8600 KB Output is correct
28 Correct 733 ms 8364 KB Output is correct
29 Correct 726 ms 8532 KB Output is correct
30 Correct 727 ms 8560 KB Output is correct
31 Correct 734 ms 8352 KB Output is correct
32 Correct 735 ms 8360 KB Output is correct
33 Correct 730 ms 8600 KB Output is correct
34 Correct 743 ms 8472 KB Output is correct
35 Correct 731 ms 8532 KB Output is correct
36 Correct 728 ms 8724 KB Output is correct
37 Correct 730 ms 8352 KB Output is correct
38 Correct 724 ms 8528 KB Output is correct
39 Correct 743 ms 8528 KB Output is correct
40 Correct 727 ms 8596 KB Output is correct
41 Correct 731 ms 8532 KB Output is correct
42 Correct 729 ms 8596 KB Output is correct
43 Correct 765 ms 11120 KB Output is correct
44 Correct 755 ms 10948 KB Output is correct
45 Correct 756 ms 11092 KB Output is correct
46 Correct 768 ms 11160 KB Output is correct
47 Correct 780 ms 11056 KB Output is correct
48 Correct 792 ms 10848 KB Output is correct
49 Correct 788 ms 11052 KB Output is correct
50 Correct 792 ms 10908 KB Output is correct
51 Correct 784 ms 10868 KB Output is correct
52 Correct 772 ms 11052 KB Output is correct
53 Correct 776 ms 11048 KB Output is correct
54 Correct 781 ms 10844 KB Output is correct
55 Correct 764 ms 11116 KB Output is correct
56 Correct 764 ms 10972 KB Output is correct
57 Correct 754 ms 11056 KB Output is correct
58 Correct 756 ms 11056 KB Output is correct
59 Correct 773 ms 10804 KB Output is correct
60 Correct 763 ms 10868 KB Output is correct
61 Correct 783 ms 11152 KB Output is correct
62 Correct 786 ms 10840 KB Output is correct
63 Correct 763 ms 10872 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 745 ms 8016 KB Output is correct
2 Correct 749 ms 7808 KB Output is correct
3 Correct 753 ms 7708 KB Output is correct
4 Correct 743 ms 7808 KB Output is correct
5 Correct 760 ms 7836 KB Output is correct
6 Correct 742 ms 7840 KB Output is correct
7 Correct 740 ms 7740 KB Output is correct
8 Correct 734 ms 7900 KB Output is correct
9 Correct 743 ms 7920 KB Output is correct
10 Correct 742 ms 8044 KB Output is correct
11 Correct 728 ms 7764 KB Output is correct
12 Correct 735 ms 7836 KB Output is correct
13 Correct 739 ms 7708 KB Output is correct
14 Correct 739 ms 7864 KB Output is correct
15 Correct 739 ms 7804 KB Output is correct
16 Correct 744 ms 7736 KB Output is correct
17 Correct 750 ms 7828 KB Output is correct
18 Correct 742 ms 7776 KB Output is correct
19 Correct 752 ms 8020 KB Output is correct
20 Correct 744 ms 8024 KB Output is correct
21 Correct 735 ms 7748 KB Output is correct
22 Correct 746 ms 8600 KB Output is correct
23 Correct 738 ms 8600 KB Output is correct
24 Correct 785 ms 8356 KB Output is correct
25 Correct 761 ms 8600 KB Output is correct
26 Correct 738 ms 8484 KB Output is correct
27 Correct 737 ms 8600 KB Output is correct
28 Correct 733 ms 8364 KB Output is correct
29 Correct 726 ms 8532 KB Output is correct
30 Correct 727 ms 8560 KB Output is correct
31 Correct 734 ms 8352 KB Output is correct
32 Correct 735 ms 8360 KB Output is correct
33 Correct 730 ms 8600 KB Output is correct
34 Correct 743 ms 8472 KB Output is correct
35 Correct 731 ms 8532 KB Output is correct
36 Correct 728 ms 8724 KB Output is correct
37 Correct 730 ms 8352 KB Output is correct
38 Correct 724 ms 8528 KB Output is correct
39 Correct 743 ms 8528 KB Output is correct
40 Correct 727 ms 8596 KB Output is correct
41 Correct 731 ms 8532 KB Output is correct
42 Correct 729 ms 8596 KB Output is correct
43 Correct 765 ms 11120 KB Output is correct
44 Correct 755 ms 10948 KB Output is correct
45 Correct 756 ms 11092 KB Output is correct
46 Correct 768 ms 11160 KB Output is correct
47 Correct 780 ms 11056 KB Output is correct
48 Correct 792 ms 10848 KB Output is correct
49 Correct 788 ms 11052 KB Output is correct
50 Correct 792 ms 10908 KB Output is correct
51 Correct 784 ms 10868 KB Output is correct
52 Correct 772 ms 11052 KB Output is correct
53 Correct 776 ms 11048 KB Output is correct
54 Correct 781 ms 10844 KB Output is correct
55 Correct 764 ms 11116 KB Output is correct
56 Correct 764 ms 10972 KB Output is correct
57 Correct 754 ms 11056 KB Output is correct
58 Correct 756 ms 11056 KB Output is correct
59 Correct 773 ms 10804 KB Output is correct
60 Correct 763 ms 10868 KB Output is correct
61 Correct 783 ms 11152 KB Output is correct
62 Correct 786 ms 10840 KB Output is correct
63 Correct 763 ms 10872 KB Output is correct
64 Correct 1051 ms 15056 KB Output is correct
65 Correct 1062 ms 15136 KB Output is correct
66 Correct 1036 ms 15244 KB Output is correct
67 Correct 1040 ms 15448 KB Output is correct
68 Correct 1052 ms 15360 KB Output is correct
69 Correct 1041 ms 15160 KB Output is correct
70 Correct 1033 ms 15132 KB Output is correct
71 Correct 1038 ms 15276 KB Output is correct
72 Correct 1053 ms 15324 KB Output is correct
73 Correct 1037 ms 15356 KB Output is correct
74 Correct 1045 ms 15224 KB Output is correct
75 Correct 1036 ms 15336 KB Output is correct
76 Correct 1050 ms 15160 KB Output is correct
77 Correct 1051 ms 15424 KB Output is correct
78 Correct 1033 ms 15336 KB Output is correct
79 Correct 1061 ms 15336 KB Output is correct
80 Correct 1042 ms 15456 KB Output is correct
81 Correct 1045 ms 15184 KB Output is correct
82 Correct 1031 ms 15368 KB Output is correct
83 Correct 1073 ms 15480 KB Output is correct
84 Correct 1045 ms 15248 KB Output is correct