Submission #846062

# Submission time Handle Problem Language Result Execution time Memory
846062 2023-09-07T08:58:13 Z vjudge1 Trener (COCI20_trener) C++17
22 / 110
2000 ms 3720 KB
/*
    Author:Matkap(prefixsumenjoyer23)
    
*/
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#pragma GCC optimize("O3,fast-math,inline")
#include <bits/stdc++.h>

using namespace std;
#define fr freopen("in.txt","r",stdin);freopen("out.txt","w",stdout);


#define int long long
#define endl "\n"
const int mod = (int)(1e9+7);
#define all(x) x.begin(),x.end()

int mxn = 1e18;
int mnn = -mxn;

void outarr(int ans[],int n)
{
	for (int i = 0; i < n; i++) cout << ans[i] << " \n"[i == n - 1];
}
int binpow(int base,int power)
{
	if(power == 1) return base;
	if(power == 0) return 1;
    
     if(power&2)
     {
     	 int a;
     	a = binpow(base,(power-1)/2);
     	return a*a*base;
     } 
     else
     {
     	 int a;
     	a = binpow(base,power/2);
     	return a*a;
     } 

}
int gcd(int a, int b)
{

    if(b == 0) {
            return a;
    }
    else {
        return gcd(b, a % b);
    }
}
int lcm(int a,int b)
{
	return (a*b)/gcd(a,b);
}
int cvp = 0;
int n,k;
string s[55][1505];
void func(int i,int j)
{

	if(j == k)
	{
		
		return;
	}
	if(i == n) return;
	if(i == n-1)
	{
		cvp%=mod;
		cvp++;
		cvp%=mod;
	
		return;
	}

	for(int k1 = 0;k>k1;k1++)
	{
	
		string it = s[i+1][k1];
		int i1 = 0;
		int j1 = 0;

		for(int l = 1;i+2>l;l++)
		{
			if(s[i][j][l-1] != it[l])
			{
				i1 = -1;
				break;
			}
			i1++;
		}
		for(int l = 0;i+1>l;l++)
		{
			if(s[i][j][l] != it[l])
			{
				j1 = -1;
				break;
			}
			j1++;
		}

		if(i1 == i+1 || j1 == i+1)
		{
			
			func(i+1,k1);

		}
		
	}
	if(i == 0 && k-1 > j)
	func(i,j+1);

}
int mark[50][1505];
void solve()
{
   	map<string,int> mp;
   	cin >> n >> k;

   	
   	for(int i = 0;n>i;i++)
   	{
   		for(int j = 0;k>j;j++) cin >> s[i][j];
   	}

   func(0,0);

   cout << cvp << endl;



}



int32_t main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);

	//fr

	int t;
	t=1;
	//cin >> t;
	while(t--) solve();

}


//template



# Verdict Execution time Memory Grader output
1 Correct 1 ms 3420 KB Output is correct
2 Correct 1 ms 3420 KB Output is correct
3 Correct 1 ms 3420 KB Output is correct
4 Correct 3 ms 3720 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 130 ms 3628 KB Output is correct
2 Correct 107 ms 3636 KB Output is correct
3 Correct 217 ms 3664 KB Output is correct
4 Execution timed out 2044 ms 3416 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 3420 KB Output is correct
2 Correct 1 ms 3420 KB Output is correct
3 Correct 1 ms 3420 KB Output is correct
4 Correct 3 ms 3720 KB Output is correct
5 Correct 130 ms 3628 KB Output is correct
6 Correct 107 ms 3636 KB Output is correct
7 Correct 217 ms 3664 KB Output is correct
8 Execution timed out 2044 ms 3416 KB Time limit exceeded
9 Halted 0 ms 0 KB -