# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
238749 |
2020-06-12T15:15:26 Z |
Salito |
Trener (COCI20_trener) |
C++14 |
|
5 ms |
512 KB |
#include<bits/stdc++.h>
using namespace std;
long long const mod = 1e9+7;
unordered_map<string,int> h;
long long dp[56][1505];
int n,k;
int main()
{
int i,j;
string s;
cin>>n>>k;
for(i=1;i<=k;i++)
{
cin>>s;
dp[0][i] = 1;
h[s] = i;
}
for(i=1;i<n;i++)
for(j=1;j<=k;j++)
{
cin>>s;
string l,r;
l = s.substr(0,s.size()-1);
r = s.substr(1,s.size()-1);
if(h[l])
dp[i][j]=(dp[i][j]+dp[i-1][h[l]])%mod;
if(h[r] && l!=r)
dp[i][j]=(dp[i][j]+dp[i-1][h[r]])%mod;
if(h[s])j = j/0;
h[s] = j;
}
long long ans = 0;
for(i=1;i<=k;i++)
ans=(ans+dp[n-1][i])%mod;
cout<<ans<<endl;
return 0;
}
Compilation message
trener.cpp: In function 'int main()':
trener.cpp:34:26: warning: division by zero [-Wdiv-by-zero]
if(h[s])j = j/0;
~^~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
5 ms |
512 KB |
Execution killed with signal 4 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |