답안 #234493

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
234493 2020-05-24T10:34:40 Z doowey Zapina (COCI20_zapina) C++14
110 / 110
193 ms 2168 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

const int N = 400;
const int MOD = (int)1e9 + 7;
int dp[N][N][2];
int C[N][N];

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

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

int main(){
  fastIO;
  int n;
  cin >> n;
  for(int i = 0; i < N ; i ++ )
    C[i][0]=1;
  for(int i = 1; i < N; i  ++ ){
    for(int j = 1; j <= i; j ++ ){
      add(C[i][j], C[i-1][j]);
      add(C[i][j], C[i-1][j-1]);
    }
  }
  dp[0][0][0]=1;
  for(int i = 0; i < n; i ++ ){
    for(int j = 0 ; j <= n; j ++ ){
      for(int bit = 0; bit < 2; bit ++ ){
        for(int x = 0; j + x <= n; x ++ ){
          add(dp[i + 1][j + x][(bit | (x == (i + 1)))], 
            mult(dp[i][j][bit],C[n-j][x]) 
          );
        }
      }
    }
  }
  cout << dp[n][n][1] << "\n";
  return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 1024 KB Output is correct
2 Correct 5 ms 1024 KB Output is correct
3 Correct 5 ms 1024 KB Output is correct
4 Correct 5 ms 1024 KB Output is correct
5 Correct 5 ms 1024 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 1024 KB Output is correct
2 Correct 5 ms 1024 KB Output is correct
3 Correct 5 ms 1024 KB Output is correct
4 Correct 5 ms 1024 KB Output is correct
5 Correct 5 ms 1024 KB Output is correct
6 Correct 5 ms 1024 KB Output is correct
7 Correct 5 ms 1024 KB Output is correct
8 Correct 5 ms 1024 KB Output is correct
9 Correct 5 ms 1024 KB Output is correct
10 Correct 5 ms 1024 KB Output is correct
11 Correct 5 ms 1024 KB Output is correct
12 Correct 6 ms 1024 KB Output is correct
13 Correct 5 ms 1024 KB Output is correct
14 Correct 5 ms 1024 KB Output is correct
15 Correct 6 ms 1024 KB Output is correct
16 Correct 5 ms 1024 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 1024 KB Output is correct
2 Correct 5 ms 1024 KB Output is correct
3 Correct 5 ms 1024 KB Output is correct
4 Correct 5 ms 1024 KB Output is correct
5 Correct 5 ms 1024 KB Output is correct
6 Correct 5 ms 1024 KB Output is correct
7 Correct 5 ms 1024 KB Output is correct
8 Correct 5 ms 1024 KB Output is correct
9 Correct 5 ms 1024 KB Output is correct
10 Correct 5 ms 1024 KB Output is correct
11 Correct 5 ms 1024 KB Output is correct
12 Correct 6 ms 1024 KB Output is correct
13 Correct 5 ms 1024 KB Output is correct
14 Correct 5 ms 1024 KB Output is correct
15 Correct 6 ms 1024 KB Output is correct
16 Correct 5 ms 1024 KB Output is correct
17 Correct 92 ms 1896 KB Output is correct
18 Correct 6 ms 1152 KB Output is correct
19 Correct 24 ms 1408 KB Output is correct
20 Correct 5 ms 1024 KB Output is correct
21 Correct 124 ms 1888 KB Output is correct
22 Correct 19 ms 1536 KB Output is correct
23 Correct 6 ms 1152 KB Output is correct
24 Correct 30 ms 1528 KB Output is correct
25 Correct 23 ms 1408 KB Output is correct
26 Correct 39 ms 1528 KB Output is correct
27 Correct 170 ms 2168 KB Output is correct
28 Correct 179 ms 2040 KB Output is correct
29 Correct 174 ms 2040 KB Output is correct
30 Correct 176 ms 2040 KB Output is correct
31 Correct 181 ms 2040 KB Output is correct
32 Correct 183 ms 2040 KB Output is correct
33 Correct 179 ms 2040 KB Output is correct
34 Correct 184 ms 2040 KB Output is correct
35 Correct 187 ms 2040 KB Output is correct
36 Correct 193 ms 2040 KB Output is correct
37 Correct 190 ms 2040 KB Output is correct