#include <bits/stdc++.h>
using namespace std;
#define fod(i,a,b) for(int i = (int) (a); i <= (int) (b); i++)
#define fok(i,a,b) for(int i = (int) (a); i >= (int) (b); i--)
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define el '\n'
#define ve vector
#define vi ve<int>
#define vll ve<ll>
#define mask(a) (1LL<<(a))
#define BIT(msk,i) (msk>>(i)&1LL)
using namespace std;
template <class T> bool mini(T &a, T b){ return (a > (b)) ? a = (b), 1 : 0; }
template <class T> bool maxi(T &a, T b){ return (a < (b)) ? a = (b), 1 : 0; }
#define name "trener"
const int MOD = 1e9 + 7;
inline void madd(int &a, int b){
a += b;
if(a >= MOD) a -= MOD;
else if(a < 0) a += MOD;
}
int n, k;
unordered_map <string, int> dp;
int main(){
ios_base::sync_with_stdio(false); cin.tie(0);
cin >> n >> k;
string s;
fod(i,1,k){
cin >> s;
dp[s]++;
}
fod(i,2,n){
unordered_map <string, int> new_dp;
fod(j,1,k){
string s; cin >> s;
new_dp[s]++;
}
unordered_map <string, int> cnt = new_dp;
for(auto &x : new_dp){
x.se = 0;
for(auto y : dp) if(x.fi.find(y.fi) != string::npos){
madd(x.se, 1LL * cnt[x.fi] * y.se % MOD);
}
}
swap(dp, new_dp);
}
int res = 0;
for(auto &x : dp) madd(res, x.se);
cout << res;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 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 |
604 KB |
Output is correct |
2 |
Correct |
13 ms |
604 KB |
Output is correct |
3 |
Correct |
13 ms |
604 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
11 ms |
600 KB |
Output is correct |
6 |
Correct |
11 ms |
604 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 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 |
604 KB |
Output is correct |
6 |
Correct |
13 ms |
604 KB |
Output is correct |
7 |
Correct |
13 ms |
604 KB |
Output is correct |
8 |
Correct |
1 ms |
344 KB |
Output is correct |
9 |
Correct |
11 ms |
600 KB |
Output is correct |
10 |
Correct |
11 ms |
604 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Execution timed out |
2076 ms |
2420 KB |
Time limit exceeded |
13 |
Halted |
0 ms |
0 KB |
- |