# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
346448 | CaroLinda | Tents (JOI18_tents) | C++14 | 135 ms | 71020 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define ll long long
const int MAX = 3010 ;
const ll MOD = 1e9+7 ;
using namespace std ;
int N , M ;
ll dp[MAX][MAX] ;
int main()
{
scanf("%d %d", &N, &M ) ;
for(int i = 0 ; i <= max(N,M) ; i++ ) dp[0][i] = dp[i][0] = 1 ;
for(int i= 1 ; i <= N ; i++ )
{
ll bin = (ll)i * (i-1) ;
bin = (bin>>1LL ) % MOD ;
ll c = (4*i) % MOD ;
for(int j = 1 , aux = 0 ; j <= M ; j++, aux += i )
{
if( aux >= MOD ) aux -= MOD ;
ll &ptr = dp[i][j] ;
ptr = dp[i][j-1] ;
ptr += ( c * dp[i-1][j-1] ) % MOD ;
if( ptr >= MOD ) ptr -= MOD ;
if(i >= 2 )
{
ptr += ( bin * dp[i-2][j-1] ) % MOD ;
if( ptr >= MOD ) ptr -= MOD ;
}
if( j >= 2 )
{
ptr += ( aux * dp[i-1][j-2] ) % MOD ;
if( ptr >= MOD ) ptr -= MOD ;
}
}
}
ll ans = dp[N][M] - 1LL ;
if( ans < 0 ) ans += MOD ;
printf("%lld\n", ans ) ;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |