답안 #946802

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
946802 2024-03-15T05:18:22 Z berr Cubeword (CEOI19_cubeword) C++17
100 / 100
150 ms 19480 KB
//#pragma GCC optimize("O3,unroll-loops")
//#pragma GCC target("avx2")

#include <bits/stdc++.h>
using namespace std;
#define int long long

map<char, int> mp;
int c[11][62][62][62];
int aa[11][63][63];

const int mod = 998244353;

int mul(int x, int y){
	if((x*y)>mod) return x*y%mod;
	return x*y;
}

void sum(int &a){
	if(a>=mod) a-=mod;
}

signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int cnt=0;

	for(int i='a'; i<='z'; i++) mp[i]=cnt++;
	for(int i='A'; i<='Z'; i++)	mp[i]=cnt++;
	for(int i='0'; i<='9'; i++)	mp[i]=cnt++;
	
	int n; cin>>n;
	vector<string> s(n), x;
		
	for(auto &i: s){
		cin >> i;
		string x = i;
		reverse(x.begin(), x.end());
		if(x<i) i=x;
	}

	sort(s.begin(), s.end());
	for(int i=0; i<n; i++){
		if(i==0||s[i]!=s[i-1]) x.push_back(s[i]);
	}

	s=x;
	n = s.size();	

	for(int i=0; i<n; i++){
		string x=s[i];
		reverse(x.begin(), x.end());
		if(x==s[i]) aa[x.size()][mp[x[0]]][mp[x.back()]]++;
		else aa[x.size()][mp[x[0]]][mp[x.back()]]++, aa[x.size()][mp[x.back()]][mp[x[0]]]++;
	}
	for(int i=3; i<=10; i++){
		for(int j=0; j<62; j++){
			for(int a=0; a<62; a++){
				for(int b=a; b<62; b++){
					for(int cc=b; cc<62; cc++){
						c[i][a][b][cc] += mul(aa[i][j][a], mul(aa[i][j][b], aa[i][j][cc]));
						sum(c[i][a][b][cc]);
					}
				}
			}
		}
	}

	int ans=0;
	for(int i=3; i<=10; i++){
		for(int a=0; a<62; a++){
			for(int b=a; b<62; b++){
				for(int cc=b; cc<62; cc++){
					for(int d=cc; d<62; d++){

					int val = 0;
					if(d==a) val = 1;
					else if(d==b) val=4;
					else if(cc==a) val= 4;
					else if(b==a && d==cc) val=6;
					else if(d==cc || b==a) val=12;
					else if(cc==b) val = 12;
					else val=24;

					ans += mul(val, mul(mul(c[i][a][b][cc], c[i][a][b][d]), mul(c[i][b][cc][d], c[i][a][cc][d])));
					sum(ans);
				}
			}
			}
		}

	}

	cout<<ans;

}   
# 결과 실행 시간 메모리 Grader output
1 Correct 117 ms 17952 KB Output is correct
2 Correct 106 ms 17808 KB Output is correct
3 Correct 137 ms 18364 KB Output is correct
4 Correct 106 ms 17792 KB Output is correct
5 Correct 111 ms 18812 KB Output is correct
6 Correct 106 ms 18108 KB Output is correct
7 Correct 109 ms 17856 KB Output is correct
8 Correct 109 ms 18876 KB Output is correct
9 Correct 111 ms 17784 KB Output is correct
10 Correct 107 ms 18524 KB Output is correct
11 Correct 107 ms 17856 KB Output is correct
12 Correct 107 ms 18560 KB Output is correct
13 Correct 110 ms 18028 KB Output is correct
14 Correct 126 ms 17944 KB Output is correct
15 Correct 109 ms 18080 KB Output is correct
16 Correct 116 ms 18296 KB Output is correct
17 Correct 106 ms 17852 KB Output is correct
18 Correct 107 ms 17920 KB Output is correct
19 Correct 112 ms 19140 KB Output is correct
20 Correct 108 ms 17852 KB Output is correct
21 Correct 114 ms 18112 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 117 ms 17952 KB Output is correct
2 Correct 106 ms 17808 KB Output is correct
3 Correct 137 ms 18364 KB Output is correct
4 Correct 106 ms 17792 KB Output is correct
5 Correct 111 ms 18812 KB Output is correct
6 Correct 106 ms 18108 KB Output is correct
7 Correct 109 ms 17856 KB Output is correct
8 Correct 109 ms 18876 KB Output is correct
9 Correct 111 ms 17784 KB Output is correct
10 Correct 107 ms 18524 KB Output is correct
11 Correct 107 ms 17856 KB Output is correct
12 Correct 107 ms 18560 KB Output is correct
13 Correct 110 ms 18028 KB Output is correct
14 Correct 126 ms 17944 KB Output is correct
15 Correct 109 ms 18080 KB Output is correct
16 Correct 116 ms 18296 KB Output is correct
17 Correct 106 ms 17852 KB Output is correct
18 Correct 107 ms 17920 KB Output is correct
19 Correct 112 ms 19140 KB Output is correct
20 Correct 108 ms 17852 KB Output is correct
21 Correct 114 ms 18112 KB Output is correct
22 Correct 106 ms 18088 KB Output is correct
23 Correct 110 ms 17856 KB Output is correct
24 Correct 109 ms 18364 KB Output is correct
25 Correct 108 ms 18364 KB Output is correct
26 Correct 107 ms 17856 KB Output is correct
27 Correct 111 ms 18564 KB Output is correct
28 Correct 115 ms 18528 KB Output is correct
29 Correct 108 ms 17856 KB Output is correct
30 Correct 106 ms 18864 KB Output is correct
31 Correct 107 ms 18108 KB Output is correct
32 Correct 116 ms 17960 KB Output is correct
33 Correct 109 ms 18368 KB Output is correct
34 Correct 118 ms 17956 KB Output is correct
35 Correct 107 ms 18084 KB Output is correct
36 Correct 106 ms 18104 KB Output is correct
37 Correct 108 ms 17928 KB Output is correct
38 Correct 108 ms 18588 KB Output is correct
39 Correct 107 ms 17860 KB Output is correct
40 Correct 147 ms 18364 KB Output is correct
41 Correct 117 ms 18548 KB Output is correct
42 Correct 135 ms 18880 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 117 ms 17952 KB Output is correct
2 Correct 106 ms 17808 KB Output is correct
3 Correct 137 ms 18364 KB Output is correct
4 Correct 106 ms 17792 KB Output is correct
5 Correct 111 ms 18812 KB Output is correct
6 Correct 106 ms 18108 KB Output is correct
7 Correct 109 ms 17856 KB Output is correct
8 Correct 109 ms 18876 KB Output is correct
9 Correct 111 ms 17784 KB Output is correct
10 Correct 107 ms 18524 KB Output is correct
11 Correct 107 ms 17856 KB Output is correct
12 Correct 107 ms 18560 KB Output is correct
13 Correct 110 ms 18028 KB Output is correct
14 Correct 126 ms 17944 KB Output is correct
15 Correct 109 ms 18080 KB Output is correct
16 Correct 116 ms 18296 KB Output is correct
17 Correct 106 ms 17852 KB Output is correct
18 Correct 107 ms 17920 KB Output is correct
19 Correct 112 ms 19140 KB Output is correct
20 Correct 108 ms 17852 KB Output is correct
21 Correct 114 ms 18112 KB Output is correct
22 Correct 106 ms 18088 KB Output is correct
23 Correct 110 ms 17856 KB Output is correct
24 Correct 109 ms 18364 KB Output is correct
25 Correct 108 ms 18364 KB Output is correct
26 Correct 107 ms 17856 KB Output is correct
27 Correct 111 ms 18564 KB Output is correct
28 Correct 115 ms 18528 KB Output is correct
29 Correct 108 ms 17856 KB Output is correct
30 Correct 106 ms 18864 KB Output is correct
31 Correct 107 ms 18108 KB Output is correct
32 Correct 116 ms 17960 KB Output is correct
33 Correct 109 ms 18368 KB Output is correct
34 Correct 118 ms 17956 KB Output is correct
35 Correct 107 ms 18084 KB Output is correct
36 Correct 106 ms 18104 KB Output is correct
37 Correct 108 ms 17928 KB Output is correct
38 Correct 108 ms 18588 KB Output is correct
39 Correct 107 ms 17860 KB Output is correct
40 Correct 147 ms 18364 KB Output is correct
41 Correct 117 ms 18548 KB Output is correct
42 Correct 135 ms 18880 KB Output is correct
43 Correct 133 ms 19096 KB Output is correct
44 Correct 114 ms 18620 KB Output is correct
45 Correct 140 ms 19140 KB Output is correct
46 Correct 112 ms 18108 KB Output is correct
47 Correct 111 ms 18016 KB Output is correct
48 Correct 138 ms 18820 KB Output is correct
49 Correct 118 ms 18156 KB Output is correct
50 Correct 115 ms 18108 KB Output is correct
51 Correct 114 ms 18100 KB Output is correct
52 Correct 119 ms 18312 KB Output is correct
53 Correct 112 ms 18120 KB Output is correct
54 Correct 112 ms 18112 KB Output is correct
55 Correct 118 ms 18400 KB Output is correct
56 Correct 120 ms 19332 KB Output is correct
57 Correct 112 ms 18116 KB Output is correct
58 Correct 116 ms 18112 KB Output is correct
59 Correct 117 ms 18112 KB Output is correct
60 Correct 122 ms 18016 KB Output is correct
61 Correct 111 ms 18112 KB Output is correct
62 Correct 112 ms 18200 KB Output is correct
63 Correct 113 ms 18060 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 117 ms 17952 KB Output is correct
2 Correct 106 ms 17808 KB Output is correct
3 Correct 137 ms 18364 KB Output is correct
4 Correct 106 ms 17792 KB Output is correct
5 Correct 111 ms 18812 KB Output is correct
6 Correct 106 ms 18108 KB Output is correct
7 Correct 109 ms 17856 KB Output is correct
8 Correct 109 ms 18876 KB Output is correct
9 Correct 111 ms 17784 KB Output is correct
10 Correct 107 ms 18524 KB Output is correct
11 Correct 107 ms 17856 KB Output is correct
12 Correct 107 ms 18560 KB Output is correct
13 Correct 110 ms 18028 KB Output is correct
14 Correct 126 ms 17944 KB Output is correct
15 Correct 109 ms 18080 KB Output is correct
16 Correct 116 ms 18296 KB Output is correct
17 Correct 106 ms 17852 KB Output is correct
18 Correct 107 ms 17920 KB Output is correct
19 Correct 112 ms 19140 KB Output is correct
20 Correct 108 ms 17852 KB Output is correct
21 Correct 114 ms 18112 KB Output is correct
22 Correct 106 ms 18088 KB Output is correct
23 Correct 110 ms 17856 KB Output is correct
24 Correct 109 ms 18364 KB Output is correct
25 Correct 108 ms 18364 KB Output is correct
26 Correct 107 ms 17856 KB Output is correct
27 Correct 111 ms 18564 KB Output is correct
28 Correct 115 ms 18528 KB Output is correct
29 Correct 108 ms 17856 KB Output is correct
30 Correct 106 ms 18864 KB Output is correct
31 Correct 107 ms 18108 KB Output is correct
32 Correct 116 ms 17960 KB Output is correct
33 Correct 109 ms 18368 KB Output is correct
34 Correct 118 ms 17956 KB Output is correct
35 Correct 107 ms 18084 KB Output is correct
36 Correct 106 ms 18104 KB Output is correct
37 Correct 108 ms 17928 KB Output is correct
38 Correct 108 ms 18588 KB Output is correct
39 Correct 107 ms 17860 KB Output is correct
40 Correct 147 ms 18364 KB Output is correct
41 Correct 117 ms 18548 KB Output is correct
42 Correct 135 ms 18880 KB Output is correct
43 Correct 133 ms 19096 KB Output is correct
44 Correct 114 ms 18620 KB Output is correct
45 Correct 140 ms 19140 KB Output is correct
46 Correct 112 ms 18108 KB Output is correct
47 Correct 111 ms 18016 KB Output is correct
48 Correct 138 ms 18820 KB Output is correct
49 Correct 118 ms 18156 KB Output is correct
50 Correct 115 ms 18108 KB Output is correct
51 Correct 114 ms 18100 KB Output is correct
52 Correct 119 ms 18312 KB Output is correct
53 Correct 112 ms 18120 KB Output is correct
54 Correct 112 ms 18112 KB Output is correct
55 Correct 118 ms 18400 KB Output is correct
56 Correct 120 ms 19332 KB Output is correct
57 Correct 112 ms 18116 KB Output is correct
58 Correct 116 ms 18112 KB Output is correct
59 Correct 117 ms 18112 KB Output is correct
60 Correct 122 ms 18016 KB Output is correct
61 Correct 111 ms 18112 KB Output is correct
62 Correct 112 ms 18200 KB Output is correct
63 Correct 113 ms 18060 KB Output is correct
64 Correct 124 ms 18068 KB Output is correct
65 Correct 121 ms 18508 KB Output is correct
66 Correct 124 ms 18108 KB Output is correct
67 Correct 150 ms 18112 KB Output is correct
68 Correct 133 ms 18036 KB Output is correct
69 Correct 124 ms 18116 KB Output is correct
70 Correct 127 ms 18044 KB Output is correct
71 Correct 136 ms 18088 KB Output is correct
72 Correct 123 ms 18112 KB Output is correct
73 Correct 131 ms 18196 KB Output is correct
74 Correct 128 ms 18036 KB Output is correct
75 Correct 124 ms 18056 KB Output is correct
76 Correct 129 ms 18060 KB Output is correct
77 Correct 132 ms 19480 KB Output is correct
78 Correct 130 ms 18048 KB Output is correct
79 Correct 127 ms 18492 KB Output is correct
80 Correct 133 ms 18056 KB Output is correct
81 Correct 136 ms 18896 KB Output is correct
82 Correct 126 ms 18112 KB Output is correct
83 Correct 124 ms 18108 KB Output is correct
84 Correct 122 ms 18112 KB Output is correct