Submission #223219

#TimeUsernameProblemLanguageResultExecution timeMemory
223219errorgornTrener (COCI20_trener)C++14
110 / 110
139 ms1020 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define ii pair<ll,ll> #define iii pair<ll,ii> #define endl '\n' const int MOD=1000000007; int n,k; map<string,ll> m[2]; int main(){ ios::sync_with_stdio(0); cin.tie(0); cin>>n>>k; m[0][""]=1; int a=0,b=1; for (int x=0;x<n;x++){ for (int y=0;y<k;y++){ string s,t1,t2; ll res=0; cin>>s; 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]+=res; m[b][s]%=MOD; //cout<<s<<" "<<res<<endl; } swap(a,b); m[b].clear(); } ll ans=0; for (auto &it:m[a]){ ans+=it.second; } cout<<ans%MOD<<endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...