Submission #238435

# Submission time Handle Problem Language Result Execution time Memory
238435 2020-06-11T09:25:12 Z stev2005 Trener (COCI20_trener) C++17
55 / 110
2000 ms 9720 KB
#include<iostream>
#include<string>
using namespace std;
const int mod=1000000007;
int n,k,dp[62][2048];
string s[62][2048];
void read()
{
	cin>>n>>k;
	for(int i=0;i<n;i++)
		for(int j=0;j<k;j++)
		{
			cin>>s[i][j];
		}
}
void solve()
{
	for(int i=0;i<k;i++)
		dp[0][i]=1;
	int rez;
	for(int i=1;i<n;i++)
		for(int j=0;j<k;j++)
			for(int p=0;p<k;p++)
			{
				rez=(int)s[i][j].find(s[i-1][p]);
				///cout<<rez<<' '<<s[i][j]<<' '<<s[i-1][p]<<endl;
				if(rez>-1)dp[i][j]=(dp[i-1][p]%mod+dp[i][j]%mod)%mod;
			}
	int ans=0,pos=n-1;
	for(int i=0;i<k;i++)
		ans=(dp[pos][i]%mod+ans%mod)%mod;
	cout<<ans<<endl;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	read();
	solve();
return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 7 ms 4352 KB Output is correct
2 Correct 7 ms 4352 KB Output is correct
3 Correct 7 ms 4352 KB Output is correct
4 Correct 7 ms 4352 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 15 ms 4864 KB Output is correct
2 Correct 15 ms 4840 KB Output is correct
3 Correct 15 ms 4864 KB Output is correct
4 Correct 14 ms 4864 KB Output is correct
5 Correct 21 ms 4856 KB Output is correct
6 Correct 23 ms 4912 KB Output is correct
7 Correct 14 ms 4736 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 4352 KB Output is correct
2 Correct 7 ms 4352 KB Output is correct
3 Correct 7 ms 4352 KB Output is correct
4 Correct 7 ms 4352 KB Output is correct
5 Correct 15 ms 4864 KB Output is correct
6 Correct 15 ms 4840 KB Output is correct
7 Correct 15 ms 4864 KB Output is correct
8 Correct 14 ms 4864 KB Output is correct
9 Correct 21 ms 4856 KB Output is correct
10 Correct 23 ms 4912 KB Output is correct
11 Correct 14 ms 4736 KB Output is correct
12 Correct 1504 ms 8440 KB Output is correct
13 Correct 1568 ms 9660 KB Output is correct
14 Correct 1542 ms 9720 KB Output is correct
15 Correct 1541 ms 9492 KB Output is correct
16 Correct 1483 ms 9592 KB Output is correct
17 Execution timed out 2080 ms 9364 KB Time limit exceeded
18 Halted 0 ms 0 KB -