Submission #238473

#TimeUsernameProblemLanguageResultExecution timeMemory
238473akatTrener (COCI20_trener)C++14
22 / 110
9 ms1408 KiB
#include<bits/stdc++.h> using namespace std; unordered_map<string,int>h; const int MOD = 1e9 + 7; int main() { ios_base::sync_with_stdio(0); cin.tie(0); long long n,k,i,j,curr,ans = 0; string s,sub1,sub2; cin>>n>>k; for(i = 0; i < n; i++) for(j = 0; j < k; j++) { cin>>s; sub1 = s.substr(0,i); sub2 = s.substr(1,i); curr = h[sub1];; if(sub1 != sub2) curr += h[sub2]; if(curr >= MOD) curr -= MOD; if(i==0) curr++; h[s] += curr; if(i == n-1) ans += curr; if(ans >= MOD) ans -= MOD; } cout<<ans<<'\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...