#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define ll long long
#define pri pair<int,int>
#define prl pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define vp vector<pair<int,int>>
#define vpl vector<pair<ll,ll>>
#define re return 0
#define sqrt sqrtl
struct node {
string val;
vector<int> adj; //asagi
ll ds = 1;
};
int insides(string s1, string s2) {
if (s1.find(s2)!=s1.npos) {
return 1;
} return 0;
}
int32_t main() {
int n,k;cin>>n>>k;
vector<vector<string>> nk(n,vector<string>(k));
vector<node> nodes(n*k);
for (int i = 0;i<n;i++) {
for (int j = 0;j<k;j++) {
string s1;cin>>s1;nodes[i*k+j].val=s1;
}
}
for (int i = n-2;i>-1;i--){
for (int j = 0;j<k;j++) {
nodes[i*k+j].ds=0;
for (int x = 0;x<k;x++) {
if (insides(nodes[(i+1)*k+x].val,nodes[i*k+j].val)) {
nodes[(i+1)*k+x].adj.push_back(i*k+j);
nodes[i*k+j].ds+=nodes[(i+1)*k+x].ds;
}
}
}
}
ll t = 0;
for (int i = 0;i<k;i++){
t+=nodes[i].ds;
} cout<<t%MOD<<endl;
/* for (int i = 0;i<n*k;i++) {
cout<<nodes[i].val<<" "<<nodes[i].ds<<" "<<nodes[i].adj.size()<<endl;
} */
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 |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
27 ms |
1112 KB |
Output is correct |
2 |
Correct |
27 ms |
1176 KB |
Output is correct |
3 |
Correct |
27 ms |
1112 KB |
Output is correct |
4 |
Incorrect |
27 ms |
3640 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 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
27 ms |
1112 KB |
Output is correct |
6 |
Correct |
27 ms |
1176 KB |
Output is correct |
7 |
Correct |
27 ms |
1112 KB |
Output is correct |
8 |
Incorrect |
27 ms |
3640 KB |
Output isn't correct |
9 |
Halted |
0 ms |
0 KB |
- |