# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
421364 | 2021-06-09T05:45:24 Z | juggernaut | Tents (JOI18_tents) | C++17 | 498 ms | 71136 KB |
#include<bits/stdc++.h> #define fr first #define sc second using namespace std; void usaco(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);} typedef long long ll; #define USING_ORDERED_SET 0 #if USING_ORDERED_SET #include<bits/extc++.h> using namespace __gnu_pbds; template<class T>using ordered_set=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>; #endif template<class T>void umax(T &a,T b){if(a<b)a=b;} template<class T>void umin(T &a,T b){if(b<a)a=b;} #ifdef IOI2021SG #define printl(args...)printf(args) #else #define printl(args...)((void)0) #endif ll dp[3005][3005]; ll mod=1e9+7; inline ll add(ll a,ll b){ return (a+b)%mod; } inline ll mult(ll a,ll b){ return (a*b)%mod; } ll go(int n,int m){ if(n==1)return 4*m+m*(m-1)/2+1; if(m==1)return 4*n+n*(n-1)/2+1; if(n==0||m==0)return 1; if(n<0||m<0)return 0; ll &res=dp[n][m]; if(~res)return res; res=0; res=add(res,go(n-1,m)); res=add(res,mult(4*m,go(n-1,m-1))); res=add(res,mult(go(n-1,m-2),m*(m-1)/2)); res=add(res,mult(go(n-2,m-1),m*(n-1))); return res; } int main(){ memset(dp,-1,sizeof dp); int n,m; scanf("%d%d",&n,&m); if(n>m)swap(n,m); ll ans=go(n,m); if(ans==0)ans=mod-1; else ans--; printf("%lld",ans); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 36 ms | 70852 KB | Output is correct |
2 | Correct | 41 ms | 70860 KB | Output is correct |
3 | Correct | 35 ms | 70928 KB | Output is correct |
4 | Correct | 36 ms | 70872 KB | Output is correct |
5 | Correct | 36 ms | 70860 KB | Output is correct |
6 | Correct | 35 ms | 70900 KB | Output is correct |
7 | Correct | 37 ms | 70868 KB | Output is correct |
8 | Correct | 36 ms | 70924 KB | Output is correct |
9 | Correct | 36 ms | 70952 KB | Output is correct |
10 | Correct | 37 ms | 70852 KB | Output is correct |
11 | Correct | 36 ms | 70952 KB | Output is correct |
12 | Correct | 40 ms | 70908 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 36 ms | 70852 KB | Output is correct |
2 | Correct | 41 ms | 70860 KB | Output is correct |
3 | Correct | 35 ms | 70928 KB | Output is correct |
4 | Correct | 36 ms | 70872 KB | Output is correct |
5 | Correct | 36 ms | 70860 KB | Output is correct |
6 | Correct | 35 ms | 70900 KB | Output is correct |
7 | Correct | 37 ms | 70868 KB | Output is correct |
8 | Correct | 36 ms | 70924 KB | Output is correct |
9 | Correct | 36 ms | 70952 KB | Output is correct |
10 | Correct | 37 ms | 70852 KB | Output is correct |
11 | Correct | 36 ms | 70952 KB | Output is correct |
12 | Correct | 40 ms | 70908 KB | Output is correct |
13 | Correct | 36 ms | 70952 KB | Output is correct |
14 | Correct | 36 ms | 70852 KB | Output is correct |
15 | Correct | 283 ms | 71084 KB | Output is correct |
16 | Correct | 39 ms | 70852 KB | Output is correct |
17 | Correct | 67 ms | 70996 KB | Output is correct |
18 | Correct | 100 ms | 71024 KB | Output is correct |
19 | Correct | 339 ms | 71092 KB | Output is correct |
20 | Correct | 273 ms | 71020 KB | Output is correct |
21 | Correct | 182 ms | 70980 KB | Output is correct |
22 | Correct | 176 ms | 71056 KB | Output is correct |
23 | Correct | 57 ms | 70980 KB | Output is correct |
24 | Correct | 498 ms | 71116 KB | Output is correct |
25 | Correct | 376 ms | 71088 KB | Output is correct |
26 | Correct | 420 ms | 71128 KB | Output is correct |
27 | Correct | 483 ms | 71136 KB | Output is correct |