# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
223294 | dantoh000 | Trener (COCI20_trener) | C++14 | 21 ms | 4224 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;
typedef long long ll;
const int mod = 1000000007;
int n,k;
map<string,int> ct[55];
string a[55][1505];
int main(){
scanf("%d%d",&n,&k);
for (int i = 1; i <= n; i++){
for (int j = 1; j <= k; j++){
cin >> a[i][j];
}
}
ll ans = 0;
ct[0][""]++;
for (int i = 1; i <= n; i++){
for (int j = 1; j <= k; j++){
string X = a[i][j].substr(1);
string Y = a[i][j].substr(0,a[i][j].size()-1);
//cout << a[i][j] << " " << X << " " << Y;
int res = ct[i-1][X];
if (X != Y) res += ct[i-1][Y];
//printf("%d %d\n",ct[X],ct[Y]);
ct[i][a[i][j]] += res;
ct[i][a[i][j]] %= mod;
if (i == n) ans += res;
}
}
printf("%lld",ans%mod);
}
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... |