Submission #845309

#TimeUsernameProblemLanguageResultExecution timeMemory
845309vjudge1Trener (COCI20_trener)C++14
110 / 110
189 ms22624 KiB
// Aber der schlimmste Fiend, dem du begegnen kannst, wirst du immer dir selber sein #include <bits/stdc++.h> #pragma GCC optimize("O3") #pragma GCC optimize("Ofast,unroll-loops") #pragma GCC target("avx2,popcnt,lzcnt,abm,bmi,bmi2,fma,tune=native") #define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL); #define ff first #define ss second #define pb push_back #define rev reverse #define all(x) x.begin(),x.end() #define acc accumulate #define sz size() #define MOD 1000000007 #define rall(x) x.rbegin(),x.rend() #define rep(i, x, n) for(int i = x; i < n; i++) using namespace std; const int N = 2e5 + 5; inline void solve(){ int n, k; cin >> n >> k; map<string, int> mp; string ma[n][k]; for(int i = 0; i < n; i++){ for(int j = 0; j < k; j++){ cin >> ma[i][j]; } } for(int i = 0; i < k; i++){ mp[ma[n-1][i]] = 1; } for(int i = n-1; i > 0; i--){ for(int j = 0; j < k; j++){ string s1 = ma[i][j].substr(0, i), s2 = ma[i][j].substr(1, i); mp[s1] = (mp[ma[i][j]] + mp[s1]) % MOD; if(s1 != s2){ mp[s2] = (mp[s2] + mp[ma[i][j]]) % MOD; } } } int ans = 0; for(int i = 0; i < k; i++){ ans = (ans + mp[ma[0][i]]) % MOD; } cout << ans << endl; } int main(){ fast_io int t; t = 1; while(t--) solve(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...