답안 #906816

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
906816 2024-01-15T03:37:24 Z lighton Tents (JOI18_tents) C++17
100 / 100
237 ms 119460 KB
#include<bits/stdc++.h>
#define forf(i,a,b) for(int i = a; i<=b; i++)
using namespace std;
typedef long long ll;
ll mod = 1000000007;
int N,M;
ll dp[5005][5005]; // +2
ll c2(ll x){
    return x*(x-1)/2 %mod;
}
int main(){
    scanf("%d %d" , &N ,&M);
    forf(i,2,N+2) dp[i][2] = 1;
    forf(j,2,M+2) dp[2][j] = 1;
    forf(i,3,N+2){
        forf(j,3,M+2){
            ll ri = i-2;
            ll rj = j-2;
            ll d1 = 2 * ri * dp[i-1][j-1] % mod;
            d1 += ri * (rj-1) * dp[i-1][j-2]; d1 %= mod;

            ll d2 = 2 * ri * dp[i-1][j-1] % mod;
            d2 += c2(ri) * dp[i-2][j-1]; d1 %= mod;

            ll d3 = dp[i][j-1] % mod;

            dp[i][j] = (d1+d2+d3) % mod;

        }
    }
    printf("%lld" , dp[N+2][M+2]-1);
}

Compilation message

tents.cpp: In function 'int main()':
tents.cpp:12:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |     scanf("%d %d" , &N ,&M);
      |     ~~~~~^~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 2552 KB Output is correct
4 Correct 2 ms 8540 KB Output is correct
5 Correct 2 ms 4696 KB Output is correct
6 Correct 3 ms 10588 KB Output is correct
7 Correct 2 ms 4444 KB Output is correct
8 Correct 2 ms 10588 KB Output is correct
9 Correct 2 ms 6492 KB Output is correct
10 Correct 3 ms 12636 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 4 ms 12636 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 2552 KB Output is correct
4 Correct 2 ms 8540 KB Output is correct
5 Correct 2 ms 4696 KB Output is correct
6 Correct 3 ms 10588 KB Output is correct
7 Correct 2 ms 4444 KB Output is correct
8 Correct 2 ms 10588 KB Output is correct
9 Correct 2 ms 6492 KB Output is correct
10 Correct 3 ms 12636 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 4 ms 12636 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 15 ms 90716 KB Output is correct
15 Correct 151 ms 109400 KB Output is correct
16 Correct 11 ms 10588 KB Output is correct
17 Correct 34 ms 29020 KB Output is correct
18 Correct 44 ms 47452 KB Output is correct
19 Correct 176 ms 115240 KB Output is correct
20 Correct 140 ms 96860 KB Output is correct
21 Correct 91 ms 66140 KB Output is correct
22 Correct 94 ms 86620 KB Output is correct
23 Correct 63 ms 119460 KB Output is correct
24 Correct 237 ms 119380 KB Output is correct
25 Correct 176 ms 103004 KB Output is correct
26 Correct 204 ms 111304 KB Output is correct
27 Correct 229 ms 115432 KB Output is correct