Submission #943958

# Submission time Handle Problem Language Result Execution time Memory
943958 2024-03-12T05:35:20 Z vjudge1 Cubeword (CEOI19_cubeword) C++17
21 / 100
1052 ms 31200 KB
#include <bits/stdc++.h>

using namespace std;

#define int long long

const int N=1e6 + 5	;
const int inf = 1e18 + 7;
const int mod = 998244353;

int g[11][7][7];
vector<int>op[8];

int ans = 0;


void dfs(int sz, int ind, vector<int>v){
	
	if(7 < ind){
		int val = 1;
		
		for(int i = 0;i<7;i++){
			for(auto to:op[i]){
				val *= g[sz][v[i]][v[to]];
				val %= mod;
			}
		}
		ans += val;
		ans %= mod;
		return;
	}
	
	for(int i = 0;i<6;i++){
		v[ind] = i;
		dfs(sz,ind+1,v);
	}
	
	
}

void solve(){
	
	op[0] = {1,2,3};
	op[1] = {4,7};
	op[2] = {5,7};
	op[3] = {4,5};
	op[4] = {6};
	op[5] = {6};
	op[6] = {7};
	
	int n,m,k;
	cin >> n;
	
	map<string,int>mp;
	
	for(int i = 1;i<=n;i++){
		string a;
		cin >> a;
		if(mp[a] == 0){
			g[(int)a.size()][a[0] - 'a'][a[a.size()-1] - 'a'] += 1;
			mp[a] += 1;
		}
		reverse(a.begin(),a.end());
		if(mp[a] == 0){
			g[(int)a.size()][a[0] - 'a'][a[a.size()-1] - 'a'] += 1;
			mp[a] += 1;
		}
	}	
	
	for(int i = 3;i<=10;i++){
		vector<int>v(8);
		dfs(i,0,v);
	}
	
	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();

}

Compilation message

cubeword.cpp: In function 'void solve()':
cubeword.cpp:51:8: warning: unused variable 'm' [-Wunused-variable]
   51 |  int n,m,k;
      |        ^
cubeword.cpp:51:10: warning: unused variable 'k' [-Wunused-variable]
   51 |  int n,m,k;
      |          ^
# Verdict Execution time Memory Grader output
1 Correct 1051 ms 14928 KB Output is correct
2 Correct 1018 ms 14892 KB Output is correct
3 Correct 1043 ms 14920 KB Output is correct
4 Correct 1006 ms 14908 KB Output is correct
5 Correct 1012 ms 14928 KB Output is correct
6 Correct 1020 ms 14920 KB Output is correct
7 Correct 1034 ms 14820 KB Output is correct
8 Correct 1020 ms 14940 KB Output is correct
9 Correct 1004 ms 14932 KB Output is correct
10 Correct 1008 ms 14928 KB Output is correct
11 Correct 1040 ms 14920 KB Output is correct
12 Correct 1052 ms 14912 KB Output is correct
13 Correct 1025 ms 14932 KB Output is correct
14 Correct 1036 ms 14896 KB Output is correct
15 Correct 1028 ms 14932 KB Output is correct
16 Correct 1020 ms 15092 KB Output is correct
17 Correct 1049 ms 14924 KB Output is correct
18 Correct 1020 ms 14916 KB Output is correct
19 Correct 1026 ms 14908 KB Output is correct
20 Correct 1025 ms 14920 KB Output is correct
21 Correct 1006 ms 14908 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1051 ms 14928 KB Output is correct
2 Correct 1018 ms 14892 KB Output is correct
3 Correct 1043 ms 14920 KB Output is correct
4 Correct 1006 ms 14908 KB Output is correct
5 Correct 1012 ms 14928 KB Output is correct
6 Correct 1020 ms 14920 KB Output is correct
7 Correct 1034 ms 14820 KB Output is correct
8 Correct 1020 ms 14940 KB Output is correct
9 Correct 1004 ms 14932 KB Output is correct
10 Correct 1008 ms 14928 KB Output is correct
11 Correct 1040 ms 14920 KB Output is correct
12 Correct 1052 ms 14912 KB Output is correct
13 Correct 1025 ms 14932 KB Output is correct
14 Correct 1036 ms 14896 KB Output is correct
15 Correct 1028 ms 14932 KB Output is correct
16 Correct 1020 ms 15092 KB Output is correct
17 Correct 1049 ms 14924 KB Output is correct
18 Correct 1020 ms 14916 KB Output is correct
19 Correct 1026 ms 14908 KB Output is correct
20 Correct 1025 ms 14920 KB Output is correct
21 Correct 1006 ms 14908 KB Output is correct
22 Runtime error 1018 ms 31200 KB Execution killed with signal 11
23 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1051 ms 14928 KB Output is correct
2 Correct 1018 ms 14892 KB Output is correct
3 Correct 1043 ms 14920 KB Output is correct
4 Correct 1006 ms 14908 KB Output is correct
5 Correct 1012 ms 14928 KB Output is correct
6 Correct 1020 ms 14920 KB Output is correct
7 Correct 1034 ms 14820 KB Output is correct
8 Correct 1020 ms 14940 KB Output is correct
9 Correct 1004 ms 14932 KB Output is correct
10 Correct 1008 ms 14928 KB Output is correct
11 Correct 1040 ms 14920 KB Output is correct
12 Correct 1052 ms 14912 KB Output is correct
13 Correct 1025 ms 14932 KB Output is correct
14 Correct 1036 ms 14896 KB Output is correct
15 Correct 1028 ms 14932 KB Output is correct
16 Correct 1020 ms 15092 KB Output is correct
17 Correct 1049 ms 14924 KB Output is correct
18 Correct 1020 ms 14916 KB Output is correct
19 Correct 1026 ms 14908 KB Output is correct
20 Correct 1025 ms 14920 KB Output is correct
21 Correct 1006 ms 14908 KB Output is correct
22 Runtime error 1018 ms 31200 KB Execution killed with signal 11
23 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1051 ms 14928 KB Output is correct
2 Correct 1018 ms 14892 KB Output is correct
3 Correct 1043 ms 14920 KB Output is correct
4 Correct 1006 ms 14908 KB Output is correct
5 Correct 1012 ms 14928 KB Output is correct
6 Correct 1020 ms 14920 KB Output is correct
7 Correct 1034 ms 14820 KB Output is correct
8 Correct 1020 ms 14940 KB Output is correct
9 Correct 1004 ms 14932 KB Output is correct
10 Correct 1008 ms 14928 KB Output is correct
11 Correct 1040 ms 14920 KB Output is correct
12 Correct 1052 ms 14912 KB Output is correct
13 Correct 1025 ms 14932 KB Output is correct
14 Correct 1036 ms 14896 KB Output is correct
15 Correct 1028 ms 14932 KB Output is correct
16 Correct 1020 ms 15092 KB Output is correct
17 Correct 1049 ms 14924 KB Output is correct
18 Correct 1020 ms 14916 KB Output is correct
19 Correct 1026 ms 14908 KB Output is correct
20 Correct 1025 ms 14920 KB Output is correct
21 Correct 1006 ms 14908 KB Output is correct
22 Runtime error 1018 ms 31200 KB Execution killed with signal 11
23 Halted 0 ms 0 KB -