답안 #945962

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
945962 2024-03-14T09:09:22 Z Minbaev Cubeword (CEOI19_cubeword) C++17
100 / 100
337 ms 28556 KB
#include <bits/stdc++.h>
 
using namespace std;
 
#define int long long
#define all(x) x.begin(),x.end()
#define pb push_back
 
const int N=1e6 + 5	;
const int inf = 1e18 + 7;
const int mod = 998244353;
 
int g[11][63][63][63];
int v[11][63][63];
int ans = 0;
int n,m,k;
 
map<char,int>mps;
 
vector<int>vs;
 
int ii(char ch){
	return mps[ch];	
}
 
void dfs(int i){
	
	
	
}
int cnt = 0;
 
void solve(){
	
	cin >> n;
	map<string,int>mp;
	
	for(int i = 1;i<=n;i++){
		
		string a;
		cin >> a;
		
		if(mp[a] == 0){
			v[a.size()][ii(a[0])][ii(a[a.size()-1])] += 1;
		}
		mp[a] += 1;
		reverse(all(a));
		
		if(mp[a] == 0){
			v[a.size()][ii(a[0])][ii(a[a.size()-1])] += 1;
		}
		mp[a] += 1;
	}
	for(int sz = 3;sz<=10;sz++){
		for(int i = 0;i<cnt;i++){
			for(int j = 0;j<cnt;j++){
				for(int l = j;l<cnt;l++){
					for(int u = l;u<cnt;u++){
						g[sz][j][l][u] += ((v[sz][i][j]*v[sz][i][l]) % mod) * (v[sz][i][u])% mod;
						g[sz][j][l][u] %= mod;
					}
				}
			}
		}
	}//da ya spizdil resheniye, glavnoye chundumda tuuraby?
	vector<int>fac(5,1);
	fac[2] = 2;fac[3] = 6;fac[4] = 24;
	for(int sz = 3;sz<=10;sz++){
		for(int i = 0;i<cnt;i++){
			for(int j = i;j<cnt;j++){
				for(int l = j;l<cnt;l++){
					for(int u = l;u<cnt;u++){
						
						int ile=24,c=1;
                        if(j!=i)
                        {
                            ile/=fac[c];
                            c=1;
                        }
                        else c++;
                        if(l!=j)
                        {
                            ile/=fac[c];
                            c=1;
                        }
                        else c++;
                        if(l!=u)
                        {
                            ile/=fac[c];
                            c=1;
                        }
                        else c++;
                        ile/=fac[c];
						
						ans += (((g[sz][i][j][l] * g[sz][i][j][u])% mod)  * g[sz][i][l][u]) % mod * g[sz][j][l][u] % mod*ile%mod;
						ans %= mod;
					}
				}
			}
		}
	}
	
	cout << ans << '\n';
	
}
/*
 
*/
signed main()
{
	for(int i = 0;i<='z'-'a';i+=1){
		mps['a'+i] = cnt++;
	}
	for(int i = 0;i<='z'-'a';i+=1){
		mps['A'+i] = cnt++;
	}
	for(int i = 0;i<=9;i++){
		mps['0'+i] = cnt++;
	}
	
	ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
	int tt=1;//cin>>tt>>n;
	while(tt--)solve();
 
}
# 결과 실행 시간 메모리 Grader output
1 Correct 295 ms 27216 KB Output is correct
2 Correct 324 ms 27476 KB Output is correct
3 Correct 296 ms 27288 KB Output is correct
4 Correct 292 ms 27348 KB Output is correct
5 Correct 307 ms 27264 KB Output is correct
6 Correct 314 ms 27108 KB Output is correct
7 Correct 301 ms 27440 KB Output is correct
8 Correct 295 ms 27220 KB Output is correct
9 Correct 295 ms 27468 KB Output is correct
10 Correct 298 ms 27216 KB Output is correct
11 Correct 327 ms 27220 KB Output is correct
12 Correct 304 ms 27372 KB Output is correct
13 Correct 301 ms 27220 KB Output is correct
14 Correct 332 ms 27216 KB Output is correct
15 Correct 309 ms 27348 KB Output is correct
16 Correct 313 ms 27216 KB Output is correct
17 Correct 292 ms 27216 KB Output is correct
18 Correct 306 ms 27460 KB Output is correct
19 Correct 299 ms 27216 KB Output is correct
20 Correct 303 ms 27556 KB Output is correct
21 Correct 297 ms 27220 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 295 ms 27216 KB Output is correct
2 Correct 324 ms 27476 KB Output is correct
3 Correct 296 ms 27288 KB Output is correct
4 Correct 292 ms 27348 KB Output is correct
5 Correct 307 ms 27264 KB Output is correct
6 Correct 314 ms 27108 KB Output is correct
7 Correct 301 ms 27440 KB Output is correct
8 Correct 295 ms 27220 KB Output is correct
9 Correct 295 ms 27468 KB Output is correct
10 Correct 298 ms 27216 KB Output is correct
11 Correct 327 ms 27220 KB Output is correct
12 Correct 304 ms 27372 KB Output is correct
13 Correct 301 ms 27220 KB Output is correct
14 Correct 332 ms 27216 KB Output is correct
15 Correct 309 ms 27348 KB Output is correct
16 Correct 313 ms 27216 KB Output is correct
17 Correct 292 ms 27216 KB Output is correct
18 Correct 306 ms 27460 KB Output is correct
19 Correct 299 ms 27216 KB Output is correct
20 Correct 303 ms 27556 KB Output is correct
21 Correct 297 ms 27220 KB Output is correct
22 Correct 311 ms 27956 KB Output is correct
23 Correct 307 ms 27728 KB Output is correct
24 Correct 316 ms 27856 KB Output is correct
25 Correct 300 ms 27724 KB Output is correct
26 Correct 331 ms 27728 KB Output is correct
27 Correct 326 ms 27720 KB Output is correct
28 Correct 312 ms 27760 KB Output is correct
29 Correct 312 ms 27932 KB Output is correct
30 Correct 301 ms 27728 KB Output is correct
31 Correct 309 ms 27812 KB Output is correct
32 Correct 313 ms 27824 KB Output is correct
33 Correct 305 ms 27728 KB Output is correct
34 Correct 293 ms 27728 KB Output is correct
35 Correct 309 ms 27732 KB Output is correct
36 Correct 305 ms 27988 KB Output is correct
37 Correct 293 ms 27944 KB Output is correct
38 Correct 299 ms 27948 KB Output is correct
39 Correct 312 ms 27920 KB Output is correct
40 Correct 296 ms 27944 KB Output is correct
41 Correct 308 ms 27700 KB Output is correct
42 Correct 306 ms 27896 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 295 ms 27216 KB Output is correct
2 Correct 324 ms 27476 KB Output is correct
3 Correct 296 ms 27288 KB Output is correct
4 Correct 292 ms 27348 KB Output is correct
5 Correct 307 ms 27264 KB Output is correct
6 Correct 314 ms 27108 KB Output is correct
7 Correct 301 ms 27440 KB Output is correct
8 Correct 295 ms 27220 KB Output is correct
9 Correct 295 ms 27468 KB Output is correct
10 Correct 298 ms 27216 KB Output is correct
11 Correct 327 ms 27220 KB Output is correct
12 Correct 304 ms 27372 KB Output is correct
13 Correct 301 ms 27220 KB Output is correct
14 Correct 332 ms 27216 KB Output is correct
15 Correct 309 ms 27348 KB Output is correct
16 Correct 313 ms 27216 KB Output is correct
17 Correct 292 ms 27216 KB Output is correct
18 Correct 306 ms 27460 KB Output is correct
19 Correct 299 ms 27216 KB Output is correct
20 Correct 303 ms 27556 KB Output is correct
21 Correct 297 ms 27220 KB Output is correct
22 Correct 311 ms 27956 KB Output is correct
23 Correct 307 ms 27728 KB Output is correct
24 Correct 316 ms 27856 KB Output is correct
25 Correct 300 ms 27724 KB Output is correct
26 Correct 331 ms 27728 KB Output is correct
27 Correct 326 ms 27720 KB Output is correct
28 Correct 312 ms 27760 KB Output is correct
29 Correct 312 ms 27932 KB Output is correct
30 Correct 301 ms 27728 KB Output is correct
31 Correct 309 ms 27812 KB Output is correct
32 Correct 313 ms 27824 KB Output is correct
33 Correct 305 ms 27728 KB Output is correct
34 Correct 293 ms 27728 KB Output is correct
35 Correct 309 ms 27732 KB Output is correct
36 Correct 305 ms 27988 KB Output is correct
37 Correct 293 ms 27944 KB Output is correct
38 Correct 299 ms 27948 KB Output is correct
39 Correct 312 ms 27920 KB Output is correct
40 Correct 296 ms 27944 KB Output is correct
41 Correct 308 ms 27700 KB Output is correct
42 Correct 306 ms 27896 KB Output is correct
43 Correct 306 ms 28156 KB Output is correct
44 Correct 311 ms 27984 KB Output is correct
45 Correct 309 ms 27988 KB Output is correct
46 Correct 297 ms 27984 KB Output is correct
47 Correct 301 ms 28140 KB Output is correct
48 Correct 337 ms 28160 KB Output is correct
49 Correct 315 ms 28244 KB Output is correct
50 Correct 292 ms 27984 KB Output is correct
51 Correct 307 ms 28144 KB Output is correct
52 Correct 295 ms 27908 KB Output is correct
53 Correct 301 ms 27984 KB Output is correct
54 Correct 310 ms 28108 KB Output is correct
55 Correct 314 ms 28148 KB Output is correct
56 Correct 308 ms 28208 KB Output is correct
57 Correct 296 ms 27984 KB Output is correct
58 Correct 309 ms 28152 KB Output is correct
59 Correct 298 ms 27984 KB Output is correct
60 Correct 319 ms 28240 KB Output is correct
61 Correct 297 ms 28148 KB Output is correct
62 Correct 302 ms 27992 KB Output is correct
63 Correct 314 ms 28204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 295 ms 27216 KB Output is correct
2 Correct 324 ms 27476 KB Output is correct
3 Correct 296 ms 27288 KB Output is correct
4 Correct 292 ms 27348 KB Output is correct
5 Correct 307 ms 27264 KB Output is correct
6 Correct 314 ms 27108 KB Output is correct
7 Correct 301 ms 27440 KB Output is correct
8 Correct 295 ms 27220 KB Output is correct
9 Correct 295 ms 27468 KB Output is correct
10 Correct 298 ms 27216 KB Output is correct
11 Correct 327 ms 27220 KB Output is correct
12 Correct 304 ms 27372 KB Output is correct
13 Correct 301 ms 27220 KB Output is correct
14 Correct 332 ms 27216 KB Output is correct
15 Correct 309 ms 27348 KB Output is correct
16 Correct 313 ms 27216 KB Output is correct
17 Correct 292 ms 27216 KB Output is correct
18 Correct 306 ms 27460 KB Output is correct
19 Correct 299 ms 27216 KB Output is correct
20 Correct 303 ms 27556 KB Output is correct
21 Correct 297 ms 27220 KB Output is correct
22 Correct 311 ms 27956 KB Output is correct
23 Correct 307 ms 27728 KB Output is correct
24 Correct 316 ms 27856 KB Output is correct
25 Correct 300 ms 27724 KB Output is correct
26 Correct 331 ms 27728 KB Output is correct
27 Correct 326 ms 27720 KB Output is correct
28 Correct 312 ms 27760 KB Output is correct
29 Correct 312 ms 27932 KB Output is correct
30 Correct 301 ms 27728 KB Output is correct
31 Correct 309 ms 27812 KB Output is correct
32 Correct 313 ms 27824 KB Output is correct
33 Correct 305 ms 27728 KB Output is correct
34 Correct 293 ms 27728 KB Output is correct
35 Correct 309 ms 27732 KB Output is correct
36 Correct 305 ms 27988 KB Output is correct
37 Correct 293 ms 27944 KB Output is correct
38 Correct 299 ms 27948 KB Output is correct
39 Correct 312 ms 27920 KB Output is correct
40 Correct 296 ms 27944 KB Output is correct
41 Correct 308 ms 27700 KB Output is correct
42 Correct 306 ms 27896 KB Output is correct
43 Correct 306 ms 28156 KB Output is correct
44 Correct 311 ms 27984 KB Output is correct
45 Correct 309 ms 27988 KB Output is correct
46 Correct 297 ms 27984 KB Output is correct
47 Correct 301 ms 28140 KB Output is correct
48 Correct 337 ms 28160 KB Output is correct
49 Correct 315 ms 28244 KB Output is correct
50 Correct 292 ms 27984 KB Output is correct
51 Correct 307 ms 28144 KB Output is correct
52 Correct 295 ms 27908 KB Output is correct
53 Correct 301 ms 27984 KB Output is correct
54 Correct 310 ms 28108 KB Output is correct
55 Correct 314 ms 28148 KB Output is correct
56 Correct 308 ms 28208 KB Output is correct
57 Correct 296 ms 27984 KB Output is correct
58 Correct 309 ms 28152 KB Output is correct
59 Correct 298 ms 27984 KB Output is correct
60 Correct 319 ms 28240 KB Output is correct
61 Correct 297 ms 28148 KB Output is correct
62 Correct 302 ms 27992 KB Output is correct
63 Correct 314 ms 28204 KB Output is correct
64 Correct 309 ms 28240 KB Output is correct
65 Correct 309 ms 28388 KB Output is correct
66 Correct 306 ms 28276 KB Output is correct
67 Correct 302 ms 28548 KB Output is correct
68 Correct 301 ms 28244 KB Output is correct
69 Correct 301 ms 28244 KB Output is correct
70 Correct 300 ms 28240 KB Output is correct
71 Correct 309 ms 28240 KB Output is correct
72 Correct 323 ms 28380 KB Output is correct
73 Correct 295 ms 28292 KB Output is correct
74 Correct 316 ms 28496 KB Output is correct
75 Correct 299 ms 28388 KB Output is correct
76 Correct 303 ms 28396 KB Output is correct
77 Correct 305 ms 28188 KB Output is correct
78 Correct 302 ms 28228 KB Output is correct
79 Correct 309 ms 28556 KB Output is correct
80 Correct 299 ms 28244 KB Output is correct
81 Correct 313 ms 28496 KB Output is correct
82 Correct 307 ms 28396 KB Output is correct
83 Correct 315 ms 28400 KB Output is correct
84 Correct 308 ms 28240 KB Output is correct