답안 #72433

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
72433 2018-08-26T08:06:42 Z MANcity Tents (JOI18_tents) C++14
100 / 100
202 ms 71232 KB
#include<iostream>
#include<cstdio>
#include<fstream>
#include<algorithm>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<cstring>
#include<vector>
using namespace std;
#define for1(i,n) for(int i=1;i<=(int)n;i++)
#define for0(i,n) for(int i=0;i<=(int)n;i++)
#define forn(i,n) for(int i=n;i>=1;i--)
#define fo(i,x,y) for(int i=x;i<=(int)y;i++)
#define fr(i,x,y) for(int i=x;i>=(int)y;i--)
#define pb push_back
#define mp make_pair
#define LL long long
const LL Mod=1000*1000*1000+7;
LL dp[3002][3002];
int main()
{
    int w,h;
    cin>>w>>h;
    dp[0][0]=1;
    for1(i,max(w,h))
    {
        dp[i][0]=1;
        dp[0][i]=1;
    }
    for1(i,w)
        for1(j,h)
        {
            LL num2=(j*(j-1))/2;
            dp[i][j]=(dp[i-1][j])%Mod;
            if(j>=2)
                dp[i][j]=(dp[i][j]+((LL)num2*(LL)dp[i-1][j-2])%Mod)%Mod;
            dp[i][j]=(dp[i][j]+((LL)(4*j)*(LL)dp[i-1][j-1])%Mod)%Mod;
            if(i>=2)
                dp[i][j]=(dp[i][j]+((LL)(j*(i-1))*(LL)(dp[i-2][j-1]))%Mod)%Mod;
        }
    cout<<(dp[w][h]-1+Mod)%Mod<<endl;
    return 0;
}
/*
4 3
*/
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 3 ms 1256 KB Output is correct
3 Correct 3 ms 1256 KB Output is correct
4 Correct 3 ms 1260 KB Output is correct
5 Correct 3 ms 1664 KB Output is correct
6 Correct 3 ms 1664 KB Output is correct
7 Correct 3 ms 1664 KB Output is correct
8 Correct 3 ms 1732 KB Output is correct
9 Correct 3 ms 1732 KB Output is correct
10 Correct 5 ms 2020 KB Output is correct
11 Correct 4 ms 2020 KB Output is correct
12 Correct 6 ms 2572 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 3 ms 1256 KB Output is correct
3 Correct 3 ms 1256 KB Output is correct
4 Correct 3 ms 1260 KB Output is correct
5 Correct 3 ms 1664 KB Output is correct
6 Correct 3 ms 1664 KB Output is correct
7 Correct 3 ms 1664 KB Output is correct
8 Correct 3 ms 1732 KB Output is correct
9 Correct 3 ms 1732 KB Output is correct
10 Correct 5 ms 2020 KB Output is correct
11 Correct 4 ms 2020 KB Output is correct
12 Correct 6 ms 2572 KB Output is correct
13 Correct 7 ms 8216 KB Output is correct
14 Correct 10 ms 10112 KB Output is correct
15 Correct 141 ms 55708 KB Output is correct
16 Correct 13 ms 55708 KB Output is correct
17 Correct 32 ms 55708 KB Output is correct
18 Correct 44 ms 55708 KB Output is correct
19 Correct 144 ms 63380 KB Output is correct
20 Correct 117 ms 63380 KB Output is correct
21 Correct 89 ms 63380 KB Output is correct
22 Correct 79 ms 63380 KB Output is correct
23 Correct 59 ms 63380 KB Output is correct
24 Correct 186 ms 71232 KB Output is correct
25 Correct 167 ms 71232 KB Output is correct
26 Correct 189 ms 71232 KB Output is correct
27 Correct 202 ms 71232 KB Output is correct