Submission #999012

# Submission time Handle Problem Language Result Execution time Memory
999012 2024-06-15T04:59:45 Z vjudge1 Trener (COCI20_trener) C++17
110 / 110
171 ms 18384 KB
#include <bits/stdc++.h>

using namespace std;

#define int long long

const int mod = 1e9 + 7;

signed main()
{
	int n,k;
	cin>>n>>k;
	map<string,int> ans,cnt;
	int fin_ans=0,iv = (mod+1)/2;
	for (int a=1;a<=n;a++)
		for (int b=0;b<k;b++)
		{
			string s;
			cin>>s;
			cnt[s]++;
			if (a==1)
			{
				ans[s]=1;
				continue;
			}
			int x=0;
			string s1=s.substr(0,a-1),s2=s.substr(1,a-1);
			if (ans.find(s1)!=ans.end())
				x+=ans[s1]*cnt[s1]%mod;
			if (ans.find(s2)!=ans.end())
				x+=ans[s2]*cnt[s2]%mod;
			x%=mod;
			if (s1==s2)
				x=x*iv%mod;
			ans[s]=x;
			if (a==n)
				fin_ans+=x,fin_ans%=mod;
		}
	cout<<fin_ans<<endl;
	
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 1372 KB Output is correct
2 Correct 8 ms 1372 KB Output is correct
3 Correct 9 ms 1380 KB Output is correct
4 Correct 4 ms 348 KB Output is correct
5 Correct 8 ms 1292 KB Output is correct
6 Correct 7 ms 1088 KB Output is correct
7 Correct 4 ms 448 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 8 ms 1372 KB Output is correct
6 Correct 8 ms 1372 KB Output is correct
7 Correct 9 ms 1380 KB Output is correct
8 Correct 4 ms 348 KB Output is correct
9 Correct 8 ms 1292 KB Output is correct
10 Correct 7 ms 1088 KB Output is correct
11 Correct 4 ms 448 KB Output is correct
12 Correct 170 ms 16464 KB Output is correct
13 Correct 171 ms 18260 KB Output is correct
14 Correct 164 ms 18384 KB Output is correct
15 Correct 163 ms 18260 KB Output is correct
16 Correct 49 ms 2132 KB Output is correct
17 Correct 147 ms 14180 KB Output is correct
18 Correct 153 ms 14216 KB Output is correct
19 Correct 149 ms 14164 KB Output is correct
20 Correct 158 ms 14192 KB Output is correct
21 Correct 158 ms 14288 KB Output is correct
22 Correct 53 ms 2132 KB Output is correct