Submission #1119657

# Submission time Handle Problem Language Result Execution time Memory
1119657 2024-11-27T09:32:19 Z ezzzay Trener (COCI20_trener) C++14
110 / 110
925 ms 132200 KB
#include<bits/stdc++.h>
using namespace std;
#define itn long long
#define int long long
#define ff first
#define ss second
#define pb push_back
const int N=2003;
string a[N][N];
int dp[N][N];
const int mod=1e9+7;
signed main(){
    int n,k;
    cin>>n>>k;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=k;j++)cin>>a[i][j];
    }
    for(int i=1;i<=k;i++)dp[1][i]=1;
    
    for(int i=2;i<=n;i++){
        for(int j=1;j<=k;j++){
            string x=a[i][j];
            string y=x.substr(0,i-1);
            string w=x.substr(1,i-1);
            for(int p=1;p<=k;p++){
                if(a[i-1][p]==y or a[i-1][p]==w){
                    dp[i][j]+=dp[i-1][p];
                    dp[i][j]%=mod;
                }
            }
        }
    }
    int ans=0;
    for(int i=1;i<=k;i++){
        ans+=dp[n][i];
        ans%=mod;
    }
    cout<<ans;
}
# Verdict Execution time Memory Grader output
1 Correct 106 ms 126024 KB Output is correct
2 Correct 113 ms 126068 KB Output is correct
3 Correct 99 ms 126004 KB Output is correct
4 Correct 97 ms 126060 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 103 ms 126540 KB Output is correct
2 Correct 110 ms 126548 KB Output is correct
3 Correct 109 ms 126536 KB Output is correct
4 Correct 110 ms 126536 KB Output is correct
5 Correct 107 ms 126536 KB Output is correct
6 Correct 99 ms 126536 KB Output is correct
7 Correct 94 ms 126536 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 106 ms 126024 KB Output is correct
2 Correct 113 ms 126068 KB Output is correct
3 Correct 99 ms 126004 KB Output is correct
4 Correct 97 ms 126060 KB Output is correct
5 Correct 103 ms 126540 KB Output is correct
6 Correct 110 ms 126548 KB Output is correct
7 Correct 109 ms 126536 KB Output is correct
8 Correct 110 ms 126536 KB Output is correct
9 Correct 107 ms 126536 KB Output is correct
10 Correct 99 ms 126536 KB Output is correct
11 Correct 94 ms 126536 KB Output is correct
12 Correct 925 ms 132180 KB Output is correct
13 Correct 821 ms 132136 KB Output is correct
14 Correct 839 ms 131916 KB Output is correct
15 Correct 859 ms 132172 KB Output is correct
16 Correct 850 ms 131916 KB Output is correct
17 Correct 860 ms 132200 KB Output is correct
18 Correct 880 ms 132048 KB Output is correct
19 Correct 906 ms 131920 KB Output is correct
20 Correct 817 ms 132156 KB Output is correct
21 Correct 815 ms 132100 KB Output is correct
22 Correct 849 ms 132132 KB Output is correct