답안 #45862

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
45862 2018-04-16T09:32:06 Z khohko Tents (JOI18_tents) C++17
100 / 100
292 ms 82812 KB
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
#define ll long long
#define lol long long
#define pb push_back
//#define mp make_pair
#define fr first
#define sc second
#define MAX ((lol)(1e9+100))
#define MX ((lol)(4e9+100))
#define ARRS ((lol)(5e5+100))
#define MOD ((lol)(1e9+7))
#define EP ((double)(1e-9))
#define EPS ((double)(1e-8))
#define pb push_back
#define PI ((double)3.141592653)
#define LG 21

ll dp[4000][4000];


ll go(ll n,ll m){
    if(n<0||m<0)return 0;
    if(n==0||m==0)return 1;
    if(dp[n][m]>=0)return dp[n][m];
   // cout<<m*(m-1)/2<<endl;
    //        10              1*1
    dp[n][m]=go(n-1,m)+m*(m-1)/2*go(n-1,m-2)+m*(n-1)*go(n-2,m-1)+m*4*go(n-1,m-1);
   // cout<<n<<" "<<m<<" "<<dp[n][m]<<endl;
    dp[n][m]%=MOD;
    return dp[n][m];
}


int main(){
    #ifdef KHOKHO
        freopen("in.in","r",stdin);
        freopen("out.out","w",stdout);
    #endif // KHOKHO
    ios::sync_with_stdio(0);
    ll n,m;
    cin>>n>>m;
    for(int i=0; i<=n; i++){
        for(int j=0; j<=m; j++){
            dp[i][j]=-1;
        }
    }
    cout<<go(n,m)-1;

}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 488 KB Output is correct
3 Correct 2 ms 608 KB Output is correct
4 Correct 2 ms 1176 KB Output is correct
5 Correct 2 ms 1176 KB Output is correct
6 Correct 3 ms 1440 KB Output is correct
7 Correct 2 ms 1440 KB Output is correct
8 Correct 3 ms 1452 KB Output is correct
9 Correct 2 ms 1452 KB Output is correct
10 Correct 3 ms 2036 KB Output is correct
11 Correct 2 ms 2036 KB Output is correct
12 Correct 4 ms 2540 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 488 KB Output is correct
3 Correct 2 ms 608 KB Output is correct
4 Correct 2 ms 1176 KB Output is correct
5 Correct 2 ms 1176 KB Output is correct
6 Correct 3 ms 1440 KB Output is correct
7 Correct 2 ms 1440 KB Output is correct
8 Correct 3 ms 1452 KB Output is correct
9 Correct 2 ms 1452 KB Output is correct
10 Correct 3 ms 2036 KB Output is correct
11 Correct 2 ms 2036 KB Output is correct
12 Correct 4 ms 2540 KB Output is correct
13 Correct 2 ms 2540 KB Output is correct
14 Correct 8 ms 10108 KB Output is correct
15 Correct 131 ms 55728 KB Output is correct
16 Correct 5 ms 55728 KB Output is correct
17 Correct 19 ms 55728 KB Output is correct
18 Correct 33 ms 55728 KB Output is correct
19 Correct 151 ms 63612 KB Output is correct
20 Correct 117 ms 63612 KB Output is correct
21 Correct 70 ms 63612 KB Output is correct
22 Correct 76 ms 63612 KB Output is correct
23 Correct 54 ms 63612 KB Output is correct
24 Correct 200 ms 82812 KB Output is correct
25 Correct 145 ms 82812 KB Output is correct
26 Correct 196 ms 82812 KB Output is correct
27 Correct 292 ms 82812 KB Output is correct