Submission #341393

# Submission time Handle Problem Language Result Execution time Memory
341393 2020-12-29T15:49:31 Z Kerim Tents (JOI18_tents) C++17
0 / 100
55 ms 109292 KB
#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=303;
int p[N],dp[N][N][N],pw[N];
int mod(ll x){
	return (x%INF);	
}
int rec(int x,int y,int z){
	if(!x)
		return pw[z];
	int &ret=dp[x][y][z];
	if(~ret)
		return ret;ret=rec(x-1,y,z);
	if(y>=2)
		ret=mod(ret+rec(x-1,y-2,z)*1LL*p[y]);
	if(y)
		ret=mod(ret+rec(x-1,y-1,z+1)*1LL*y);
	if(z)
		ret=mod(ret+rec(x-1,y,z-1)*1LL*z);
	return ret;
}
int main(){
    //freopen("file.in", "r", stdin);pw[0]=1;
    for(int i=1;i<N;i++)p[i]=(i*(i-1))/2,pw[i]=mod(pw[i-1]*4LL);
    int n,m;
    scanf("%d%d",&n,&m);
    memset(dp,-1,sizeof dp);
    printf("%d\n",rec(n,m,0)-1);
	return 0;
}

Compilation message

tents.cpp: In function 'int rec(int, int, int)':
tents.cpp:29:2: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   29 |  if(~ret)
      |  ^~
tents.cpp:30:14: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   30 |   return ret;ret=rec(x-1,y,z);
      |              ^~~
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 time Memory Grader output
1 Incorrect 55 ms 109292 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 55 ms 109292 KB Output isn't correct
2 Halted 0 ms 0 KB -