# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
845207 | vjudge1 | Trener (COCI20_trener) | C++17 | 11 ms | 1372 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
#define all(aa) aa.begin(), aa.end()
const int mod=1e9+7;
int main(){
int n, k;
cin>>n>>k;
int ans;
map<string, int> dp;
for(int j=0; j<k; j++){
string s;
cin>>s;
dp[s]=1;
}
for(int i=1; i<n; i++){
ans=0;
for(int j=0; j<k; j++){
string s;
cin>>s;
string a(s.begin(), s.end()-1), b(s.begin()+1, s.end());
if(a==b) dp[s]=dp[a];
else dp[s]=(dp[a]+dp[b])%mod;
ans=(ans+dp[s])%mod;
}
}
cout<<ans<<endl;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |