# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
219356 |
2020-04-05T07:35:02 Z |
Vimmer |
Trener (COCI20_trener) |
C++14 |
|
2000 ms |
15736 KB |
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("fast-math")
#pragma GCC optimize("no-stack-protector")
#define F first
#define S second
#define sz(x) ll(x.size())
#define pb push_back
#define N 75005
#define M ll(1e9 + 7)
using namespace std;
typedef long double ld;
typedef long long ll;
typedef short int si;
ll dp[51][1501];
int main()
{
ios_base::sync_with_stdio(0); istream::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int n, k;
cin >> n >> k;
string s[n][k][3];
for (register int i = 0; i < n; i++)
for (register int j = 0; j < k; j++) {cin >> s[i][j][0]; if (i != 0) {s[i][j][1] = s[i][j][0].substr(0, i); s[i][j][2] = s[i][j][0].substr(1);} }
for (register int i = 0; i < k; i++) dp[0][i] = 1;
for (register int i = 0; i < n - 1; i++)
for (register int j = 0; j < k; j++)
{
if (dp[i][j] == 0) continue;
for (register int u = 0; u < k; u++) if (s[i][j][0] == s[i + 1][u][1] || s[i][j][0] == s[i + 1][u][2]) dp[i + 1][u] = (dp[i + 1][u] + dp[i][j]) % M;
}
ll ans = 0;
for (register int i = 0; i < k; i++) ans = (ans + dp[n - 1][i]) % M;
cout << ans << endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
4 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
1536 KB |
Output is correct |
2 |
Correct |
12 ms |
1536 KB |
Output is correct |
3 |
Correct |
12 ms |
1536 KB |
Output is correct |
4 |
Correct |
9 ms |
1536 KB |
Output is correct |
5 |
Correct |
16 ms |
1536 KB |
Output is correct |
6 |
Correct |
17 ms |
1536 KB |
Output is correct |
7 |
Correct |
9 ms |
1536 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
4 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
12 ms |
1536 KB |
Output is correct |
6 |
Correct |
12 ms |
1536 KB |
Output is correct |
7 |
Correct |
12 ms |
1536 KB |
Output is correct |
8 |
Correct |
9 ms |
1536 KB |
Output is correct |
9 |
Correct |
16 ms |
1536 KB |
Output is correct |
10 |
Correct |
17 ms |
1536 KB |
Output is correct |
11 |
Correct |
9 ms |
1536 KB |
Output is correct |
12 |
Correct |
1511 ms |
15596 KB |
Output is correct |
13 |
Correct |
1529 ms |
15736 KB |
Output is correct |
14 |
Correct |
1501 ms |
15512 KB |
Output is correct |
15 |
Correct |
1496 ms |
15604 KB |
Output is correct |
16 |
Correct |
602 ms |
15572 KB |
Output is correct |
17 |
Execution timed out |
2083 ms |
15496 KB |
Time limit exceeded |
18 |
Halted |
0 ms |
0 KB |
- |