#include <bits/stdc++.h>
#define int long long
int MOD = 1e9+7;
using namespace std;
void solve(void){
int n, k;
cin >> n >> k;
vector<vector<string>> bruh(n, vector<string>(k));
for(int i=0; i<n; i++)
for(int g=0; g<k; g++)
cin >> bruh[i][g];
map<string, int> hmmm;
for(int g=0; g<k; g++){
hmmm[ bruh[n-1][g] ] = 1;
}
for(int i=n-1; i>0; i--){
for(int g=0; g<k; g++){
string ss = bruh[i][g];
string fr = ss.substr(0, i);
string bc = ss.substr(1, i);
hmmm[fr] += hmmm[ss];
hmmm[fr] = hmmm[fr]%MOD;
if( fr != bc ){
hmmm[bc] = (hmmm[bc] + hmmm[ss] )%MOD;
}
}
}
int cnt = 0;
for(int i=0; i<k; i++){
cnt += hmmm[bruh[0][i]];
}
cout << cnt << "\n";
}
signed main(){
int t=1;
// cin >> t;
while(t--)
solve();
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
13 ms |
1772 KB |
Output is correct |
2 |
Correct |
14 ms |
1840 KB |
Output is correct |
3 |
Correct |
10 ms |
1880 KB |
Output is correct |
4 |
Incorrect |
4 ms |
604 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
13 ms |
1772 KB |
Output is correct |
6 |
Correct |
14 ms |
1840 KB |
Output is correct |
7 |
Correct |
10 ms |
1880 KB |
Output is correct |
8 |
Incorrect |
4 ms |
604 KB |
Output isn't correct |
9 |
Halted |
0 ms |
0 KB |
- |