# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
168881 |
2019-12-16T21:28:36 Z |
triplem5ds |
Tents (JOI18_tents) |
C++14 |
|
272 ms |
36076 KB |
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#include "bits/stdc++.h"
using namespace std;
#define pb push_back
#define F first
#define S second
#define f(i,a,b) for(int i = a; i < b; i++)
//#define endl '\n'
using ll = long long;
using db = long double;
using row = vector<int>;
using ii = pair<int, int>;
const int N = 1e5 + 5, M = 1e6 + 5, A = 6561, LG = 18, MOD = 1e9 + 7;
const int BLOCK = 1900;
const int BLOCKN = N / BLOCK + 1;
const long double EPS = 1e-7;
int dp[3005][3005];
int n, m;
int solve(int col, int emptyRows){
if(col == 0)return 1;
int &ret = dp[col][emptyRows];
if(~ret)
return ret;
///put nothing
ret = solve(col-1,emptyRows);
///put two S and N have to be emptyRows
if(emptyRows>=2)
ret = (ret + solve(col-1,emptyRows-2) * 1ll * emptyRows * (emptyRows-1)/2) % MOD;
///put an S or an N or a W
if(emptyRows)
ret = (ret + solve(col-1,emptyRows-1) * 3ll * emptyRows)%MOD;
///put an E with no follow up
if(emptyRows)
ret = (ret + solve(col-1,emptyRows-1)*1ll*emptyRows)%MOD;
///put a E and W combo
if(emptyRows&&col>=2)
ret = (ret + solve(col-2,emptyRows-1)*1ll*emptyRows*(col-1))%MOD;
return ret;
}
int main(){
#ifdef ONLINE_JUDGE
ios_base::sync_with_stdio(0);
cin.tie(0);
#endif // ONLINE_JUDGE
cin>>n>>m;
memset(dp,-1,sizeof dp);
cout<<solve(m,n)-1<<'\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
38 ms |
35612 KB |
Output is correct |
2 |
Correct |
32 ms |
35704 KB |
Output is correct |
3 |
Correct |
38 ms |
35704 KB |
Output is correct |
4 |
Correct |
32 ms |
35588 KB |
Output is correct |
5 |
Correct |
38 ms |
35704 KB |
Output is correct |
6 |
Correct |
33 ms |
35612 KB |
Output is correct |
7 |
Correct |
33 ms |
35704 KB |
Output is correct |
8 |
Correct |
32 ms |
35704 KB |
Output is correct |
9 |
Correct |
37 ms |
35704 KB |
Output is correct |
10 |
Correct |
37 ms |
35704 KB |
Output is correct |
11 |
Correct |
32 ms |
35760 KB |
Output is correct |
12 |
Correct |
34 ms |
35704 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
38 ms |
35612 KB |
Output is correct |
2 |
Correct |
32 ms |
35704 KB |
Output is correct |
3 |
Correct |
38 ms |
35704 KB |
Output is correct |
4 |
Correct |
32 ms |
35588 KB |
Output is correct |
5 |
Correct |
38 ms |
35704 KB |
Output is correct |
6 |
Correct |
33 ms |
35612 KB |
Output is correct |
7 |
Correct |
33 ms |
35704 KB |
Output is correct |
8 |
Correct |
32 ms |
35704 KB |
Output is correct |
9 |
Correct |
37 ms |
35704 KB |
Output is correct |
10 |
Correct |
37 ms |
35704 KB |
Output is correct |
11 |
Correct |
32 ms |
35760 KB |
Output is correct |
12 |
Correct |
34 ms |
35704 KB |
Output is correct |
13 |
Correct |
33 ms |
35960 KB |
Output is correct |
14 |
Correct |
31 ms |
35704 KB |
Output is correct |
15 |
Correct |
160 ms |
35928 KB |
Output is correct |
16 |
Correct |
43 ms |
35832 KB |
Output is correct |
17 |
Correct |
69 ms |
35832 KB |
Output is correct |
18 |
Correct |
71 ms |
35832 KB |
Output is correct |
19 |
Correct |
185 ms |
35960 KB |
Output is correct |
20 |
Correct |
158 ms |
35832 KB |
Output is correct |
21 |
Correct |
123 ms |
35832 KB |
Output is correct |
22 |
Correct |
106 ms |
35832 KB |
Output is correct |
23 |
Correct |
45 ms |
35704 KB |
Output is correct |
24 |
Correct |
272 ms |
36076 KB |
Output is correct |
25 |
Correct |
203 ms |
35960 KB |
Output is correct |
26 |
Correct |
228 ms |
35992 KB |
Output is correct |
27 |
Correct |
259 ms |
35920 KB |
Output is correct |