# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
341394 |
2020-12-29T15:50:05 Z |
Kerim |
Tents (JOI18_tents) |
C++17 |
|
405 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:44:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
44 | scanf("%d%d",&n,&m);
| ~~~~~^~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
55 ms |
109164 KB |
Output is correct |
2 |
Correct |
56 ms |
109164 KB |
Output is correct |
3 |
Correct |
55 ms |
109164 KB |
Output is correct |
4 |
Correct |
55 ms |
109164 KB |
Output is correct |
5 |
Correct |
59 ms |
109292 KB |
Output is correct |
6 |
Correct |
76 ms |
109164 KB |
Output is correct |
7 |
Correct |
63 ms |
109164 KB |
Output is correct |
8 |
Correct |
66 ms |
109164 KB |
Output is correct |
9 |
Correct |
55 ms |
109164 KB |
Output is correct |
10 |
Correct |
128 ms |
109164 KB |
Output is correct |
11 |
Correct |
55 ms |
109164 KB |
Output is correct |
12 |
Correct |
405 ms |
109272 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
55 ms |
109164 KB |
Output is correct |
2 |
Correct |
56 ms |
109164 KB |
Output is correct |
3 |
Correct |
55 ms |
109164 KB |
Output is correct |
4 |
Correct |
55 ms |
109164 KB |
Output is correct |
5 |
Correct |
59 ms |
109292 KB |
Output is correct |
6 |
Correct |
76 ms |
109164 KB |
Output is correct |
7 |
Correct |
63 ms |
109164 KB |
Output is correct |
8 |
Correct |
66 ms |
109164 KB |
Output is correct |
9 |
Correct |
55 ms |
109164 KB |
Output is correct |
10 |
Correct |
128 ms |
109164 KB |
Output is correct |
11 |
Correct |
55 ms |
109164 KB |
Output is correct |
12 |
Correct |
405 ms |
109272 KB |
Output is correct |
13 |
Incorrect |
55 ms |
109164 KB |
Output isn't correct |
14 |
Halted |
0 ms |
0 KB |
- |