Submission #659053

#TimeUsernameProblemLanguageResultExecution timeMemory
659053iloveroseanneTrener (COCI20_trener)C++14
22 / 110
6 ms340 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+=m[a][t1]; if (t1!=t2) { if (m[a].count(t2)) res+=m[a][t2]; } m[b][s]=(m[b][s]+res)%M; } swap(a,b); m[b].clear(); } res=0; for (auto i:m[a]) res+=i.se; cout<<res; } 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...