답안 #945967

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
945967 2024-03-14T09:11:33 Z vjudge1 Cubeword (CEOI19_cubeword) C++17
100 / 100
373 ms 27732 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 305 ms 26284 KB Output is correct
2 Correct 295 ms 26492 KB Output is correct
3 Correct 316 ms 26664 KB Output is correct
4 Correct 309 ms 26488 KB Output is correct
5 Correct 361 ms 26548 KB Output is correct
6 Correct 294 ms 26500 KB Output is correct
7 Correct 313 ms 26516 KB Output is correct
8 Correct 306 ms 26504 KB Output is correct
9 Correct 314 ms 26376 KB Output is correct
10 Correct 305 ms 26376 KB Output is correct
11 Correct 303 ms 26328 KB Output is correct
12 Correct 309 ms 26484 KB Output is correct
13 Correct 316 ms 26516 KB Output is correct
14 Correct 341 ms 26756 KB Output is correct
15 Correct 318 ms 26504 KB Output is correct
16 Correct 314 ms 26496 KB Output is correct
17 Correct 316 ms 26504 KB Output is correct
18 Correct 312 ms 26500 KB Output is correct
19 Correct 333 ms 26492 KB Output is correct
20 Correct 325 ms 26304 KB Output is correct
21 Correct 314 ms 26268 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 305 ms 26284 KB Output is correct
2 Correct 295 ms 26492 KB Output is correct
3 Correct 316 ms 26664 KB Output is correct
4 Correct 309 ms 26488 KB Output is correct
5 Correct 361 ms 26548 KB Output is correct
6 Correct 294 ms 26500 KB Output is correct
7 Correct 313 ms 26516 KB Output is correct
8 Correct 306 ms 26504 KB Output is correct
9 Correct 314 ms 26376 KB Output is correct
10 Correct 305 ms 26376 KB Output is correct
11 Correct 303 ms 26328 KB Output is correct
12 Correct 309 ms 26484 KB Output is correct
13 Correct 316 ms 26516 KB Output is correct
14 Correct 341 ms 26756 KB Output is correct
15 Correct 318 ms 26504 KB Output is correct
16 Correct 314 ms 26496 KB Output is correct
17 Correct 316 ms 26504 KB Output is correct
18 Correct 312 ms 26500 KB Output is correct
19 Correct 333 ms 26492 KB Output is correct
20 Correct 325 ms 26304 KB Output is correct
21 Correct 314 ms 26268 KB Output is correct
22 Correct 309 ms 27068 KB Output is correct
23 Correct 333 ms 27168 KB Output is correct
24 Correct 313 ms 27180 KB Output is correct
25 Correct 311 ms 27176 KB Output is correct
26 Correct 311 ms 27100 KB Output is correct
27 Correct 309 ms 27040 KB Output is correct
28 Correct 315 ms 26976 KB Output is correct
29 Correct 323 ms 27184 KB Output is correct
30 Correct 346 ms 27152 KB Output is correct
31 Correct 305 ms 27324 KB Output is correct
32 Correct 321 ms 27160 KB Output is correct
33 Correct 333 ms 27012 KB Output is correct
34 Correct 322 ms 26956 KB Output is correct
35 Correct 326 ms 27168 KB Output is correct
36 Correct 330 ms 26960 KB Output is correct
37 Correct 326 ms 27168 KB Output is correct
38 Correct 298 ms 27036 KB Output is correct
39 Correct 313 ms 27024 KB Output is correct
40 Correct 313 ms 27144 KB Output is correct
41 Correct 297 ms 27176 KB Output is correct
42 Correct 299 ms 27180 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 305 ms 26284 KB Output is correct
2 Correct 295 ms 26492 KB Output is correct
3 Correct 316 ms 26664 KB Output is correct
4 Correct 309 ms 26488 KB Output is correct
5 Correct 361 ms 26548 KB Output is correct
6 Correct 294 ms 26500 KB Output is correct
7 Correct 313 ms 26516 KB Output is correct
8 Correct 306 ms 26504 KB Output is correct
9 Correct 314 ms 26376 KB Output is correct
10 Correct 305 ms 26376 KB Output is correct
11 Correct 303 ms 26328 KB Output is correct
12 Correct 309 ms 26484 KB Output is correct
13 Correct 316 ms 26516 KB Output is correct
14 Correct 341 ms 26756 KB Output is correct
15 Correct 318 ms 26504 KB Output is correct
16 Correct 314 ms 26496 KB Output is correct
17 Correct 316 ms 26504 KB Output is correct
18 Correct 312 ms 26500 KB Output is correct
19 Correct 333 ms 26492 KB Output is correct
20 Correct 325 ms 26304 KB Output is correct
21 Correct 314 ms 26268 KB Output is correct
22 Correct 309 ms 27068 KB Output is correct
23 Correct 333 ms 27168 KB Output is correct
24 Correct 313 ms 27180 KB Output is correct
25 Correct 311 ms 27176 KB Output is correct
26 Correct 311 ms 27100 KB Output is correct
27 Correct 309 ms 27040 KB Output is correct
28 Correct 315 ms 26976 KB Output is correct
29 Correct 323 ms 27184 KB Output is correct
30 Correct 346 ms 27152 KB Output is correct
31 Correct 305 ms 27324 KB Output is correct
32 Correct 321 ms 27160 KB Output is correct
33 Correct 333 ms 27012 KB Output is correct
34 Correct 322 ms 26956 KB Output is correct
35 Correct 326 ms 27168 KB Output is correct
36 Correct 330 ms 26960 KB Output is correct
37 Correct 326 ms 27168 KB Output is correct
38 Correct 298 ms 27036 KB Output is correct
39 Correct 313 ms 27024 KB Output is correct
40 Correct 313 ms 27144 KB Output is correct
41 Correct 297 ms 27176 KB Output is correct
42 Correct 299 ms 27180 KB Output is correct
43 Correct 322 ms 27416 KB Output is correct
44 Correct 318 ms 27424 KB Output is correct
45 Correct 298 ms 27400 KB Output is correct
46 Correct 302 ms 27408 KB Output is correct
47 Correct 300 ms 27520 KB Output is correct
48 Correct 301 ms 27172 KB Output is correct
49 Correct 312 ms 27272 KB Output is correct
50 Correct 313 ms 27416 KB Output is correct
51 Correct 328 ms 27412 KB Output is correct
52 Correct 302 ms 27220 KB Output is correct
53 Correct 313 ms 27412 KB Output is correct
54 Correct 309 ms 27384 KB Output is correct
55 Correct 319 ms 27172 KB Output is correct
56 Correct 309 ms 27244 KB Output is correct
57 Correct 320 ms 27440 KB Output is correct
58 Correct 317 ms 27276 KB Output is correct
59 Correct 309 ms 27216 KB Output is correct
60 Correct 331 ms 27216 KB Output is correct
61 Correct 308 ms 27312 KB Output is correct
62 Correct 297 ms 27284 KB Output is correct
63 Correct 321 ms 27312 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 305 ms 26284 KB Output is correct
2 Correct 295 ms 26492 KB Output is correct
3 Correct 316 ms 26664 KB Output is correct
4 Correct 309 ms 26488 KB Output is correct
5 Correct 361 ms 26548 KB Output is correct
6 Correct 294 ms 26500 KB Output is correct
7 Correct 313 ms 26516 KB Output is correct
8 Correct 306 ms 26504 KB Output is correct
9 Correct 314 ms 26376 KB Output is correct
10 Correct 305 ms 26376 KB Output is correct
11 Correct 303 ms 26328 KB Output is correct
12 Correct 309 ms 26484 KB Output is correct
13 Correct 316 ms 26516 KB Output is correct
14 Correct 341 ms 26756 KB Output is correct
15 Correct 318 ms 26504 KB Output is correct
16 Correct 314 ms 26496 KB Output is correct
17 Correct 316 ms 26504 KB Output is correct
18 Correct 312 ms 26500 KB Output is correct
19 Correct 333 ms 26492 KB Output is correct
20 Correct 325 ms 26304 KB Output is correct
21 Correct 314 ms 26268 KB Output is correct
22 Correct 309 ms 27068 KB Output is correct
23 Correct 333 ms 27168 KB Output is correct
24 Correct 313 ms 27180 KB Output is correct
25 Correct 311 ms 27176 KB Output is correct
26 Correct 311 ms 27100 KB Output is correct
27 Correct 309 ms 27040 KB Output is correct
28 Correct 315 ms 26976 KB Output is correct
29 Correct 323 ms 27184 KB Output is correct
30 Correct 346 ms 27152 KB Output is correct
31 Correct 305 ms 27324 KB Output is correct
32 Correct 321 ms 27160 KB Output is correct
33 Correct 333 ms 27012 KB Output is correct
34 Correct 322 ms 26956 KB Output is correct
35 Correct 326 ms 27168 KB Output is correct
36 Correct 330 ms 26960 KB Output is correct
37 Correct 326 ms 27168 KB Output is correct
38 Correct 298 ms 27036 KB Output is correct
39 Correct 313 ms 27024 KB Output is correct
40 Correct 313 ms 27144 KB Output is correct
41 Correct 297 ms 27176 KB Output is correct
42 Correct 299 ms 27180 KB Output is correct
43 Correct 322 ms 27416 KB Output is correct
44 Correct 318 ms 27424 KB Output is correct
45 Correct 298 ms 27400 KB Output is correct
46 Correct 302 ms 27408 KB Output is correct
47 Correct 300 ms 27520 KB Output is correct
48 Correct 301 ms 27172 KB Output is correct
49 Correct 312 ms 27272 KB Output is correct
50 Correct 313 ms 27416 KB Output is correct
51 Correct 328 ms 27412 KB Output is correct
52 Correct 302 ms 27220 KB Output is correct
53 Correct 313 ms 27412 KB Output is correct
54 Correct 309 ms 27384 KB Output is correct
55 Correct 319 ms 27172 KB Output is correct
56 Correct 309 ms 27244 KB Output is correct
57 Correct 320 ms 27440 KB Output is correct
58 Correct 317 ms 27276 KB Output is correct
59 Correct 309 ms 27216 KB Output is correct
60 Correct 331 ms 27216 KB Output is correct
61 Correct 308 ms 27312 KB Output is correct
62 Correct 297 ms 27284 KB Output is correct
63 Correct 321 ms 27312 KB Output is correct
64 Correct 333 ms 27668 KB Output is correct
65 Correct 301 ms 27664 KB Output is correct
66 Correct 314 ms 27608 KB Output is correct
67 Correct 302 ms 27420 KB Output is correct
68 Correct 315 ms 27476 KB Output is correct
69 Correct 301 ms 27476 KB Output is correct
70 Correct 373 ms 27592 KB Output is correct
71 Correct 307 ms 27652 KB Output is correct
72 Correct 324 ms 27668 KB Output is correct
73 Correct 307 ms 27472 KB Output is correct
74 Correct 318 ms 27548 KB Output is correct
75 Correct 308 ms 27652 KB Output is correct
76 Correct 303 ms 27660 KB Output is correct
77 Correct 306 ms 27476 KB Output is correct
78 Correct 299 ms 27660 KB Output is correct
79 Correct 310 ms 27732 KB Output is correct
80 Correct 325 ms 27472 KB Output is correct
81 Correct 307 ms 27656 KB Output is correct
82 Correct 303 ms 27656 KB Output is correct
83 Correct 316 ms 27600 KB Output is correct
84 Correct 322 ms 27640 KB Output is correct