# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1116880 | 2024-11-22T14:01:32 Z | byebye75 | 유적 3 (JOI20_ruins3) | C++14 | 271 ms | 13568 KB |
#include <iostream> const long long M=605,mod=1e9+7; int n,a[M]; long long C[2*M][2*M],F[M],dp[M][M]; int main(){ C[0][0]=F[0]=dp[0][0]=1; for(int i=0;i<2*M-1;i++) for(int j=0;j<=i;j++){ (C[i+1][j]+=C[i][j])%=mod; (C[i+1][j+1]+=C[i][j])%=mod; } for(int i=1;i<M;i++) F[i]=F[i-1]*i%mod; scanf("%d",&n); for(int i=0;i<n;i++) scanf("%d",a+i); for(int i=0;i<n;i++) for(int j=0;j<=n;j++) if(dp[i][j]) for(int k=0;k<=std::min(n,a[i]-i-1)-j;k++){ (dp[i+1][j+k]+=dp[i][j]*C[2*k][k]%mod*C[a[i]-i-j-1][k]%mod*F[k]%mod*(k?1:j-i))%=mod; } long long res=dp[n][n]; for(int i=0;i<n;i++) (res*=mod/2+1)%=mod; printf("%lld\n",res); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 9 ms | 11344 KB | Output is correct |
2 | Correct | 9 ms | 11344 KB | Output is correct |
3 | Correct | 8 ms | 11344 KB | Output is correct |
4 | Correct | 9 ms | 11344 KB | Output is correct |
5 | Correct | 9 ms | 11344 KB | Output is correct |
6 | Correct | 9 ms | 11344 KB | Output is correct |
7 | Correct | 9 ms | 11344 KB | Output is correct |
8 | Correct | 10 ms | 11344 KB | Output is correct |
9 | Correct | 9 ms | 11344 KB | Output is correct |
10 | Correct | 8 ms | 11220 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 9 ms | 11344 KB | Output is correct |
2 | Correct | 9 ms | 11344 KB | Output is correct |
3 | Correct | 8 ms | 11344 KB | Output is correct |
4 | Correct | 9 ms | 11344 KB | Output is correct |
5 | Correct | 9 ms | 11344 KB | Output is correct |
6 | Correct | 9 ms | 11344 KB | Output is correct |
7 | Correct | 9 ms | 11344 KB | Output is correct |
8 | Correct | 10 ms | 11344 KB | Output is correct |
9 | Correct | 9 ms | 11344 KB | Output is correct |
10 | Correct | 8 ms | 11220 KB | Output is correct |
11 | Correct | 9 ms | 11600 KB | Output is correct |
12 | Correct | 9 ms | 11600 KB | Output is correct |
13 | Correct | 9 ms | 11772 KB | Output is correct |
14 | Correct | 9 ms | 11420 KB | Output is correct |
15 | Correct | 9 ms | 11344 KB | Output is correct |
16 | Correct | 9 ms | 11588 KB | Output is correct |
17 | Correct | 9 ms | 11344 KB | Output is correct |
18 | Correct | 9 ms | 11600 KB | Output is correct |
19 | Correct | 9 ms | 11600 KB | Output is correct |
20 | Correct | 9 ms | 11600 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 9 ms | 11344 KB | Output is correct |
2 | Correct | 9 ms | 11344 KB | Output is correct |
3 | Correct | 8 ms | 11344 KB | Output is correct |
4 | Correct | 9 ms | 11344 KB | Output is correct |
5 | Correct | 9 ms | 11344 KB | Output is correct |
6 | Correct | 9 ms | 11344 KB | Output is correct |
7 | Correct | 9 ms | 11344 KB | Output is correct |
8 | Correct | 10 ms | 11344 KB | Output is correct |
9 | Correct | 9 ms | 11344 KB | Output is correct |
10 | Correct | 8 ms | 11220 KB | Output is correct |
11 | Correct | 9 ms | 11600 KB | Output is correct |
12 | Correct | 9 ms | 11600 KB | Output is correct |
13 | Correct | 9 ms | 11772 KB | Output is correct |
14 | Correct | 9 ms | 11420 KB | Output is correct |
15 | Correct | 9 ms | 11344 KB | Output is correct |
16 | Correct | 9 ms | 11588 KB | Output is correct |
17 | Correct | 9 ms | 11344 KB | Output is correct |
18 | Correct | 9 ms | 11600 KB | Output is correct |
19 | Correct | 9 ms | 11600 KB | Output is correct |
20 | Correct | 9 ms | 11600 KB | Output is correct |
21 | Correct | 11 ms | 13136 KB | Output is correct |
22 | Correct | 11 ms | 13136 KB | Output is correct |
23 | Correct | 11 ms | 13264 KB | Output is correct |
24 | Correct | 13 ms | 13144 KB | Output is correct |
25 | Correct | 9 ms | 11360 KB | Output is correct |
26 | Correct | 9 ms | 11344 KB | Output is correct |
27 | Correct | 9 ms | 11344 KB | Output is correct |
28 | Correct | 10 ms | 13196 KB | Output is correct |
29 | Correct | 9 ms | 11344 KB | Output is correct |
30 | Correct | 271 ms | 13556 KB | Output is correct |
31 | Correct | 150 ms | 13384 KB | Output is correct |
32 | Correct | 209 ms | 13568 KB | Output is correct |
33 | Correct | 249 ms | 13384 KB | Output is correct |
34 | Correct | 143 ms | 13384 KB | Output is correct |
35 | Correct | 205 ms | 13476 KB | Output is correct |
36 | Correct | 246 ms | 13384 KB | Output is correct |