# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
139203 |
2019-07-31T11:31:06 Z |
zoooma13 |
Tents (JOI18_tents) |
C++14 |
|
466 ms |
108288 KB |
#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9+7;
int GM(long long num){
return num%mod;
}
int n ,m ,dp[302][302][302];
int solve(int p ,int l ,int t){
if(t<0 || l<0) return 0;
if(p == n) return !l;
int&ret = dp[p][t][l];
if(~ret)
return ret;
ret = solve(p+1 ,l ,t); ///nothing
ret = GM(ret + 1LL*l*solve(p+1 ,l-1 ,t)); ///adding rest of vertical tent
ret = GM(ret + 1LL*t*solve(p+1 ,l+1 ,t-1)); ///adding vertical tents
ret = GM(ret + 4LL*t*solve(p+1 ,l ,t-1)); ///adding a solo tent
ret = GM(ret + 1LL*t*(t-1)/2*solve(p+1 ,l ,t-2)); ///adding horizontal tents
//cout << p << " " << l << " " << t << " = " << ret << endl;
return ret;
}
int main()
{
scanf("%d%d",&n,&m);
memset(dp ,-1 ,sizeof dp);
printf("%d\n",solve(0,0,m)-1);
}
Compilation message
tents.cpp: In function 'int main()':
tents.cpp:28:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d",&n,&m);
~~~~~^~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
93 ms |
108280 KB |
Output is correct |
2 |
Correct |
92 ms |
108152 KB |
Output is correct |
3 |
Correct |
92 ms |
108152 KB |
Output is correct |
4 |
Correct |
92 ms |
108152 KB |
Output is correct |
5 |
Correct |
95 ms |
108152 KB |
Output is correct |
6 |
Correct |
125 ms |
108152 KB |
Output is correct |
7 |
Correct |
103 ms |
108152 KB |
Output is correct |
8 |
Correct |
110 ms |
108132 KB |
Output is correct |
9 |
Correct |
93 ms |
108080 KB |
Output is correct |
10 |
Correct |
196 ms |
108288 KB |
Output is correct |
11 |
Correct |
92 ms |
108152 KB |
Output is correct |
12 |
Correct |
466 ms |
108280 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
93 ms |
108280 KB |
Output is correct |
2 |
Correct |
92 ms |
108152 KB |
Output is correct |
3 |
Correct |
92 ms |
108152 KB |
Output is correct |
4 |
Correct |
92 ms |
108152 KB |
Output is correct |
5 |
Correct |
95 ms |
108152 KB |
Output is correct |
6 |
Correct |
125 ms |
108152 KB |
Output is correct |
7 |
Correct |
103 ms |
108152 KB |
Output is correct |
8 |
Correct |
110 ms |
108132 KB |
Output is correct |
9 |
Correct |
93 ms |
108080 KB |
Output is correct |
10 |
Correct |
196 ms |
108288 KB |
Output is correct |
11 |
Correct |
92 ms |
108152 KB |
Output is correct |
12 |
Correct |
466 ms |
108280 KB |
Output is correct |
13 |
Correct |
92 ms |
108052 KB |
Output is correct |
14 |
Incorrect |
92 ms |
108164 KB |
Output isn't correct |
15 |
Halted |
0 ms |
0 KB |
- |