Submission #945558

# Submission time Handle Problem Language Result Execution time Memory
945558 2024-03-14T04:39:25 Z vjudge1 Cubeword (CEOI19_cubeword) C++17
50 / 100
380 ms 16572 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][25][25];
int ans = 0;
int n,m,k;

vector<int>vs;

void dfs(int i){
	
	if(i == 4){
		
		for(int sz = 3;sz<=10;sz++){
			int val = 1;
				for(int j = 0;j<4;j++){
					int sum = 0; 
					for(int k = 0;k<='p'-'a';k++){
						int c = 1;
						
						for(int l = 0;l<4;l++){
							if(l == j)continue;
							c *= g[sz][vs[l]][k];
						}
						sum += c;
						sum %= mod;
					}
					val *= sum;
					val %= mod;
				}
			ans += val;
			ans %= mod;
		}
		return;
	}
	
	for(int l = 0;l<='p'-'a';l++){
		vs.pb(l);
		dfs(i + 1);
		vs.pop_back();
	}
	
}


void solve(){
	
	cin >> n;
	map<string,int>mp;
	for(int i = 1;i<=n;i++){
		string a;
		cin >> a;
		if(mp[a] == 0)
		g[a.size()][a[0]-'a'][a[a.size()-1]-'a'] += 1;
		
		mp[a] += 1;
		
		reverse(all(a));
		if(mp[a] == 0){
			g[a.size()][a[0]-'a'][a[a.size()-1]-'a'] += 1;
		}
		mp[a] += 1;
	}
	
	dfs(0);
	cout << ans << '\n';
	
}
/*

*/
signed main()
{
	ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
	int tt=1;//cin>>tt>>n;
	while(tt--)solve();

}

