# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
942734 | artixkrishna | Mate (COCI18_mate) | C++14 | 213 ms | 68084 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define mod (1000000000 + 7)
#define N 2005
typedef long long ll;
string s;
int q, n, qtd[30][N];
ll dp[N][30][30], ch[N][N];
vector<int> pos[30];
ll choose(int a, int b) {
if (a == b || b == 0)
return 1;
if (b == 1)
return a;
if (b > a)
return 0;
if (ch[a][b] != -1)
return ch[a][b];
return ch[a][b] = (choose(a - 1, b - 1) + choose(a - 1, b)) % mod;
}
void solve(int a, int b) {
for (int len = 1; len <= n; len++) {
for (int i = 0; i < pos[a].size(); i++) {
int x = pos[a][i];
dp[len][a][b] += ((ll)qtd[b][x + 1] * choose(x - 1, len - 2)) % mod;
dp[len][a][b] %= mod;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |