Submission #280403

# Submission time Handle Problem Language Result Execution time Memory
280403 2020-08-22T17:27:10 Z williamMBDK Cubeword (CEOI19_cubeword) C++14
84 / 100
470 ms 17284 KB
#include<bits/stdc++.h>
using namespace std;
#define int long long
//int M = 62;
//string chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
int M = 32;
string chars = "abcdefghijklmnopABCDEFGHIJKLMNOP";
vector<vector<vector<int>>> cnt (11, vector<vector<int>> (M, vector<int> (M)));
signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	map<char,int> mp;
	for(int i = 0; i < M; i++) mp[chars[i]] = i;
	int N; cin >> N;
	set<string> seen;
	for(int i = 0; i < N; i++){
		string s; cin >> s;
		if(seen.count(s)) continue;
		cnt[s.length()][mp[s[0]]][mp[s[s.length() - 1]]]++;
		seen.insert(s);
		reverse(s.begin(), s.end());
		if(seen.count(s)) continue;
		cnt[s.length()][mp[s[0]]][mp[s[s.length() - 1]]]++;
		seen.insert(s);
	}
	int MOD = 998244353;
	int res = 0;
	for(int len = 3; len <= 10; len++){
		vector<vector<vector<int>>> dp (M, vector<vector<int>> (M, vector<int> (M)));
		for(int i = 0; i < M; i++){
			for(int j = 0; j < M; j++){
				for(int k = 0; k < M; k++){
					for(int l = 0; l < M; l++){
						dp[i][j][k] += (cnt[len][i][l] * cnt[len][j][l] * cnt[len][k][l]) % MOD;
						dp[i][j][k] %= MOD;
					}
				}
			}	
		}
		for(int i = 0; i < M; i++){
			for(int j = 0; j < M; j++){
				for(int k = 0; k < M; k++){
					for(int l = 0; l < M; l++){
						res += (dp[i][j][k] * dp[i][j][l] % MOD) * (dp[i][l][k] * dp[j][k][l] % MOD) % MOD;
						/*if(res < 0){
							cout << res << endl;
							cout << dp[i][j][k] << " " << dp[i][j][l] << " " << dp[i][l][k] << " " << dp[j][k][l] << endl;
						}*/
						res %= MOD;
					}
				}
			}	
		}
	}
	cout << res << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 412 ms 15272 KB Output is correct
