답안 #1077654

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1077654 2024-08-27T08:30:10 Z MC123 Tents (JOI18_tents) C++14
100 / 100
265 ms 67668 KB
#include <bits/stdc++.h>
using namespace std;
long long bruh=1e9+7;
bool d[3001][3001];
long long mem[3001][3001];
long long dp(long long n,long long m){
    if(n<0||m<0)return 0;
    if(n==0||m==0)return 1;
    if(d[n][m])return mem[n][m];
    d[n][m]=1;
    return mem[n][m]=(((dp(n-1,m)%bruh+(4*m*dp(n-1,m  -1))%bruh)%bruh+(dp(n-1,m-2)*m*(m-1)/2)%bruh)%bruh+(dp(n-2,m-1)*m*(n-1))%bruh)%bruh;
}
int main(){
    ios_base::sync_with_stdio (0);
    cin.tie(0);
    cout.tie(0);
    long long n,m;
    cin>>n>>m;
    cout<<dp(n,m)-1 ;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 2652 KB Output is correct
4 Correct 1 ms 7260 KB Output is correct
5 Correct 1 ms 2652 KB Output is correct
6 Correct 2 ms 7260 KB Output is correct
7 Correct 1 ms 2652 KB Output is correct
8 Correct 1 ms 7232 KB Output is correct
9 Correct 2 ms 5112 KB Output is correct
10 Correct 2 ms 9564 KB Output is correct
11 Correct 0 ms 2396 KB Output is correct
12 Correct 4 ms 9564 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 2652 KB Output is correct
4 Correct 1 ms 7260 KB Output is correct
5 Correct 1 ms 2652 KB Output is correct
6 Correct 2 ms 7260 KB Output is correct
7 Correct 1 ms 2652 KB Output is correct
8 Correct 1 ms 7232 KB Output is correct
9 Correct 2 ms 5112 KB Output is correct
10 Correct 2 ms 9564 KB Output is correct
11 Correct 0 ms 2396 KB Output is correct
12 Correct 4 ms 9564 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 7 ms 16524 KB Output is correct
15 Correct 153 ms 55408 KB Output is correct
16 Correct 4 ms 2392 KB Output is correct
17 Correct 16 ms 9048 KB Output is correct
18 Correct 44 ms 16976 KB Output is correct
19 Correct 190 ms 61888 KB Output is correct
20 Correct 159 ms 49488 KB Output is correct
21 Correct 82 ms 30304 KB Output is correct
22 Correct 92 ms 44216 KB Output is correct
23 Correct 63 ms 41556 KB Output is correct
24 Correct 265 ms 67668 KB Output is correct
25 Correct 192 ms 56912 KB Output is correct
26 Correct 236 ms 62800 KB Output is correct
27 Correct 241 ms 65676 KB Output is correct