// Aber der schlimmste Fiend, dem du begegnen kannst, wirst du immer dir selber sein
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx2,popcnt,lzcnt,abm,bmi,bmi2,fma,tune=native")
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ff first
#define ss second
#define pb push_back
#define rev reverse
#define all(x) x.begin(),x.end()
#define acc accumulate
#define sz size()
#define MOD 1000000007
#define rall(x) x.rbegin(),x.rend()
#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;
const int N = 2e5 + 5;
inline void solve(){
int n, k;
cin >> n >> k;
map<string, int> mp;
string ma[n][k];
for(int i = 0; i < n; i++){
for(int j = 0; j < k; j++){
cin >> ma[i][j];
}
}
for(int i = 0; i < k; i++){
mp[ma[n-1][i]]++;
}
for(int i = n-1; i > 0; i--){
for(int j = 0; j < k; j++){
string s1 = ma[i][j].substr(0, i), s2 = ma[i][j].substr(1, i);
mp[s1] = (mp[ma[i][j]] + mp[s1]) % MOD;
if(s1 != s2){
mp[s2] = (mp[s2] + mp[ma[i][j]]) % MOD;
}
}
}
int ans = 0;
for(int i = 0; i < k; i++){
ans = (ans + mp[ma[0][i]]) % MOD;
}
cout << ans << endl;
}
int main(){
fast_io
int t;
t = 1;
while(t--) solve();
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
1628 KB |
Output is correct |
2 |
Correct |
7 ms |
1624 KB |
Output is correct |
3 |
Correct |
7 ms |
1628 KB |
Output is correct |
4 |
Incorrect |
3 ms |
600 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |