답안 #594054

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
594054 2022-07-12T02:42:20 Z penguinhacker Cubeword (CEOI19_cubeword) C++17
100 / 100
220 ms 9260 KB
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ar array

const int mxN=1e5, K=62, M=998244353;
int n;
string s[mxN];
ll cnt[K][K], dp[K][K][K];

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n;
	for (int i=0; i<n; ++i)
		cin >> s[i];
	ll ans=0;
	for (int i=3; i<=10; ++i) {
		set<string> st;
		for (int j=0; j<n; ++j)
			if (s[j].size()==i)
				for (int rep=0; rep<2; ++rep) {
					st.insert(s[j]);
					reverse(s[j].begin(), s[j].end());
				}
		memset(cnt, 0, sizeof(cnt));
		for (string x : st) {
			int a='a'<=x[0]&&x[0]<='z'?x[0]-'a':'A'<=x[0]&&x[0]<='Z'?26+x[0]-'A':52+x[0]-'0';
			int b='a'<=x.back()&&x.back()<='z'?x.back()-'a':'A'<=x.back()&&x.back()<='Z'?26+x.back()-'A':52+x.back()-'0';
			++cnt[a][b];
		}
		memset(dp, 0, sizeof(dp));
		for (int a=0; a<K; ++a)
			for (int b=a; b<K; ++b)
				for (int c=b; c<K; ++c)
					for (int d=0; d<K; ++d)
						dp[a][b][c]=(dp[a][b][c]+cnt[d][a]*cnt[d][b]*cnt[d][c])%M;
		auto Consider=[&](int a, int b, int c, int d, int mul) {
			ans=(ans+mul*dp[a][b][c]%M*dp[a][b][d]%M*dp[a][c][d]%M*dp[b][c][d])%M;
		};
		//cout << dp['r'-'a']['r'-'a']['r'-'a'] << endl;
		for (int a=0; a<K; ++a) {
			Consider(a, a, a, a, 1);
			for (int b=a+1; b<K; ++b) {
				Consider(a, a, a, b, 4);
				Consider(a, a, b, b, 6);
				Consider(a, b, b, b, 4);
				for (int c=b+1; c<K; ++c) {
					Consider(a, b, c, c, 12);
					Consider(a, b, b, c, 12);
					Consider(a, a, b, c, 12);
					for (int d=c+1; d<K; ++d)
						Consider(a, b, c, d, 24);
				}
			}
		}
	}
	cout << ans;
	return 0;
}

Compilation message

cubeword.cpp: In function 'int main()':
cubeword.cpp:22:19: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   22 |    if (s[j].size()==i)
      |        ~~~~~~~~~~~^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 189 ms 9160 KB Output is correct
