Submission #999012

#TimeUsernameProblemLanguageResultExecution timeMemory
999012vjudge1Trener (COCI20_trener)C++17
110 / 110
171 ms18384 KiB
#include <bits/stdc++.h> using namespace std; #define int long long const int mod = 1e9 + 7; signed main() { int n,k; cin>>n>>k; map<string,int> ans,cnt; int fin_ans=0,iv = (mod+1)/2; for (int a=1;a<=n;a++) for (int b=0;b<k;b++) { string s; cin>>s; cnt[s]++; if (a==1) { ans[s]=1; continue; } int x=0; string s1=s.substr(0,a-1),s2=s.substr(1,a-1); if (ans.find(s1)!=ans.end()) x+=ans[s1]*cnt[s1]%mod; if (ans.find(s2)!=ans.end()) x+=ans[s2]*cnt[s2]%mod; x%=mod; if (s1==s2) x=x*iv%mod; ans[s]=x; if (a==n) fin_ans+=x,fin_ans%=mod; } cout<<fin_ans<<endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...