Submission #570035

#TimeUsernameProblemLanguageResultExecution timeMemory
570035angelo_torresTrener (COCI20_trener)C++17
110 / 110
550 ms103684 KiB
#include <bits/stdc++.h> #define f(i,j,n) for(int i = j; i < n; ++i) #define sz(s) (int) (s.size()) using namespace std; typedef long long ll; const int N = 3e3 + 20; const ll mod = 1e9 + 7; ll sum(ll a,ll b){ return (a+b)%mod; } ll n,k; map<deque<char>,ll> dp; deque<char> s; int main(){ cin >> n >> k; f(i,1,n+1){ f(j,1,k+1){ s.resize(i); f(r,0,i) cin >> s[r]; if(i == 1){ dp[s] = sum(dp[s],1LL); continue; } deque<char> ps = s,ss = s; ss.pop_front(); ps.pop_back(); dp[s] = sum(dp[ss],dp[s]); if(ss != ps) dp[s] = sum(dp[ps],dp[s]); } } ll ans = 0; for(auto [it,vl] : dp){ if(sz(it) == n) ans = sum(ans,vl); } cout << ans << endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...