# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
895487 | box | Ruins 3 (JOI20_ruins3) | C++17 | 158 ms | 3416 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 ar array
#define sz(v) int(std::size(v))
using i64 = long long;
const int MAXN = 606;
const int MOD = 1e9 + 7;
int N;
bool use[MAXN * 2];
int take[MAXN][MAXN];
int nck[MAXN][MAXN];
int dp[MAXN + 1], ndp[MAXN + 1];
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> N;
for (int i = 0; i < N; i++) {
int x;
cin >> x;
use[x] = 1;
}
take[0][0] = 1;
for (int n = 1; n <= N; n++) for (int k = 0; k <= n; k++) {
i64 x = take[n - 1][k];
if (k >= 1) x += (i64) take[n - 1][k - 1] * 2 * k;
if (k >= 2) x += (i64) take[n - 1][k - 2] * k * (k - 1);
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |