Submission #238473

# Submission time Handle Problem Language Result Execution time Memory
238473 2020-06-11T13:46:16 Z akat Trener (COCI20_trener) C++14
22 / 110
9 ms 1408 KB
#include<bits/stdc++.h>
using namespace std;
unordered_map<string,int>h;
const int MOD = 1e9 + 7;
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	long long n,k,i,j,curr,ans = 0;
	string s,sub1,sub2;
	cin>>n>>k;
	for(i = 0; i < n; i++)
		for(j = 0; j < k; j++)
		{
			cin>>s;
			sub1 = s.substr(0,i);
			sub2 = s.substr(1,i);
			curr = h[sub1];;
			if(sub1 != sub2) curr += h[sub2];
			if(curr >= MOD) curr -= MOD;
			if(i==0) curr++;
			h[s] += curr;
			if(i == n-1) ans += curr;
			if(ans >= MOD) ans -= MOD;
		}
	cout<<ans<<'\n';
}
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 1408 KB Output is correct
2 Correct 9 ms 1408 KB Output is correct
3 Correct 8 ms 1408 KB Output is correct
4 Incorrect 6 ms 384 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 9 ms 1408 KB Output is correct
6 Correct 9 ms 1408 KB Output is correct
7 Correct 8 ms 1408 KB Output is correct
8 Incorrect 6 ms 384 KB Output isn't correct
9 Halted 0 ms 0 KB -