# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
223204 | tqbfjotld | Trener (COCI20_trener) | C++14 | 261 ms | 16068 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 MOD 1000000007
unordered_map<string,int> ways;
int main(){
int n,k;
cin>>n;
cin>>k;
for (int x = 0; x<n; x++){
for (int y = 0; y<k; y++){
string str;
cin>>str;
if (str.size()==1){
ways[str]++;
}
else{
string str1 = "";
string str2 = "";
for (int i = 0; i<str.size(); i++){
if (i!=0){
str2 += str[i];
}
if (i!=str.size()-1){
str1+=str[i];
}
}
if (str1!=str2){
ways[str] += ways[str1];
ways[str] %= MOD;
ways[str] += ways[str2];
ways[str] %= MOD;
}
else{
ways[str] += ways[str1];
ways[str] %=MOD;
}
}
}
}
int ans = 0;
for (auto x : ways){
if (x.first.size()==n){
ans += x.second;
ans %= MOD;
}
}
printf("%d",ans);
}
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... |