# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
845236 |
2023-09-06T12:43:52 Z |
vjudge1 |
Trener (COCI20_trener) |
C++17 |
|
29 ms |
864 KB |
#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 time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
24 ms |
864 KB |
Output is correct |
2 |
Correct |
29 ms |
604 KB |
Output is correct |
3 |
Correct |
24 ms |
604 KB |
Output is correct |
4 |
Incorrect |
18 ms |
860 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
24 ms |
864 KB |
Output is correct |
6 |
Correct |
29 ms |
604 KB |
Output is correct |
7 |
Correct |
24 ms |
604 KB |
Output is correct |
8 |
Incorrect |
18 ms |
860 KB |
Output isn't correct |
9 |
Halted |
0 ms |
0 KB |
- |