Submission #421654

#TimeUsernameProblemLanguageResultExecution timeMemory
421654KerimTents (JOI18_tents)C++17
100 / 100
219 ms35908 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 dp[N][N],c[N]; int mod(ll x){ return (x%INF); } int rec(int row,int empty){ if(!row)return 1; int &ret=dp[row][empty]; if(~ret)return ret; ret=rec(row-1,empty); //E W N S ret=mod(ret+rec(row-1,empty-1)*4LL*empty); //EW if(empty>=2) ret=mod(ret+rec(row-1,empty-2)*1LL*c[empty]); //SN ret=mod(ret+rec(row-2,empty-1)*1LL*mod((row-1)*1LL*empty)); return ret; } int main(){ //~ freopen("file.in", "r", stdin); memset(dp,-1,sizeof dp); int n,m; scanf("%d%d",&n,&m); for(int i=1;i<=m;i++) c[i]=(i*(i-1))/2; printf("%d\n",mod(rec(n,m)-1+INF)); return 0; }

Compilation message (stderr)

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