# Verdict Execution time Memory Grader output
1 Correct 304 ms 14764 KB Output is correct
2 Correct 294 ms 15772 KB Output is correct
3 Correct 297 ms 15576 KB Output is correct
4 Correct 296 ms 15788 KB Output is correct
5 Correct 292 ms 15700 KB Output is correct
6 Correct 286 ms 15956 KB Output is correct
7 Correct 281 ms 15648 KB Output is correct
8 Correct 342 ms 15828 KB Output is correct
9 Correct 311 ms 15816 KB Output is correct
10 Correct 287 ms 15584 KB Output is correct
11 Correct 299 ms 15952 KB Output is correct
12 Correct 284 ms 15616 KB Output is correct
13 Correct 304 ms 15828 KB Output is correct
14 Correct 292 ms 15824 KB Output is correct
15 Correct 282 ms 15828 KB Output is correct
16 Correct 317 ms 15688 KB Output is correct
17 Correct 298 ms 15696 KB Output is correct
18 Correct 311 ms 15812 KB Output is correct
19 Correct 295 ms 15816 KB Output is correct
20 Correct 284 ms 15776 KB Output is correct
21 Correct 290 ms 15804 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 304 ms 14764 KB Output is correct
2 Correct 294 ms 15772 KB Output is correct
3 Correct 297 ms 15576 KB Output is correct
4 Correct 296 ms 15788 KB Output is correct
5 Correct 292 ms 15700 KB Output is correct
6 Correct 286 ms 15956 KB Output is correct
7 Correct 281 ms 15648 KB Output is correct
8 Correct 342 ms 15828 KB Output is correct
9 Correct 311 ms 15816 KB Output is correct
10 Correct 287 ms 15584 KB Output is correct
11 Correct 299 ms 15952 KB Output is correct
12 Correct 284 ms 15616 KB Output is correct
13 Correct 304 ms 15828 KB Output is correct
14 Correct 292 ms 15824 KB Output is correct
15 Correct 282 ms 15828 KB Output is correct
16 Correct 317 ms 15688 KB Output is correct
17 Correct 298 ms 15696 KB Output is correct
18 Correct 311 ms 15812 KB Output is correct
19 Correct 295 ms 15816 KB Output is correct
20 Correct 284 ms 15776 KB Output is correct
21 Correct 290 ms 15804 KB Output is correct
22 Correct 296 ms 16384 KB Output is correct
23 Correct 286 ms 16312 KB Output is correct
24 Correct 293 ms 16212 KB Output is correct
25 Correct 380 ms 16392 KB Output is correct
26 Correct 299 ms 16212 KB Output is correct
27 Correct 301 ms 16380 KB Output is correct
28 Correct 285 ms 16216 KB Output is correct
29 Correct 310 ms 16212 KB Output is correct
30 Correct 297 ms 16212 KB Output is correct
31 Correct 333 ms 16200 KB Output is correct
32 Correct 300 ms 16376 KB Output is correct
33 Correct 332 ms 16160 KB Output is correct
34 Correct 283 ms 16404 KB Output is correct
35 Correct 302 ms 16208 KB Output is correct
36 Correct 304 ms 16400 KB Output is correct
37 Correct 303 ms 16572 KB Output is correct
38 Correct 300 ms 16224 KB Output is correct
39 Correct 301 ms 16404 KB Output is correct
40 Correct 304 ms 16208 KB Output is correct
41 Correct 305 ms 16180 KB Output is correct
42 Correct 299 ms 16400 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 304 ms 14764 KB Output is correct
2 Correct 294 ms 15772 KB Output is correct
3 Correct 297 ms 15576 KB Output is correct
4 Correct 296 ms 15788 KB Output is correct
5 Correct 292 ms 15700 KB Output is correct
6 Correct 286 ms 15956 KB Output is correct
7 Correct 281 ms 15648 KB Output is correct
8 Correct 342 ms 15828 KB Output is correct
9 Correct 311 ms 15816 KB Output is correct
10 Correct 287 ms 15584 KB Output is correct
11 Correct 299 ms 15952 KB Output is correct
12 Correct 284 ms 15616 KB Output is correct
13 Correct 304 ms 15828 KB Output is correct
14 Correct 292 ms 15824 KB Output is correct
15 Correct 282 ms 15828 KB Output is correct
16 Correct 317 ms 15688 KB Output is correct
17 Correct 298 ms 15696 KB Output is correct
18 Correct 311 ms 15812 KB Output is correct
19 Correct 295 ms 15816 KB Output is correct
20 Correct 284 ms 15776 KB Output is correct
21 Correct 290 ms 15804 KB Output is correct
22 Correct 296 ms 16384 KB Output is correct
23 Correct 286 ms 16312 KB Output is correct
24 Correct 293 ms 16212 KB Output is correct
25 Correct 380 ms 16392 KB Output is correct
26 Correct 299 ms 16212 KB Output is correct
27 Correct 301 ms 16380 KB Output is correct
28 Correct 285 ms 16216 KB Output is correct
29 Correct 310 ms 16212 KB Output is correct
30 Correct 297 ms 16212 KB Output is correct
31 Correct 333 ms 16200 KB Output is correct
32 Correct 300 ms 16376 KB Output is correct
33 Correct 332 ms 16160 KB Output is correct
34 Correct 283 ms 16404 KB Output is correct
35 Correct 302 ms 16208 KB Output is correct
36 Correct 304 ms 16400 KB Output is correct
37 Correct 303 ms 16572 KB Output is correct
38 Correct 300 ms 16224 KB Output is correct
39 Correct 301 ms 16404 KB Output is correct
40 Correct 304 ms 16208 KB Output is correct
41 Correct 305 ms 16180 KB Output is correct
42 Correct 299 ms 16400 KB Output is correct
43 Incorrect 291 ms 16384 KB Output isn't correct
44 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 304 ms 14764 KB Output is correct
2 Correct 294 ms 15772 KB Output is correct
3 Correct 297 ms 15576 KB Output is correct
4 Correct 296 ms 15788 KB Output is correct
5 Correct 292 ms 15700 KB Output is correct
6 Correct 286 ms 15956 KB Output is correct
7 Correct 281 ms 15648 KB Output is correct
8 Correct 342 ms 15828 KB Output is correct
9 Correct 311 ms 15816 KB Output is correct
10 Correct 287 ms 15584 KB Output is correct
11 Correct 299 ms 15952 KB Output is correct
12 Correct 284 ms 15616 KB Output is correct
13 Correct 304 ms 15828 KB Output is correct
14 Correct 292 ms 15824 KB Output is correct
15 Correct 282 ms 15828 KB Output is correct
16 Correct 317 ms 15688 KB Output is correct
17 Correct 298 ms 15696 KB Output is correct
18 Correct 311 ms 15812 KB Output is correct
19 Correct 295 ms 15816 KB Output is correct
20 Correct 284 ms 15776 KB Output is correct
21 Correct 290 ms 15804 KB Output is correct
22 Correct 296 ms 16384 KB Output is correct
23 Correct 286 ms 16312 KB Output is correct
24 Correct 293 ms 16212 KB Output is correct
25 Correct 380 ms 16392 KB Output is correct
26 Correct 299 ms 16212 KB Output is correct
27 Correct 301 ms 16380 KB Output is correct
28 Correct 285 ms 16216 KB Output is correct
29 Correct 310 ms 16212 KB Output is correct
30 Correct 297 ms 16212 KB Output is correct
31 Correct 333 ms 16200 KB Output is correct
32 Correct 300 ms 16376 KB Output is correct
33 Correct 332 ms 16160 KB Output is correct
34 Correct 283 ms 16404 KB Output is correct
35 Correct 302 ms 16208 KB Output is correct
36 Correct 304 ms 16400 KB Output is correct
37 Correct 303 ms 16572 KB Output is correct
38 Correct 300 ms 16224 KB Output is correct
39 Correct 301 ms 16404 KB Output is correct
40 Correct 304 ms 16208 KB Output is correct
41 Correct 305 ms 16180 KB Output is correct
42 Correct 299 ms 16400 KB Output is correct
43 Incorrect 291 ms 16384 KB Output isn't correct
44 Halted 0 ms 0 KB -