답안 #200982

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
200982 2020-02-09T02:37:34 Z model_code Zapina (COCI20_zapina) C++17
110 / 110
356 ms 3448 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef double lf;
typedef long double Lf;
typedef pair <int,int> pii;
typedef pair <ll, ll> pll;

#define TRACE(x) cerr << #x << "  " << x << endl
#define FOR(i, a, b) for (int i = (a); i < int(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define _ << " " <<

#define fi first
#define sec second
#define mp make_pair
#define pb push_back

const int MAXN = 501;
const int MOD = 1e9 + 7;

int add(int a, int b) {
  a += b;
  if (a >= MOD) a -= MOD;
  return a;
}

int mul(int a, int b) {
  return (ll)a * b % MOD;
}

int n, dp[2][MAXN][MAXN];
int povrh[MAXN][MAXN];

int rek(int ok, int a, int b) {
  if (b == n + 1) {
    if (a != 0) return 0;
    return ok;
  }
  if (a == 0) return ok;
  if (dp[ok][a][b] != -1) return dp[ok][a][b];
  int ret = 0;
  REP(i, a + 1) {
    ret = add(ret, mul(povrh[a][i], rek(ok | (b == i), a - i, b + 1)));
  }
  return dp[ok][a][b] = ret;
}

int main() {
  cin >> n;
  memset(dp, -1, sizeof dp);
  povrh[0][0] = 1;
  FOR(i, 1, MAXN) {
    REP(j, i + 1) {
      povrh[i][j] = povrh[i - 1][j];
      if (j) povrh[i][j] = add(povrh[i][j], povrh[i - 1][j - 1]);
    }
  }
  cout << rek(0, n, 1) << endl;
  return 0;
}

# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 3192 KB Output is correct
2 Correct 6 ms 3192 KB Output is correct
3 Correct 6 ms 3192 KB Output is correct
4 Correct 7 ms 3192 KB Output is correct
5 Correct 7 ms 3192 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 3192 KB Output is correct
2 Correct 6 ms 3192 KB Output is correct
3 Correct 6 ms 3192 KB Output is correct
4 Correct 7 ms 3192 KB Output is correct
5 Correct 7 ms 3192 KB Output is correct
6 Correct 6 ms 3324 KB Output is correct
7 Correct 6 ms 3064 KB Output is correct
8 Correct 6 ms 3320 KB Output is correct
9 Correct 7 ms 3372 KB Output is correct
10 Correct 6 ms 3192 KB Output is correct
11 Correct 7 ms 3320 KB Output is correct
12 Correct 6 ms 3192 KB Output is correct
13 Correct 6 ms 3320 KB Output is correct
14 Correct 7 ms 3192 KB Output is correct
15 Correct 6 ms 3320 KB Output is correct
16 Correct 6 ms 3192 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 3192 KB Output is correct
2 Correct 6 ms 3192 KB Output is correct
3 Correct 6 ms 3192 KB Output is correct
4 Correct 7 ms 3192 KB Output is correct
5 Correct 7 ms 3192 KB Output is correct
6 Correct 6 ms 3324 KB Output is correct
7 Correct 6 ms 3064 KB Output is correct
8 Correct 6 ms 3320 KB Output is correct
9 Correct 7 ms 3372 KB Output is correct
10 Correct 6 ms 3192 KB Output is correct
11 Correct 7 ms 3320 KB Output is correct
12 Correct 6 ms 3192 KB Output is correct
13 Correct 6 ms 3320 KB Output is correct
14 Correct 7 ms 3192 KB Output is correct
15 Correct 6 ms 3320 KB Output is correct
16 Correct 6 ms 3192 KB Output is correct
17 Correct 154 ms 3324 KB Output is correct
18 Correct 8 ms 3192 KB Output is correct
19 Correct 40 ms 3320 KB Output is correct
20 Correct 7 ms 3320 KB Output is correct
21 Correct 216 ms 3320 KB Output is correct
22 Correct 28 ms 3320 KB Output is correct
23 Correct 8 ms 3192 KB Output is correct
24 Correct 48 ms 3320 KB Output is correct
25 Correct 46 ms 3320 KB Output is correct
26 Correct 65 ms 3320 KB Output is correct
27 Correct 287 ms 3448 KB Output is correct
28 Correct 308 ms 3320 KB Output is correct
29 Correct 308 ms 3320 KB Output is correct
30 Correct 322 ms 3448 KB Output is correct
31 Correct 303 ms 3448 KB Output is correct
32 Correct 313 ms 3448 KB Output is correct
33 Correct 304 ms 3320 KB Output is correct
34 Correct 330 ms 3448 KB Output is correct
35 Correct 335 ms 3320 KB Output is correct
36 Correct 356 ms 3348 KB Output is correct
37 Correct 326 ms 3428 KB Output is correct