Submission #1119655

#TimeUsernameProblemLanguageResultExecution timeMemory
1119655ezzzayTrener (COCI20_trener)C++14
0 / 110
126 ms127368 KiB
#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]; const int mod=1e9+7; map<string,int>dp; 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[a[1][i]]++; } for(int i=2;i<=n;i++){ set<string>st; for(int j=1;j<=k;j++){ string x=a[i][j]; st.insert(x); } for(auto x:st){ string y=x; y.pop_back(); dp[x]+=dp[y]; if(x.substr(1,i-1)!=y)dp[x]+=dp[x.substr(1,i-1)]; dp[x]%=mod; } } int ans=0; set<string>st; for(int i=1;i<=k;i++){ st.insert(a[n][i]); } for(auto x:st){ ans+=dp[x]; ans%=mod; } cout<<ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...