답안 #519365

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
519365 2022-01-26T09:06:52 Z sidon Cubeword (CEOI19_cubeword) C++17
100 / 100
1034 ms 31516 KB
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;
#define int int64_t
#define F(X, Y) for(X = 0; X < Y; X++)

const int B = 62, LIM = 8, M = 998244353;

int get(char c) {
	if(c < 60) return c - 48;
	return c - (c < 95 ? 55 : 61);
}
 
int n, a[LIM][B][B], b[LIM][B][B][B], res;
map<string, bool> inp;
int i, j, k, l, x;

#define c(i, j, k, l) ((b[L][i][j][l] * b[L][j][k][l]) % M)
 
int32_t main() {
	cin >> n;
	while(n--) {
		string s; cin >> s;
		i = size(s);
 
		if(inp[s]) continue;
 
		string t = s;
		reverse(begin(t), end(t));
		inp[s] = inp[t] = 1;
 
		int z = get(s[0]), y = get(end(s)[-1]);
		++a[i-3][z][y];
		if(s != t) ++a[i-3][y][z];
	}
 
	for(int L = 0; L < LIM; L++) {
		F(i, B) F(j, i+1) F(k, j+1) F(x, B)
			b[L][i][j][k] += a[L][i][x] * a[L][j][x] * a[L][k][x];

		F(i, B) F(j, i+1) F(k, j+1) F(x, B)
			b[L][i][j][k] %= M;

		F(i, B) F(j, i+1) F(k, j+1) F(x, B)
			b[L][i][k][j] = b[L][j][i][k] = b[L][j][k][i] = b[L][k][i][j] = b[L][k][j][i] = b[L][i][j][k];

		F(i, B) F(j, B) F(k, B) F(l, B)
			res += (c(i, j, k, l) * c(l, k, j, i)) % M;
	}
 
	cout << res % M;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 945 ms 30020 KB Output is correct
2 Correct 970 ms 30104 KB Output is correct
3 Correct 960 ms 30032 KB Output is correct
4 Correct 930 ms 30280 KB Output is correct
5 Correct 968 ms 30156 KB Output is correct
6 Correct 938 ms 30144 KB Output is correct
7 Correct 958 ms 30056 KB Output is correct
8 Correct 909 ms 30208 KB Output is correct
9 Correct 979 ms 30136 KB Output is correct
10 Correct 969 ms 30140 KB Output is correct
11 Correct 942 ms 30020 KB Output is correct
12 Correct 966 ms 30044 KB Output is correct
13 Correct 947 ms 29972 KB Output is correct
14 Correct 949 ms 30000 KB Output is correct
15 Correct 931 ms 30048 KB Output is correct
16 Correct 944 ms 30136 KB Output is correct
17 Correct 955 ms 30052 KB Output is correct
18 Correct 1020 ms 29944 KB Output is correct
19 Correct 1030 ms 29936 KB Output is correct
20 Correct 965 ms 30096 KB Output is correct
21 Correct 940 ms 29984 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 945 ms 30020 KB Output is correct
2 Correct 970 ms 30104 KB Output is correct
3 Correct 960 ms 30032 KB Output is correct
4 Correct 930 ms 30280 KB Output is correct
5 Correct 968 ms 30156 KB Output is correct
6 Correct 938 ms 30144 KB Output is correct
7 Correct 958 ms 30056 KB Output is correct
8 Correct 909 ms 30208 KB Output is correct
9 Correct 979 ms 30136 KB Output is correct
10 Correct 969 ms 30140 KB Output is correct
11 Correct 942 ms 30020 KB Output is correct
12 Correct 966 ms 30044 KB Output is correct
13 Correct 947 ms 29972 KB Output is correct
14 Correct 949 ms 30000 KB Output is correct
15 Correct 931 ms 30048 KB Output is correct
16 Correct 944 ms 30136 KB Output is correct
17 Correct 955 ms 30052 KB Output is correct
18 Correct 1020 ms 29944 KB Output is correct
19 Correct 1030 ms 29936 KB Output is correct
20 Correct 965 ms 30096 KB Output is correct
21 Correct 940 ms 29984 KB Output is correct
22 Correct 920 ms 30712 KB Output is correct
23 Correct 931 ms 30776 KB Output is correct
24 Correct 1016 ms 30792 KB Output is correct
25 Correct 916 ms 30764 KB Output is correct
26 Correct 984 ms 30976 KB Output is correct
27 Correct 920 ms 30756 KB Output is correct
28 Correct 966 ms 30884 KB Output is correct
29 Correct 939 ms 30864 KB Output is correct
30 Correct 914 ms 30648 KB Output is correct
31 Correct 933 ms 30700 KB Output is correct
32 Correct 916 ms 30852 KB Output is correct
33 Correct 921 ms 30848 KB Output is correct
34 Correct 908 ms 30900 KB Output is correct
35 Correct 904 ms 30928 KB Output is correct
36 Correct 914 ms 30928 KB Output is correct
37 Correct 921 ms 30672 KB Output is correct
38 Correct 916 ms 30744 KB Output is correct
39 Correct 895 ms 30664 KB Output is correct
40 Correct 921 ms 30768 KB Output is correct
41 Correct 915 ms 30656 KB Output is correct
42 Correct 933 ms 30916 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 945 ms 30020 KB Output is correct
2 Correct 970 ms 30104 KB Output is correct
3 Correct 960 ms 30032 KB Output is correct
4 Correct 930 ms 30280 KB Output is correct
5 Correct 968 ms 30156 KB Output is correct
6 Correct 938 ms 30144 KB Output is correct
7 Correct 958 ms 30056 KB Output is correct
8 Correct 909 ms 30208 KB Output is correct
9 Correct 979 ms 30136 KB Output is correct
10 Correct 969 ms 30140 KB Output is correct
11 Correct 942 ms 30020 KB Output is correct
12 Correct 966 ms 30044 KB Output is correct
13 Correct 947 ms 29972 KB Output is correct
14 Correct 949 ms 30000 KB Output is correct
15 Correct 931 ms 30048 KB Output is correct
16 Correct 944 ms 30136 KB Output is correct
17 Correct 955 ms 30052 KB Output is correct
18 Correct 1020 ms 29944 KB Output is correct
19 Correct 1030 ms 29936 KB Output is correct
20 Correct 965 ms 30096 KB Output is correct
21 Correct 940 ms 29984 KB Output is correct
22 Correct 920 ms 30712 KB Output is correct
23 Correct 931 ms 30776 KB Output is correct
24 Correct 1016 ms 30792 KB Output is correct
25 Correct 916 ms 30764 KB Output is correct
26 Correct 984 ms 30976 KB Output is correct
27 Correct 920 ms 30756 KB Output is correct
28 Correct 966 ms 30884 KB Output is correct
29 Correct 939 ms 30864 KB Output is correct
30 Correct 914 ms 30648 KB Output is correct
31 Correct 933 ms 30700 KB Output is correct
32 Correct 916 ms 30852 KB Output is correct
33 Correct 921 ms 30848 KB Output is correct
34 Correct 908 ms 30900 KB Output is correct
35 Correct 904 ms 30928 KB Output is correct
36 Correct 914 ms 30928 KB Output is correct
37 Correct 921 ms 30672 KB Output is correct
38 Correct 916 ms 30744 KB Output is correct
39 Correct 895 ms 30664 KB Output is correct
40 Correct 921 ms 30768 KB Output is correct
41 Correct 915 ms 30656 KB Output is correct
42 Correct 933 ms 30916 KB Output is correct
43 Correct 900 ms 31180 KB Output is correct
44 Correct 905 ms 31044 KB Output is correct
45 Correct 901 ms 31020 KB Output is correct
46 Correct 905 ms 30984 KB Output is correct
47 Correct 902 ms 31128 KB Output is correct
48 Correct 922 ms 31004 KB Output is correct
49 Correct 913 ms 30952 KB Output is correct
50 Correct 900 ms 31172 KB Output is correct
51 Correct 918 ms 31060 KB Output is correct
52 Correct 908 ms 31224 KB Output is correct
53 Correct 921 ms 31044 KB Output is correct
54 Correct 920 ms 31040 KB Output is correct
55 Correct 958 ms 31128 KB Output is correct
56 Correct 955 ms 31024 KB Output is correct
57 Correct 924 ms 30988 KB Output is correct
58 Correct 911 ms 30980 KB Output is correct
59 Correct 969 ms 31040 KB Output is correct
60 Correct 950 ms 30960 KB Output is correct
61 Correct 951 ms 31176 KB Output is correct
62 Correct 966 ms 31036 KB Output is correct
63 Correct 1034 ms 30972 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 945 ms 30020 KB Output is correct
2 Correct 970 ms 30104 KB Output is correct
3 Correct 960 ms 30032 KB Output is correct
4 Correct 930 ms 30280 KB Output is correct
5 Correct 968 ms 30156 KB Output is correct
6 Correct 938 ms 30144 KB Output is correct
7 Correct 958 ms 30056 KB Output is correct
8 Correct 909 ms 30208 KB Output is correct
9 Correct 979 ms 30136 KB Output is correct
10 Correct 969 ms 30140 KB Output is correct
11 Correct 942 ms 30020 KB Output is correct
12 Correct 966 ms 30044 KB Output is correct
13 Correct 947 ms 29972 KB Output is correct
14 Correct 949 ms 30000 KB Output is correct
15 Correct 931 ms 30048 KB Output is correct
16 Correct 944 ms 30136 KB Output is correct
17 Correct 955 ms 30052 KB Output is correct
18 Correct 1020 ms 29944 KB Output is correct
19 Correct 1030 ms 29936 KB Output is correct
20 Correct 965 ms 30096 KB Output is correct
21 Correct 940 ms 29984 KB Output is correct
22 Correct 920 ms 30712 KB Output is correct
23 Correct 931 ms 30776 KB Output is correct
24 Correct 1016 ms 30792 KB Output is correct
25 Correct 916 ms 30764 KB Output is correct
26 Correct 984 ms 30976 KB Output is correct
27 Correct 920 ms 30756 KB Output is correct
28 Correct 966 ms 30884 KB Output is correct
29 Correct 939 ms 30864 KB Output is correct
30 Correct 914 ms 30648 KB Output is correct
31 Correct 933 ms 30700 KB Output is correct
32 Correct 916 ms 30852 KB Output is correct
33 Correct 921 ms 30848 KB Output is correct
34 Correct 908 ms 30900 KB Output is correct
35 Correct 904 ms 30928 KB Output is correct
36 Correct 914 ms 30928 KB Output is correct
37 Correct 921 ms 30672 KB Output is correct
38 Correct 916 ms 30744 KB Output is correct
39 Correct 895 ms 30664 KB Output is correct
40 Correct 921 ms 30768 KB Output is correct
41 Correct 915 ms 30656 KB Output is correct
42 Correct 933 ms 30916 KB Output is correct
43 Correct 900 ms 31180 KB Output is correct
44 Correct 905 ms 31044 KB Output is correct
45 Correct 901 ms 31020 KB Output is correct
46 Correct 905 ms 30984 KB Output is correct
47 Correct 902 ms 31128 KB Output is correct
48 Correct 922 ms 31004 KB Output is correct
49 Correct 913 ms 30952 KB Output is correct
50 Correct 900 ms 31172 KB Output is correct
51 Correct 918 ms 31060 KB Output is correct
52 Correct 908 ms 31224 KB Output is correct
53 Correct 921 ms 31044 KB Output is correct
54 Correct 920 ms 31040 KB Output is correct
55 Correct 958 ms 31128 KB Output is correct
56 Correct 955 ms 31024 KB Output is correct
57 Correct 924 ms 30988 KB Output is correct
58 Correct 911 ms 30980 KB Output is correct
59 Correct 969 ms 31040 KB Output is correct
60 Correct 950 ms 30960 KB Output is correct
61 Correct 951 ms 31176 KB Output is correct
62 Correct 966 ms 31036 KB Output is correct
63 Correct 1034 ms 30972 KB Output is correct
64 Correct 991 ms 31356 KB Output is correct
65 Correct 1029 ms 31316 KB Output is correct
66 Correct 1004 ms 31324 KB Output is correct
67 Correct 962 ms 31304 KB Output is correct
68 Correct 964 ms 31372 KB Output is correct
69 Correct 968 ms 31360 KB Output is correct
70 Correct 1000 ms 31404 KB Output is correct
71 Correct 1020 ms 31412 KB Output is correct
72 Correct 958 ms 31320 KB Output is correct
73 Correct 948 ms 31396 KB Output is correct
74 Correct 977 ms 31416 KB Output is correct
75 Correct 961 ms 31400 KB Output is correct
76 Correct 960 ms 31408 KB Output is correct
77 Correct 982 ms 31352 KB Output is correct
78 Correct 960 ms 31508 KB Output is correct
79 Correct 977 ms 31516 KB Output is correct
80 Correct 946 ms 31368 KB Output is correct
81 Correct 959 ms 31304 KB Output is correct
82 Correct 977 ms 31404 KB Output is correct
83 Correct 969 ms 31504 KB Output is correct
84 Correct 969 ms 31404 KB Output is correct