답안 #943956

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
943956 2024-03-12T05:33:00 Z Minbaev Cubeword (CEOI19_cubeword) C++17
0 / 100
887 ms 436 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;
	
	for(int i = 1;i<=n;i++){
		string a;
		cin >> a;
		
		string b = a;
		
			g[(int)a.size()][a[0] - 'a'][a[a.size()-1] - 'a'] += 1;
			
			
		reverse(a.begin(),a.end());
		
		if(a != b){
			g[(int)a.size()][b[0] - 'a'][b[a.size()-1] - '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;
      |          ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 887 ms 436 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 887 ms 436 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 887 ms 436 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 887 ms 436 KB Output isn't correct
2 Halted 0 ms 0 KB -