# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
885208 |
2023-12-09T09:03:26 Z |
vjudge1 |
Trener (COCI20_trener) |
C++17 |
|
5 ms |
1624 KB |
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define endl '\n'
using namespace std;
const int MOD = 1e9 + 7;
const int p = 31;
map<string,int> dp;
void solve(){
int n,k; cin>>n>>k;
//i=1;
for(int i=1;i<=k;i++){
string s; cin>>s;
dp[s]=1;
}
for(int i=2; i<=n-1; i++){
for(int j=1;j<=k;j++){
string s,s1,s2; cin>>s;
s1=s.substr(0, i-1);
s2=s.substr(1, i-1);
if(s1==s2)
dp[s]=dp[s1];
else
dp[s]=(dp[s1]+dp[s2])%MOD;
}
}
//i=n;
int ans=0;
for(int j=1;j<=k;j++){
string s,s1,s2; cin>>s;
s1=s.substr(0, n-1);
s2=s.substr(1, n-1);
if(s1==s2)
ans=(ans+dp[s1])%MOD;
else
ans=(ans+dp[s1]+dp[s2])%MOD;
}
cout<<ans;
}
int32_t main(){
cin.tie(0)->sync_with_stdio(false);
solve();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
1624 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |