답안 #94005

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
94005 2019-01-14T15:01:01 Z brcode Tents (JOI18_tents) C++14
100 / 100
116 ms 71040 KB
#include <iostream>

using namespace std;
long long dp[3010][3010];
const long long mod = 1e9+7;
int main() {
    long long n,m;
    cin>>n>>m;
    for(long long i=0;i<=3010;i++){
        dp[0][i] = 1;
        dp[i][0] = 1;
    }
    for(long long i=1;i<=n;i++){
        for(long long j=1;j<=m;j++){
            
                dp[i][j] = dp[i-1][j];

            dp[i][j] += (4*j*dp[i-1][j-1]);
            dp[i][j]+=mod;
            dp[i][j]%=mod;
            dp[i][j] += ((j*(j-1))/2)*dp[i-1][j-2];
            dp[i][j]+=mod;
            dp[i][j]%=mod;
            dp[i][j] += (j*(i-1))*dp[i-2][j-1];
            dp[i][j]+=mod;
            dp[i][j]%=mod;
        }
    }
    cout<<dp[n][m]-1<<endl;
}

Compilation message

tents.cpp: In function 'int main()':
tents.cpp:10:18: warning: iteration 3010 invokes undefined behavior [-Waggressive-loop-optimizations]
         dp[0][i] = 1;
         ~~~~~~~~~^~~
tents.cpp:9:24: note: within this loop
     for(long long i=0;i<=3010;i++){
                       ~^~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 12536 KB Output is correct
2 Correct 9 ms 12536 KB Output is correct
3 Correct 9 ms 12536 KB Output is correct
4 Correct 9 ms 12408 KB Output is correct
5 Correct 9 ms 12664 KB Output is correct
6 Correct 9 ms 12664 KB Output is correct
7 Correct 11 ms 12664 KB Output is correct
8 Correct 9 ms 12664 KB Output is correct
9 Correct 11 ms 12612 KB Output is correct
10 Correct 11 ms 12792 KB Output is correct
11 Correct 11 ms 12536 KB Output is correct
12 Correct 10 ms 13432 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 12536 KB Output is correct
2 Correct 9 ms 12536 KB Output is correct
3 Correct 9 ms 12536 KB Output is correct
4 Correct 9 ms 12408 KB Output is correct
5 Correct 9 ms 12664 KB Output is correct
6 Correct 9 ms 12664 KB Output is correct
7 Correct 11 ms 12664 KB Output is correct
8 Correct 9 ms 12664 KB Output is correct
9 Correct 11 ms 12612 KB Output is correct
10 Correct 11 ms 12792 KB Output is correct
11 Correct 11 ms 12536 KB Output is correct
12 Correct 10 ms 13432 KB Output is correct
13 Correct 9 ms 12536 KB Output is correct
14 Correct 9 ms 12536 KB Output is correct
15 Correct 74 ms 56184 KB Output is correct
16 Correct 13 ms 15352 KB Output is correct
17 Correct 24 ms 22308 KB Output is correct
18 Correct 27 ms 24568 KB Output is correct
19 Correct 84 ms 63352 KB Output is correct
20 Correct 77 ms 53240 KB Output is correct
21 Correct 52 ms 39288 KB Output is correct
22 Correct 53 ms 38904 KB Output is correct
23 Correct 34 ms 27128 KB Output is correct
24 Correct 116 ms 71040 KB Output is correct
25 Correct 94 ms 63096 KB Output is correct
26 Correct 97 ms 67576 KB Output is correct
27 Correct 111 ms 69496 KB Output is correct