답안 #60089

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
60089 2018-07-23T16:04:00 Z Hassoony Tents (JOI18_tents) C++17
100 / 100
559 ms 71804 KB
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const int MX=3009;
const ll mod=1e9+7;
ll n,m,dp[MX][MX];
ll DP(ll x,ll rem){
    if(x>n)return 0;
    if(rem==0)return 1ll;
    if(rem<0)return 0;
    if(x==n)return (rem!=m)*1ll;
    ll &ret=dp[x][rem];if(ret!=-1)return ret;
    ret=DP(x+1,rem)%mod;
    ret=(ret+(DP(x+1,rem-1)*4*rem)%mod)%mod;
    ret=(ret+(DP(x+1,rem-2)*(rem*(rem-1)/2))%mod)%mod;
    ret=(ret+(DP(x+2,rem-1)*rem*(n-x-1))%mod)%mod;
    return ret;
}
int main(){
    cin>>n>>m;
    memset(dp,-1,sizeof(dp));
    cout<<DP(0,m)<<endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 65 ms 71160 KB Output is correct
2 Correct 68 ms 71276 KB Output is correct
3 Correct 62 ms 71320 KB Output is correct
4 Correct 65 ms 71392 KB Output is correct
5 Correct 58 ms 71392 KB Output is correct
6 Correct 62 ms 71392 KB Output is correct
7 Correct 66 ms 71392 KB Output is correct
8 Correct 62 ms 71480 KB Output is correct
9 Correct 64 ms 71480 KB Output is correct
10 Correct 65 ms 71516 KB Output is correct
11 Correct 57 ms 71516 KB Output is correct
12 Correct 67 ms 71516 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 65 ms 71160 KB Output is correct
2 Correct 68 ms 71276 KB Output is correct
3 Correct 62 ms 71320 KB Output is correct
4 Correct 65 ms 71392 KB Output is correct
5 Correct 58 ms 71392 KB Output is correct
6 Correct 62 ms 71392 KB Output is correct
7 Correct 66 ms 71392 KB Output is correct
8 Correct 62 ms 71480 KB Output is correct
9 Correct 64 ms 71480 KB Output is correct
10 Correct 65 ms 71516 KB Output is correct
11 Correct 57 ms 71516 KB Output is correct
12 Correct 67 ms 71516 KB Output is correct
13 Correct 73 ms 71516 KB Output is correct
14 Correct 70 ms 71516 KB Output is correct
15 Correct 357 ms 71708 KB Output is correct
16 Correct 60 ms 71708 KB Output is correct
17 Correct 84 ms 71708 KB Output is correct
18 Correct 137 ms 71708 KB Output is correct
19 Correct 336 ms 71708 KB Output is correct
20 Correct 282 ms 71708 KB Output is correct
21 Correct 175 ms 71708 KB Output is correct
22 Correct 192 ms 71708 KB Output is correct
23 Correct 167 ms 71804 KB Output is correct
24 Correct 520 ms 71804 KB Output is correct
25 Correct 338 ms 71804 KB Output is correct
26 Correct 434 ms 71804 KB Output is correct
27 Correct 559 ms 71804 KB Output is correct