2 Correct 411 ms 16144 KB Output is correct
3 Correct 409 ms 16168 KB Output is correct
4 Correct 416 ms 16144 KB Output is correct
5 Correct 442 ms 16244 KB Output is correct
6 Correct 413 ms 16164 KB Output is correct
7 Correct 427 ms 16312 KB Output is correct
8 Correct 399 ms 16168 KB Output is correct
9 Correct 398 ms 16224 KB Output is correct
10 Correct 399 ms 16144 KB Output is correct
11 Correct 413 ms 16296 KB Output is correct
12 Correct 409 ms 16148 KB Output is correct
13 Correct 405 ms 16324 KB Output is correct
14 Correct 403 ms 16280 KB Output is correct
15 Correct 393 ms 16168 KB Output is correct
16 Correct 395 ms 16248 KB Output is correct
17 Correct 403 ms 16248 KB Output is correct
18 Correct 408 ms 16376 KB Output is correct
19 Correct 425 ms 16144 KB Output is correct
20 Correct 394 ms 16348 KB Output is correct
21 Correct 412 ms 16144 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 412 ms 15272 KB Output is correct
2 Correct 411 ms 16144 KB Output is correct
3 Correct 409 ms 16168 KB Output is correct
4 Correct 416 ms 16144 KB Output is correct
5 Correct 442 ms 16244 KB Output is correct
6 Correct 413 ms 16164 KB Output is correct
7 Correct 427 ms 16312 KB Output is correct
8 Correct 399 ms 16168 KB Output is correct
9 Correct 398 ms 16224 KB Output is correct
10 Correct 399 ms 16144 KB Output is correct
11 Correct 413 ms 16296 KB Output is correct
12 Correct 409 ms 16148 KB Output is correct
13 Correct 405 ms 16324 KB Output is correct
14 Correct 403 ms 16280 KB Output is correct
15 Correct 393 ms 16168 KB Output is correct
16 Correct 395 ms 16248 KB Output is correct
17 Correct 403 ms 16248 KB Output is correct
18 Correct 408 ms 16376 KB Output is correct
19 Correct 425 ms 16144 KB Output is correct
20 Correct 394 ms 16348 KB Output is correct
21 Correct 412 ms 16144 KB Output is correct
22 Correct 414 ms 16808 KB Output is correct
23 Correct 416 ms 16808 KB Output is correct
24 Correct 430 ms 16960 KB Output is correct
25 Correct 413 ms 16832 KB Output is correct
26 Correct 405 ms 16708 KB Output is correct
27 Correct 422 ms 16712 KB Output is correct
28 Correct 404 ms 16732 KB Output is correct
29 Correct 410 ms 16732 KB Output is correct
30 Correct 470 ms 16784 KB Output is correct
31 Correct 414 ms 16836 KB Output is correct
32 Correct 418 ms 16732 KB Output is correct
33 Correct 450 ms 16772 KB Output is correct
34 Correct 414 ms 16988 KB Output is correct
35 Correct 420 ms 16708 KB Output is correct
36 Correct 417 ms 16820 KB Output is correct
37 Correct 419 ms 16708 KB Output is correct
38 Correct 411 ms 16808 KB Output is correct
39 Correct 412 ms 16760 KB Output is correct
40 Correct 411 ms 16832 KB Output is correct
41 Correct 414 ms 16732 KB Output is correct
42 Correct 413 ms 16732 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 412 ms 15272 KB Output is correct
2 Correct 411 ms 16144 KB Output is correct
3 Correct 409 ms 16168 KB Output is correct
4 Correct 416 ms 16144 KB Output is correct
5 Correct 442 ms 16244 KB Output is correct
6 Correct 413 ms 16164 KB Output is correct
7 Correct 427 ms 16312 KB Output is correct
8 Correct 399 ms 16168 KB Output is correct
9 Correct 398 ms 16224 KB Output is correct
10 Correct 399 ms 16144 KB Output is correct
11 Correct 413 ms 16296 KB Output is correct
12 Correct 409 ms 16148 KB Output is correct
13 Correct 405 ms 16324 KB Output is correct
14 Correct 403 ms 16280 KB Output is correct
15 Correct 393 ms 16168 KB Output is correct
16 Correct 395 ms 16248 KB Output is correct
17 Correct 403 ms 16248 KB Output is correct
18 Correct 408 ms 16376 KB Output is correct
19 Correct 425 ms 16144 KB Output is correct
20 Correct 394 ms 16348 KB Output is correct
21 Correct 412 ms 16144 KB Output is correct
22 Correct 414 ms 16808 KB Output is correct
23 Correct 416 ms 16808 KB Output is correct
24 Correct 430 ms 16960 KB Output is correct
25 Correct 413 ms 16832 KB Output is correct
26 Correct 405 ms 16708 KB Output is correct
27 Correct 422 ms 16712 KB Output is correct
28 Correct 404 ms 16732 KB Output is correct
29 Correct 410 ms 16732 KB Output is correct
30 Correct 470 ms 16784 KB Output is correct
31 Correct 414 ms 16836 KB Output is correct
32 Correct 418 ms 16732 KB Output is correct
33 Correct 450 ms 16772 KB Output is correct
34 Correct 414 ms 16988 KB Output is correct
35 Correct 420 ms 16708 KB Output is correct
36 Correct 417 ms 16820 KB Output is correct
37 Correct 419 ms 16708 KB Output is correct
38 Correct 411 ms 16808 KB Output is correct
39 Correct 412 ms 16760 KB Output is correct
40 Correct 411 ms 16832 KB Output is correct
41 Correct 414 ms 16732 KB Output is correct
42 Correct 413 ms 16732 KB Output is correct
43 Correct 408 ms 16912 KB Output is correct
44 Correct 409 ms 17048 KB Output is correct
45 Correct 407 ms 16996 KB Output is correct
46 Correct 421 ms 16908 KB Output is correct
47 Correct 421 ms 17000 KB Output is correct
48 Correct 428 ms 16988 KB Output is correct
49 Correct 430 ms 16988 KB Output is correct
50 Correct 427 ms 16912 KB Output is correct
51 Correct 406 ms 16936 KB Output is correct
52 Correct 404 ms 16888 KB Output is correct
53 Correct 407 ms 17012 KB Output is correct
54 Correct 405 ms 16912 KB Output is correct
55 Correct 413 ms 16912 KB Output is correct
56 Correct 401 ms 17020 KB Output is correct
57 Correct 402 ms 16892 KB Output is correct
58 Correct 410 ms 16936 KB Output is correct
59 Correct 418 ms 17032 KB Output is correct
60 Correct 410 ms 17092 KB Output is correct
61 Correct 431 ms 16924 KB Output is correct
62 Correct 423 ms 16888 KB Output is correct
63 Correct 425 ms 16988 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 412 ms 15272 KB Output is correct
2 Correct 411 ms 16144 KB Output is correct
3 Correct 409 ms 16168 KB Output is correct
4 Correct 416 ms 16144 KB Output is correct
5 Correct 442 ms 16244 KB Output is correct
6 Correct 413 ms 16164 KB Output is correct
7 Correct 427 ms 16312 KB Output is correct
8 Correct 399 ms 16168 KB Output is correct
9 Correct 398 ms 16224 KB Output is correct
10 Correct 399 ms 16144 KB Output is correct
11 Correct 413 ms 16296 KB Output is correct
12 Correct 409 ms 16148 KB Output is correct
13 Correct 405 ms 16324 KB Output is correct
14 Correct 403 ms 16280 KB Output is correct
15 Correct 393 ms 16168 KB Output is correct
16 Correct 395 ms 16248 KB Output is correct
17 Correct 403 ms 16248 KB Output is correct
18 Correct 408 ms 16376 KB Output is correct
19 Correct 425 ms 16144 KB Output is correct
20 Correct 394 ms 16348 KB Output is correct
21 Correct 412 ms 16144 KB Output is correct
22 Correct 414 ms 16808 KB Output is correct
23 Correct 416 ms 16808 KB Output is correct
24 Correct 430 ms 16960 KB Output is correct
25 Correct 413 ms 16832 KB Output is correct
26 Correct 405 ms 16708 KB Output is correct
27 Correct 422 ms 16712 KB Output is correct
28 Correct 404 ms 16732 KB Output is correct
29 Correct 410 ms 16732 KB Output is correct
30 Correct 470 ms 16784 KB Output is correct
31 Correct 414 ms 16836 KB Output is correct
32 Correct 418 ms 16732 KB Output is correct
33 Correct 450 ms 16772 KB Output is correct
34 Correct 414 ms 16988 KB Output is correct
35 Correct 420 ms 16708 KB Output is correct
36 Correct 417 ms 16820 KB Output is correct
37 Correct 419 ms 16708 KB Output is correct
38 Correct 411 ms 16808 KB Output is correct
39 Correct 412 ms 16760 KB Output is correct
40 Correct 411 ms 16832 KB Output is correct
41 Correct 414 ms 16732 KB Output is correct
42 Correct 413 ms 16732 KB Output is correct
43 Correct 408 ms 16912 KB Output is correct
44 Correct 409 ms 17048 KB Output is correct
45 Correct 407 ms 16996 KB Output is correct
46 Correct 421 ms 16908 KB Output is correct
47 Correct 421 ms 17000 KB Output is correct
48 Correct 428 ms 16988 KB Output is correct
49 Correct 430 ms 16988 KB Output is correct
50 Correct 427 ms 16912 KB Output is correct
51 Correct 406 ms 16936 KB Output is correct
52 Correct 404 ms 16888 KB Output is correct
53 Correct 407 ms 17012 KB Output is correct
54 Correct 405 ms 16912 KB Output is correct
55 Correct 413 ms 16912 KB Output is correct
56 Correct 401 ms 17020 KB Output is correct
57 Correct 402 ms 16892 KB Output is correct
58 Correct 410 ms 16936 KB Output is correct
59 Correct 418 ms 17032 KB Output is correct
60 Correct 410 ms 17092 KB Output is correct
61 Correct 431 ms 16924 KB Output is correct
62 Correct 423 ms 16888 KB Output is correct
63 Correct 425 ms 16988 KB Output is correct
64 Incorrect 427 ms 17284 KB Output isn't correct
65 Halted 0 ms 0 KB -