2 Correct 197 ms 9104 KB Output is correct
3 Correct 192 ms 9160 KB Output is correct
4 Correct 188 ms 9212 KB Output is correct
5 Correct 207 ms 9224 KB Output is correct
6 Correct 191 ms 9148 KB Output is correct
7 Correct 187 ms 9168 KB Output is correct
8 Correct 206 ms 9096 KB Output is correct
9 Correct 186 ms 9180 KB Output is correct
10 Correct 199 ms 9108 KB Output is correct
11 Correct 200 ms 9184 KB Output is correct
12 Correct 184 ms 9080 KB Output is correct
13 Correct 194 ms 9168 KB Output is correct
14 Correct 190 ms 9260 KB Output is correct
15 Correct 195 ms 9196 KB Output is correct
16 Correct 199 ms 9076 KB Output is correct
17 Correct 183 ms 9096 KB Output is correct
18 Correct 186 ms 9164 KB Output is correct
19 Correct 199 ms 9164 KB Output is correct
20 Correct 188 ms 9116 KB Output is correct
21 Correct 186 ms 9196 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 189 ms 9160 KB Output is correct
2 Correct 197 ms 9104 KB Output is correct
3 Correct 192 ms 9160 KB Output is correct
4 Correct 188 ms 9212 KB Output is correct
5 Correct 207 ms 9224 KB Output is correct
6 Correct 191 ms 9148 KB Output is correct
7 Correct 187 ms 9168 KB Output is correct
8 Correct 206 ms 9096 KB Output is correct
9 Correct 186 ms 9180 KB Output is correct
10 Correct 199 ms 9108 KB Output is correct
11 Correct 200 ms 9184 KB Output is correct
12 Correct 184 ms 9080 KB Output is correct
13 Correct 194 ms 9168 KB Output is correct
14 Correct 190 ms 9260 KB Output is correct
15 Correct 195 ms 9196 KB Output is correct
16 Correct 199 ms 9076 KB Output is correct
17 Correct 183 ms 9096 KB Output is correct
18 Correct 186 ms 9164 KB Output is correct
19 Correct 199 ms 9164 KB Output is correct
20 Correct 188 ms 9116 KB Output is correct
21 Correct 186 ms 9196 KB Output is correct
22 Correct 212 ms 8308 KB Output is correct
23 Correct 192 ms 8316 KB Output is correct
24 Correct 186 ms 8340 KB Output is correct
25 Correct 204 ms 8292 KB Output is correct
26 Correct 187 ms 8284 KB Output is correct
27 Correct 187 ms 8288 KB Output is correct
28 Correct 198 ms 8276 KB Output is correct
29 Correct 195 ms 8268 KB Output is correct
30 Correct 183 ms 8224 KB Output is correct
31 Correct 195 ms 8296 KB Output is correct
32 Correct 220 ms 8176 KB Output is correct
33 Correct 199 ms 8232 KB Output is correct
34 Correct 207 ms 8268 KB Output is correct
35 Correct 186 ms 8288 KB Output is correct
36 Correct 197 ms 8296 KB Output is correct
37 Correct 194 ms 8356 KB Output is correct
38 Correct 191 ms 8332 KB Output is correct
39 Correct 199 ms 8356 KB Output is correct
40 Correct 210 ms 8232 KB Output is correct
41 Correct 186 ms 8336 KB Output is correct
42 Correct 187 ms 8304 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 189 ms 9160 KB Output is correct
2 Correct 197 ms 9104 KB Output is correct
3 Correct 192 ms 9160 KB Output is correct
4 Correct 188 ms 9212 KB Output is correct
5 Correct 207 ms 9224 KB Output is correct
6 Correct 191 ms 9148 KB Output is correct
7 Correct 187 ms 9168 KB Output is correct
8 Correct 206 ms 9096 KB Output is correct
9 Correct 186 ms 9180 KB Output is correct
10 Correct 199 ms 9108 KB Output is correct
11 Correct 200 ms 9184 KB Output is correct
12 Correct 184 ms 9080 KB Output is correct
13 Correct 194 ms 9168 KB Output is correct
14 Correct 190 ms 9260 KB Output is correct
15 Correct 195 ms 9196 KB Output is correct
16 Correct 199 ms 9076 KB Output is correct
17 Correct 183 ms 9096 KB Output is correct
18 Correct 186 ms 9164 KB Output is correct
19 Correct 199 ms 9164 KB Output is correct
20 Correct 188 ms 9116 KB Output is correct
21 Correct 186 ms 9196 KB Output is correct
22 Correct 212 ms 8308 KB Output is correct
23 Correct 192 ms 8316 KB Output is correct
24 Correct 186 ms 8340 KB Output is correct
25 Correct 204 ms 8292 KB Output is correct
26 Correct 187 ms 8284 KB Output is correct
27 Correct 187 ms 8288 KB Output is correct
28 Correct 198 ms 8276 KB Output is correct
29 Correct 195 ms 8268 KB Output is correct
30 Correct 183 ms 8224 KB Output is correct
31 Correct 195 ms 8296 KB Output is correct
32 Correct 220 ms 8176 KB Output is correct
33 Correct 199 ms 8232 KB Output is correct
34 Correct 207 ms 8268 KB Output is correct
35 Correct 186 ms 8288 KB Output is correct
36 Correct 197 ms 8296 KB Output is correct
37 Correct 194 ms 8356 KB Output is correct
38 Correct 191 ms 8332 KB Output is correct
39 Correct 199 ms 8356 KB Output is correct
40 Correct 210 ms 8232 KB Output is correct
41 Correct 186 ms 8336 KB Output is correct
42 Correct 187 ms 8304 KB Output is correct
43 Correct 186 ms 8088 KB Output is correct
44 Correct 201 ms 8072 KB Output is correct
45 Correct 195 ms 8052 KB Output is correct
46 Correct 181 ms 8088 KB Output is correct
47 Correct 189 ms 8184 KB Output is correct
48 Correct 212 ms 8180 KB Output is correct
49 Correct 183 ms 8068 KB Output is correct
50 Correct 189 ms 8088 KB Output is correct
51 Correct 207 ms 8196 KB Output is correct
52 Correct 181 ms 8064 KB Output is correct
53 Correct 190 ms 8088 KB Output is correct
54 Correct 216 ms 8212 KB Output is correct
55 Correct 184 ms 8092 KB Output is correct
56 Correct 184 ms 8156 KB Output is correct
57 Correct 186 ms 8036 KB Output is correct
58 Correct 199 ms 8072 KB Output is correct
59 Correct 182 ms 8056 KB Output is correct
60 Correct 193 ms 8092 KB Output is correct
61 Correct 203 ms 8032 KB Output is correct
62 Correct 182 ms 8060 KB Output is correct
63 Correct 189 ms 8084 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 189 ms 9160 KB Output is correct
2 Correct 197 ms 9104 KB Output is correct
3 Correct 192 ms 9160 KB Output is correct
4 Correct 188 ms 9212 KB Output is correct
5 Correct 207 ms 9224 KB Output is correct
6 Correct 191 ms 9148 KB Output is correct
7 Correct 187 ms 9168 KB Output is correct
8 Correct 206 ms 9096 KB Output is correct
9 Correct 186 ms 9180 KB Output is correct
10 Correct 199 ms 9108 KB Output is correct
11 Correct 200 ms 9184 KB Output is correct
12 Correct 184 ms 9080 KB Output is correct
13 Correct 194 ms 9168 KB Output is correct
14 Correct 190 ms 9260 KB Output is correct
15 Correct 195 ms 9196 KB Output is correct
16 Correct 199 ms 9076 KB Output is correct
17 Correct 183 ms 9096 KB Output is correct
18 Correct 186 ms 9164 KB Output is correct
19 Correct 199 ms 9164 KB Output is correct
20 Correct 188 ms 9116 KB Output is correct
21 Correct 186 ms 9196 KB Output is correct
22 Correct 212 ms 8308 KB Output is correct
23 Correct 192 ms 8316 KB Output is correct
24 Correct 186 ms 8340 KB Output is correct
25 Correct 204 ms 8292 KB Output is correct
26 Correct 187 ms 8284 KB Output is correct
27 Correct 187 ms 8288 KB Output is correct
28 Correct 198 ms 8276 KB Output is correct
29 Correct 195 ms 8268 KB Output is correct
30 Correct 183 ms 8224 KB Output is correct
31 Correct 195 ms 8296 KB Output is correct
32 Correct 220 ms 8176 KB Output is correct
33 Correct 199 ms 8232 KB Output is correct
34 Correct 207 ms 8268 KB Output is correct
35 Correct 186 ms 8288 KB Output is correct
36 Correct 197 ms 8296 KB Output is correct
37 Correct 194 ms 8356 KB Output is correct
38 Correct 191 ms 8332 KB Output is correct
39 Correct 199 ms 8356 KB Output is correct
40 Correct 210 ms 8232 KB Output is correct
41 Correct 186 ms 8336 KB Output is correct
42 Correct 187 ms 8304 KB Output is correct
43 Correct 186 ms 8088 KB Output is correct
44 Correct 201 ms 8072 KB Output is correct
45 Correct 195 ms 8052 KB Output is correct
46 Correct 181 ms 8088 KB Output is correct
47 Correct 189 ms 8184 KB Output is correct
48 Correct 212 ms 8180 KB Output is correct
49 Correct 183 ms 8068 KB Output is correct
50 Correct 189 ms 8088 KB Output is correct
51 Correct 207 ms 8196 KB Output is correct
52 Correct 181 ms 8064 KB Output is correct
53 Correct 190 ms 8088 KB Output is correct
54 Correct 216 ms 8212 KB Output is correct
55 Correct 184 ms 8092 KB Output is correct
56 Correct 184 ms 8156 KB Output is correct
57 Correct 186 ms 8036 KB Output is correct
58 Correct 199 ms 8072 KB Output is correct
59 Correct 182 ms 8056 KB Output is correct
60 Correct 193 ms 8092 KB Output is correct
61 Correct 203 ms 8032 KB Output is correct
62 Correct 182 ms 8060 KB Output is correct
63 Correct 189 ms 8084 KB Output is correct
64 Correct 213 ms 7944 KB Output is correct
65 Correct 187 ms 8028 KB Output is correct
66 Correct 194 ms 8048 KB Output is correct
67 Correct 191 ms 8048 KB Output is correct
68 Correct 184 ms 8052 KB Output is correct
69 Correct 194 ms 8036 KB Output is correct
70 Correct 205 ms 8052 KB Output is correct
71 Correct 188 ms 7920 KB Output is correct
72 Correct 187 ms 8012 KB Output is correct
73 Correct 205 ms 8012 KB Output is correct
74 Correct 193 ms 8028 KB Output is correct
75 Correct 182 ms 8044 KB Output is correct
76 Correct 204 ms 8060 KB Output is correct
77 Correct 182 ms 8048 KB Output is correct
78 Correct 183 ms 8048 KB Output is correct
79 Correct 213 ms 8088 KB Output is correct
80 Correct 186 ms 8032 KB Output is correct
81 Correct 188 ms 8068 KB Output is correct
82 Correct 211 ms 8040 KB Output is correct
83 Correct 192 ms 8068 KB Output is correct
84 Correct 187 ms 8012 KB Output is correct