# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
391967 |
2021-04-20T08:58:11 Z |
PixelCat |
Tents (JOI18_tents) |
C++14 |
|
171 ms |
71108 KB |
/*
/^--^\
\____/
/ \ _____ _ __ __ ____ _ ____ ____ _____
| || ()_)| |\ \/ /| ===|| |__ / (__` / () \|_ _|
\__ __/ |_| |_|/_/\_\|____||____|\____)/__/\__\ |_|
|^|^\ \^|^|^|^|^|^|^|^|^|^|^|^|^|^|^|^|^|^|^|^|^|^|^|^|^|
| | |\ \| | | | | | | | | | | | | | | | | | | | | | | | |
#####/ /#################################################
| | |\/ | | | | | | | | | | | | | | | | | | | | | | | | |
|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|*/
//#pragma GCC optimize("O4,unroll-loops,no-stack-protector")
#include <bits/stdc++.h>
#define int ll //__int128
#define double long double
using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;
#define For(i,a,b) for(int i=a;i<=b;i++)
#define Fors(i,a,b,s) for(int i=a;i<=b;i+=s)
#define Forr(i,a,b) for(int i=a;i>=b;i--)
#define F first
#define S second
#define L(id) (id*2+1)
#define R(id) (id*2+2)
#define LO(x) (x&(-x))
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define mkp make_pair
#define MOD (int)(1000000007)
#define INF (int)(1e12)
#define EPS (1e-7)
#ifdef NYAOWO
#define debug(...) do{\
cerr << __LINE__ <<\
" : ("#__VA_ARGS__ << ") = ";\
_OUT(__VA_ARGS__);\
cerr << flush;\
}while(0)
template<typename T> void _OUT(T x) { cerr << x << "\n"; }
template<typename T,typename...I>
void _OUT(T x,I ...tail) { cerr << x << ", "; _OUT(tail...); }
#else
#define debug(...)
#endif
inline void NYA(){ ios::sync_with_stdio(false); cin.tie(0); }
inline void USACO(const string &s){
freopen((s+".in").c_str(),"r",stdin);
freopen((s+".out").c_str(),"w",stdout);
}
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
//int gcd(int a,int b) { return b==0?a:gcd(b,a%b); }
inline int gcd(int a,int b) { return __gcd(a,b); }
inline int lcm(int a,int b) { return a/gcd(a,b)*b; }
__int128 fpow(__int128 b,__int128 p,const __int128 &mod){
__int128 ans=1;
while(p){
if(p&1) ans=ans*b%mod;
p/=2; b=b*b%mod;
}
return ans;
}
int fpow(int b,int p) { return fpow(b,p,MOD); }
template<typename T> inline void chmin(T &_a,const T &_b) { if(_b<_a) _a=_b; }
template<typename T> inline void chmax(T &_a,const T &_b) { if(_b>_a) _a=_b; }
int dp[3010][3010];
int fac[3010];
int inv[3010];
int C(int n,int m){
return fac[n]*inv[m]%MOD*inv[n-m]%MOD;
}
int32_t main(){
NYA();
//nachoneko so cute >/////<
fac[0]=inv[0]=1;
For(i,1,3000){
fac[i]=fac[i-1]*i%MOD;
inv[i]=fpow(fac[i],MOD-2);
}
int n,m; cin>>n>>m;
dp[0][0]=1;
int ans=0;
For(i,1,n) For(j,1,m){
dp[i][j]=dp[i-1][j-1]*4*j;
if(i>=2) dp[i][j]+=dp[i-2][j-1]*(i-1)*j;
if(j>=2) dp[i][j]+=dp[i-1][j-2]*j*(j-1)/2;
dp[i][j]%=MOD;
ans=(ans+dp[i][j]*C(n,i)%MOD*C(m,j))%MOD;
debug(i,j,dp[i][j]);
}
cout<<ans<<"\n";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
332 KB |
Output is correct |
2 |
Correct |
2 ms |
332 KB |
Output is correct |
3 |
Correct |
2 ms |
468 KB |
Output is correct |
4 |
Correct |
3 ms |
1228 KB |
Output is correct |
5 |
Correct |
3 ms |
716 KB |
Output is correct |
6 |
Correct |
3 ms |
1356 KB |
Output is correct |
7 |
Correct |
3 ms |
844 KB |
Output is correct |
8 |
Correct |
3 ms |
1484 KB |
Output is correct |
9 |
Correct |
3 ms |
880 KB |
Output is correct |
10 |
Correct |
3 ms |
1784 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Correct |
4 ms |
2304 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
332 KB |
Output is correct |
2 |
Correct |
2 ms |
332 KB |
Output is correct |
3 |
Correct |
2 ms |
468 KB |
Output is correct |
4 |
Correct |
3 ms |
1228 KB |
Output is correct |
5 |
Correct |
3 ms |
716 KB |
Output is correct |
6 |
Correct |
3 ms |
1356 KB |
Output is correct |
7 |
Correct |
3 ms |
844 KB |
Output is correct |
8 |
Correct |
3 ms |
1484 KB |
Output is correct |
9 |
Correct |
3 ms |
880 KB |
Output is correct |
10 |
Correct |
3 ms |
1784 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Correct |
4 ms |
2304 KB |
Output is correct |
13 |
Correct |
2 ms |
332 KB |
Output is correct |
14 |
Correct |
6 ms |
9676 KB |
Output is correct |
15 |
Correct |
101 ms |
55200 KB |
Output is correct |
16 |
Correct |
9 ms |
4044 KB |
Output is correct |
17 |
Correct |
27 ms |
12844 KB |
Output is correct |
18 |
Correct |
30 ms |
17012 KB |
Output is correct |
19 |
Correct |
123 ms |
63040 KB |
Output is correct |
20 |
Correct |
93 ms |
50924 KB |
Output is correct |
21 |
Correct |
62 ms |
33752 KB |
Output is correct |
22 |
Correct |
62 ms |
35416 KB |
Output is correct |
23 |
Correct |
39 ms |
27076 KB |
Output is correct |
24 |
Correct |
153 ms |
71108 KB |
Output is correct |
25 |
Correct |
117 ms |
61324 KB |
Output is correct |
26 |
Correct |
135 ms |
66688 KB |
Output is correct |
27 |
Correct |
171 ms |
69144 KB |
Output is correct |