Submission #1084238


Source Code Expand

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define X first
#define Y second
#define REP(i,a) for(int i=0;i<a;++i)
#define REPP(i,a,b) for(int i=a;i<b;++i)
#define FILL(a,x) memset(a,x,sizeof(a))
#define	foreach( gg,itit )	for( typeof(gg.begin()) itit=gg.begin();itit!=gg.end();itit++ )
#define	mp make_pair
#define	pb push_back
#define sz(a) int((a).size())
#define all(a)  a.begin(), a.end()
#define	debug(ccc)	cout << #ccc << " = " << ccc << endl;
#define present(c,x) ((c).find(x) != (c).end())
const double eps = 1e-8;
#define EQ(a,b) (fabs((a)-(b))<eps)
inline int max(int a,int b){return a<b?b:a;}
inline int min(int a,int b){return a>b?b:a;}
inline ll max(ll a,ll b){return a<b?b:a;}
inline ll min(ll a,ll b){return a>b?b:a;}
const int mod = 1e9+7;
const int N = 1e6+10;
const ll inf = 1e18;

ll power(ll a,ll n){
	if(n==0){
		return 1;
	}
	ll b = power(a,n/2);
	b = b*b%mod;
	if(n%2) b= b*a%mod;
	return b;
}

int add(int a,int b){ return (a+b)%mod;}
int mul(int a,int b){ return (ll)a*b%mod;}


int n,k;
ll dp[2005][2005][2];

ll f(int pos,int left,int ch){
	if(pos+left==0){
		if(ch==0)
			return 1;
		return 0;
	}
	ll &ret = dp[pos][left][ch];
	if(ret!=-1) return ret;
	ret = 0;
	if(ch==1){
		if(pos==1){
			if(left==n-k) ret = f(pos-1,left,0);
			else ret = 0;
			return ret;
		}
		if(pos==0) return ret = 0;
		ret = (f(pos-1,left,0) + f(pos-1,left+1,1))%mod;
		return ret;
	}
	if(pos==0 && left>1){
		if(left>0) ret = (ret + 2*f(pos,left-1,ch))%mod;
		return ret;
	}
	if(left>0) ret = (ret + f(pos,left-1,ch))%mod;
	ret = (ret + f(pos,left,1))%mod;
	return ret;
}


int main(){
 // 	freopen("nice.in","r",stdin);
 // freopen("nice.out","w",stdout);
	scanf("%d %d",&n,&k);
	FILL(dp,-1);
	printf("%lld\n",f(n,0,0));
	return 0;
}


Submission Info

Submission Time
Task F - Solitaire
User sahilgrover
Language C++14 (GCC 5.4.1)
Score 1200
Code Size 1933 Byte
Status AC
Exec Time 124 ms
Memory 63360 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:78:22: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d",&n,&k);
                      ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 1200 / 1200
Status
AC × 3
AC × 26
Set Name Test Cases
Sample 00_example_01.txt, 00_example_02.txt, 00_example_03.txt
All 00_example_01.txt, 00_example_02.txt, 00_example_03.txt, 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt
Case Name Status Exec Time Memory
00_example_01.txt AC 64 ms 63104 KB
00_example_02.txt AC 64 ms 63104 KB
00_example_03.txt AC 123 ms 63360 KB
01.txt AC 64 ms 63104 KB
02.txt AC 79 ms 63232 KB
03.txt AC 64 ms 63104 KB
04.txt AC 64 ms 63104 KB
05.txt AC 64 ms 63104 KB
06.txt AC 64 ms 63104 KB
07.txt AC 64 ms 63104 KB
08.txt AC 64 ms 63104 KB
09.txt AC 117 ms 63232 KB
10.txt AC 63 ms 63104 KB
11.txt AC 63 ms 63104 KB
12.txt AC 115 ms 63360 KB
13.txt AC 64 ms 63104 KB
14.txt AC 123 ms 63360 KB
15.txt AC 68 ms 63104 KB
16.txt AC 123 ms 63360 KB
17.txt AC 124 ms 63360 KB
18.txt AC 124 ms 63360 KB
19.txt AC 123 ms 63360 KB
20.txt AC 123 ms 63360 KB
21.txt AC 64 ms 63104 KB
22.txt AC 124 ms 63232 KB
23.txt AC 123 ms 63360 KB