Submission #421654

# Submission time Handle Problem Language Result Execution time Memory
421654 2021-06-09T10:34:27 Z Kerim Tents (JOI18_tents) C++17
100 / 100
219 ms 35908 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=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

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 Correct 16 ms 35532 KB Output is correct
2 Correct 15 ms 35532 KB Output is correct
3 Correct 16 ms 35576 KB Output is correct
4 Correct 16 ms 35568 KB Output is correct
5 Correct 18 ms 35532 KB Output is correct
6 Correct 18 ms 35544 KB Output is correct
7 Correct 15 ms 35532 KB Output is correct
8 Correct 16 ms 35532 KB Output is correct
9 Correct 16 ms 35576 KB Output is correct
10 Correct 17 ms 35508 KB Output is correct
11 Correct 16 ms 35468 KB Output is correct
12 Correct 18 ms 35532 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 16 ms 35532 KB Output is correct
2 Correct 15 ms 35532 KB Output is correct
3 Correct 16 ms 35576 KB Output is correct
4 Correct 16 ms 35568 KB Output is correct
5 Correct 18 ms 35532 KB Output is correct
6 Correct 18 ms 35544 KB Output is correct
7 Correct 15 ms 35532 KB Output is correct
8 Correct 16 ms 35532 KB Output is correct
9 Correct 16 ms 35576 KB Output is correct
10 Correct 17 ms 35508 KB Output is correct
11 Correct 16 ms 35468 KB Output is correct
12 Correct 18 ms 35532 KB Output is correct
13 Correct 15 ms 35572 KB Output is correct
14 Correct 90 ms 35664 KB Output is correct
15 Correct 198 ms 35796 KB Output is correct
16 Correct 19 ms 35564 KB Output is correct
17 Correct 28 ms 35532 KB Output is correct
18 Correct 50 ms 35636 KB Output is correct
19 Correct 217 ms 35804 KB Output is correct
20 Correct 172 ms 35788 KB Output is correct
21 Correct 91 ms 35604 KB Output is correct
22 Correct 128 ms 35740 KB Output is correct
23 Correct 182 ms 35908 KB Output is correct
24 Correct 219 ms 35812 KB Output is correct
25 Correct 188 ms 35776 KB Output is correct
26 Correct 204 ms 35808 KB Output is correct
27 Correct 207 ms 35780 KB Output is correct