Submission #341416

#TimeUsernameProblemLanguageResultExecution timeMemory
341416KerimTents (JOI18_tents)C++17
0 / 100
18 ms35564 KiB
#include "bits/stdc++.h"
#define MAXN 100009
#define INF 1000000007
#define mp(x,y) make_pair(x,y)
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define wr cout<<"----------------"<<endl;
#define ppb() pop_back()
#define tr(ii,c) for(__typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
#define ff first
#define ss second
#define my_little_dodge 46
#define debug(x)  cerr<< #x <<" = "<< x<<endl;
using namespace std;

typedef long long ll;
typedef pair<int,int> PII;
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
const int N=3003;
int p[N],dp[N][N],n,m;
int mod(ll x){return (x%INF);}
int rec(int x,int y){
	if(!x)return 1;
	int &ret=dp[x][y];
	if(~ret)return ret;
	ret=rec(x-1,y);
	if(y>=2)ret=mod(ret+rec(x-1,y-2)*1LL*p[y]);
	if(y)ret=mod(ret+rec(x-1,y-1)*4LL*y);
	if(y and x>=2)ret=mod(ret+rec(x-2,y-1)*1LL*y*(x-1));
	return ret;
}
int main(){
    freopen("file.in", "r", stdin);
	for(int i=1;i<N;i++)p[i]=(i*(i-1))/2;
    scanf("%d%d",&n,&m);
    memset(dp,-1,sizeof dp);
    printf("%d\n",rec(n,m)-1);	
	return 0;
}

Compilation message (stderr)

tents.cpp: In function 'int main()':
tents.cpp:34:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   34 |     freopen("file.in", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
tents.cpp:36:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   36 |     scanf("%d%d",&n,&m);
      |     ~~~~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...