Submission #659054

#TimeUsernameProblemLanguageResultExecution timeMemory
659054iloveroseanneTrener (COCI20_trener)C++14
110 / 110
83 ms2796 KiB
// Author: Ngo Ba Van #include<bits/stdc++.h> using namespace std; #define ll long long #define fi first #define se second using ii=pair<ll,ll>; const ll N=1e3+5,M=1e9+7; ll n,res,dp[N][N],k; map<string,ll>m[2]; string s; void nhap() { cin>>n>>k; int a=0,b=1; m[0][""]=1; for (int i=1;i<=n;i++) { for (int j=1;j<=k;j++) { res=0; cin>>s; string t1,t2; t1=s.substr(0,s.size()-1); t2=s.substr(1,s.size()-1); if (m[a].count(t1)) res=(res+m[a][t1])%M; if (t1!=t2) { if (m[a].count(t2)) res=(res+m[a][t2])%M; } m[b][s]=(m[b][s]+res)%M; } swap(a,b); m[b].clear(); } res=0; for (auto i:m[a]) res=(res+i.se)%M; cout<<res%M; } int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); #define task "a" //define task "" int t=1; //cin>>t; while (t--) nhap(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...