Submission #1097530

#TimeUsernameProblemLanguageResultExecution timeMemory
1097530hiensumiTrener (COCI20_trener)C++14
55 / 110
2076 ms2420 KiB
#include <bits/stdc++.h> using namespace std; #define fod(i,a,b) for(int i = (int) (a); i <= (int) (b); i++) #define fok(i,a,b) for(int i = (int) (a); i >= (int) (b); i--) #define ll long long #define pb push_back #define pii pair<int,int> #define mp make_pair #define fi first #define se second #define el '\n' #define ve vector #define vi ve<int> #define vll ve<ll> #define mask(a) (1LL<<(a)) #define BIT(msk,i) (msk>>(i)&1LL) using namespace std; template <class T> bool mini(T &a, T b){ return (a > (b)) ? a = (b), 1 : 0; } template <class T> bool maxi(T &a, T b){ return (a < (b)) ? a = (b), 1 : 0; } #define name "trener" const int MOD = 1e9 + 7; inline void madd(int &a, int b){ a += b; if(a >= MOD) a -= MOD; else if(a < 0) a += MOD; } int n, k; unordered_map <string, int> dp; int main(){ ios_base::sync_with_stdio(false); cin.tie(0); cin >> n >> k; string s; fod(i,1,k){ cin >> s; dp[s]++; } fod(i,2,n){ unordered_map <string, int> new_dp; fod(j,1,k){ string s; cin >> s; new_dp[s]++; } unordered_map <string, int> cnt = new_dp; for(auto &x : new_dp){ x.se = 0; for(auto y : dp) if(x.fi.find(y.fi) != string::npos){ madd(x.se, 1LL * cnt[x.fi] * y.se % MOD); } } swap(dp, new_dp); } int res = 0; for(auto &x : dp) madd(res, x.se); cout << res; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...