제출 #234493

#제출 시각아이디문제언어결과실행 시간메모리
234493dooweyZapina (COCI20_zapina)C++14
110 / 110
193 ms2168 KiB
#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;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...