Submission #238739

# Submission time Handle Problem Language Result Execution time Memory
238739 2020-06-12T14:00:36 Z akat Trener (COCI20_trener) C++14
110 / 110
268 ms 18296 KB
    #include<bits/stdc++.h>
    using namespace std;
    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 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 15 ms 1536 KB Output is correct
2 Correct 14 ms 1536 KB Output is correct
3 Correct 16 ms 1536 KB Output is correct
4 Correct 7 ms 512 KB Output is correct
5 Correct 14 ms 1280 KB Output is correct
6 Correct 14 ms 1152 KB Output is correct
7 Correct 7 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 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 15 ms 1536 KB Output is correct
6 Correct 14 ms 1536 KB Output is correct
7 Correct 16 ms 1536 KB Output is correct
8 Correct 7 ms 512 KB Output is correct
9 Correct 14 ms 1280 KB Output is correct
10 Correct 14 ms 1152 KB Output is correct
11 Correct 7 ms 512 KB Output is correct
12 Correct 226 ms 18296 KB Output is correct
13 Correct 268 ms 18296 KB Output is correct
14 Correct 218 ms 18168 KB Output is correct
15 Correct 222 ms 18296 KB Output is correct
16 Correct 35 ms 2296 KB Output is correct
17 Correct 197 ms 12920 KB Output is correct
18 Correct 193 ms 12920 KB Output is correct
19 Correct 190 ms 12920 KB Output is correct
20 Correct 193 ms 13048 KB Output is correct
21 Correct 190 ms 12920 KB Output is correct
22 Correct 38 ms 2428 KB Output is correct