// author: MisterReaper (Ahmet Alp Orakci)
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MOD = 1e9 + 7;
#define ONLINE_JUDGE
#ifndef ONLINE_JUDGE
#include "debug.h"
#define OPEN freopen(".in", "r", stdin); freopen(".out", "w", stdout);
#define TIME cerr << "\n" << fixed << setprecision(2) << 1000.0 * clock() / CLOCKS_PER_SEC << " milliseconds ";
#else
#define debug(...) void(23)
#define OPEN void(0000)
#define TIME void(232323233)
#endif
void solve()
{
int n, k; cin >> n >> k;
vector <vector <string>> arr(n, vector <string> (k));
for(int i = 0; i < n; i++)
for(int j = 0; j < k; j++)
cin >> arr[i][j];
map <string, int> mp;
mp[""] = 1;
for(int i = 0; i < n; i++)
{
for(int j = 0; j < k; j++)
{
string f = "", s = arr[i][j];
for(int x = 1; x < i +1; x++) f += arr[i][j][x];
s.pop_back();
mp[arr[i][j]] += mp[f];
mp[arr[i][j]] %= MOD;
if(f != s) mp[arr[i][j]] += mp[s];
mp[arr[i][j]] %= MOD;
}
}
int ans = 0;
for(int i = 0; i < k; i++)
{
ans += mp[arr[n -1][i]];
ans %= MOD;
}
cout << ans;
return;
}
int32_t main()
{
OPEN;
ios_base::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
int t = 1; //cin >> t;
while(t--)
{
solve();
}
TIME;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
11 ms |
1620 KB |
Output is correct |
2 |
Correct |
12 ms |
1656 KB |
Output is correct |
3 |
Correct |
11 ms |
1724 KB |
Output is correct |
4 |
Incorrect |
3 ms |
596 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |