Submission #845236

#TimeUsernameProblemLanguageResultExecution timeMemory
845236vjudge1Trener (COCI20_trener)C++17
22 / 110
29 ms864 KiB
#include <bits/stdc++.h> #define endl "\n" #define pb push_back #define int long long using namespace std; const int inf = 2e18 + 5; const int N = 5e3 + 5; const int mod = 998244353; int32_t main(){ //freopen("in.txt","r", stdin); int n, k; cin>>n>>k; vector<vector<string> > a(n, vector<string>(k)); for(int i = 0; i < n; i++){ for(int j = 0; j < k; j++){ cin>>a[i][j]; } } vector<vector<int> > dp(n+1, vector<int>(k)); for(int i = 0; i < k; i++){ dp[0][i] = 1; } for(int i = 0; i < n-1; i++){ for(int j = 0; j < k; j++){ for(int l = 0; l < k; l++){ dp[i+1][l] += dp[i][j] * (a[i][j] == a[i+1][l].substr(0, a[i+1][l].size()-1) || a[i][j] == a[i+1][l].substr(1, a[i+1][l].size()-1)); } } } cout<<accumulate(dp[n-1].begin(), dp[n-1].end(), 0)<<endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...