Submission #238478

# Submission time Handle Problem Language Result Execution time Memory
238478 2020-06-11T13:52:01 Z akat Trener (COCI20_trener) C++14
110 / 110
106 ms 16056 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(h[s] >= MOD) h[s] -= MOD;
   			if(i == n-1) ans += curr;
   			if(ans >= MOD) ans -= MOD;
   		}
   	cout<<ans<<'\n';
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 5 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 Correct 6 ms 384 KB Output is correct
5 Correct 8 ms 1280 KB Output is correct
6 Correct 8 ms 1280 KB Output is correct
7 Correct 6 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 5 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 Correct 6 ms 384 KB Output is correct
9 Correct 8 ms 1280 KB Output is correct
10 Correct 8 ms 1280 KB Output is correct
11 Correct 6 ms 512 KB Output is correct
12 Correct 94 ms 16056 KB Output is correct
13 Correct 106 ms 15928 KB Output is correct
14 Correct 103 ms 15932 KB Output is correct
15 Correct 98 ms 15928 KB Output is correct
16 Correct 30 ms 512 KB Output is correct
17 Correct 71 ms 10504 KB Output is correct
18 Correct 65 ms 10632 KB Output is correct
19 Correct 99 ms 10632 KB Output is correct
20 Correct 85 ms 10632 KB Output is correct
21 Correct 79 ms 10556 KB Output is correct
22 Correct 27 ms 512 KB Output is correct