# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
105262 | 2019-04-11T05:13:50 Z | he_____he | Tents (JOI18_tents) | C++14 | 157 ms | 70904 KB |
#include<bits/stdc++.h> using namespace std; typedef long long ll; int readint(){ int x=0,f=1; char ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();} while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();} return x*f; } const int cys=1000000007; int n,m; ll d[3005][3005]; int mod(int x){return x>=cys?x-cys:x;} ll qpow(ll x,ll p){ ll ret=1; for(;p;p>>=1,x=x*x%cys) if(p&1) ret=ret*x%cys; return ret; } int main(){ n=readint(); m=readint(); for(int i=0;i<=m;i++) d[0][i]=1; for(int i=1;i<=n;i++){ for(int j=0;j<=m;j++){ if(i) d[i][j]=d[i-1][j]; if(i&&j) d[i][j]=mod(d[i][j]+4*j*d[i-1][j-1]%cys); if(i&&j>1) d[i][j]=mod(d[i][j]+(j*(j-1)/2)%cys*d[i-1][j-2]%cys); if(i>1&&j) d[i][j]=mod(d[i][j]+(i-1)*j%cys*d[i-2][j-1]%cys); } } printf("%lld\n",mod(d[n][m]+cys-1)); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 384 KB | Output is correct |
3 | Correct | 4 ms | 512 KB | Output is correct |
4 | Correct | 3 ms | 1152 KB | Output is correct |
5 | Correct | 2 ms | 640 KB | Output is correct |
6 | Correct | 3 ms | 1408 KB | Output is correct |
7 | Correct | 4 ms | 896 KB | Output is correct |
8 | Correct | 4 ms | 1536 KB | Output is correct |
9 | Correct | 2 ms | 768 KB | Output is correct |
10 | Correct | 4 ms | 1792 KB | Output is correct |
11 | Correct | 2 ms | 380 KB | Output is correct |
12 | Correct | 4 ms | 2176 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 384 KB | Output is correct |
3 | Correct | 4 ms | 512 KB | Output is correct |
4 | Correct | 3 ms | 1152 KB | Output is correct |
5 | Correct | 2 ms | 640 KB | Output is correct |
6 | Correct | 3 ms | 1408 KB | Output is correct |
7 | Correct | 4 ms | 896 KB | Output is correct |
8 | Correct | 4 ms | 1536 KB | Output is correct |
9 | Correct | 2 ms | 768 KB | Output is correct |
10 | Correct | 4 ms | 1792 KB | Output is correct |
11 | Correct | 2 ms | 380 KB | Output is correct |
12 | Correct | 4 ms | 2176 KB | Output is correct |
13 | Correct | 2 ms | 384 KB | Output is correct |
14 | Correct | 9 ms | 9728 KB | Output is correct |
15 | Correct | 130 ms | 55280 KB | Output is correct |
16 | Correct | 11 ms | 4096 KB | Output is correct |
17 | Correct | 25 ms | 12920 KB | Output is correct |
18 | Correct | 32 ms | 17144 KB | Output is correct |
19 | Correct | 127 ms | 63028 KB | Output is correct |
20 | Correct | 100 ms | 50940 KB | Output is correct |
21 | Correct | 71 ms | 33824 KB | Output is correct |
22 | Correct | 65 ms | 35544 KB | Output is correct |
23 | Correct | 40 ms | 27128 KB | Output is correct |
24 | Correct | 147 ms | 70904 KB | Output is correct |
25 | Correct | 123 ms | 61204 KB | Output is correct |
26 | Correct | 139 ms | 66652 KB | Output is correct |
27 | Correct | 157 ms | 69068 KB | Output is correct |