# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
223193 | jamielim | Trener (COCI20_trener) | C++14 | 23 ms | 640 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD=1000000007;
int main(){
int n,k;
scanf("%d%d",&n,&k);
char str[n][k][55];
for(int i=0;i<n;i++){
for(int j=0;j<k;j++){
scanf("%s",str[i][j]);
}
}
ll dp[n][k]; memset(dp,0,sizeof(dp));
for(int i=0;i<k;i++)dp[n-1][i]=1;
for(int i=n-2;i>=0;i--){
for(int j=0;j<k;j++){
for(int m=0;m<k;m++){
bool f=1,s=1;
for(int l=0;l<=i;l++){
if(str[i][j][l]!=str[i+1][m][l])f=0;
if(str[i][j][l]!=str[i+1][m][l+1])s=0;
}
if(f||s)dp[i][j]+=dp[i+1][m];
dp[i][j]%=MOD;
}
}
}
ll ans=0;
for(int i=0;i<k;i++)ans+=dp[0][i];
printf("%lld",ans);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |