Submission #373072

#TimeUsernameProblemLanguageResultExecution timeMemory
373072NimbostratusTrener (COCI20_trener)C++17
55 / 110
2081 ms8428 KiB
#include <bits/stdc++.h> using namespace std; #define eb emplace_back #define pb push_back #define ppb pop_back #define ub upper_bound #define lb lower_bound #define bs binary_search #define cln(a,s) memset((a),0,sizeof((a)[0])*(s)) #define all(x) (x).begin() , (x).end() #define fi first #define se second #define int int using pii = pair<int,int>; using ll = long long; const int maxn = 55; const int maxk = 1505; const int inf = 1e9; const int mod = 1e9+7; int n,k; string a[maxn][maxk]; int dp[maxn][maxk]; int32_t main () { //freopen("in","r",stdin); freopen("out","w",stdout); ios_base::sync_with_stdio(0); cout.tie(0); cin.tie(0); cin >> n >> k; for(int i=1;i<=n;i++) for(int j=1;j<=k;j++) cin >> a[i][j]; for(int i=1;i<=k;i++) dp[1][i] = 1; for(int i=2;i<=n;i++) for(int j=1;j<=k;j++) { string sub1 = a[i][j].substr(0,i-1); string sub2 = a[i][j].substr(1,i-1); for(int m=1;m<=k;m++) if(a[i-1][m] == sub1 or a[i-1][m] == sub2) { dp[i][j] += dp[i-1][m]; dp[i][j] %= mod; } } int ans = 0; for(int i=1;i<=k;i++) { ans += dp[n][i]; ans %= mod; } cout << ans << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...