Submission #2228723


Source Code Expand

#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<cstdlib>
#define cmax(a,b) (a<(b)?a=(b),1:0)
#define cmin(a,b) (a>(b)?a=(b),1:0)
#define dmin(a,b) ((a)<(b)?(a):(b))
#define dmax(a,b) ((a)>(b)?(a):(b))
#define CL fclose(stdin),fclose(stdout)
namespace io
{
	int F()
	{
		int n=0,F=1;
		char ch;
		while((ch=getchar())!='-'&&(ch<'0'||ch>'9'));
		ch=='-'?F=0:n=ch-'0';
		while((ch=getchar())>='0'&&ch<='9')n=(n<<1)+(n<<3)+ch-'0';
		return F?n:-n;
	}
	long long G()
	{
		long long n=0,F=1;
		char ch;
		while((ch=getchar())!='-'&&(ch<'0'||ch>'9'));
		ch=='-'?F=0:n=ch-'0';
		while((ch=getchar())>='0'&&ch<='9')n=(n<<1)+(n<<3)+ch-'0';
		return F?n:-n;
	}
}
char s[5555];
const int M=1000000007;
int f[5005][5005];
int g[5005][5005];
int h[5005];
int main()
{
	int n=io::F();
	scanf("%s",s+1); 
	int m=strlen(s+1);
	g[1][0]=1,g[1][1]=2;
	for(register int i=1;i<5000;++i)
		for(register int j=0;j<=5000;++j)
			g[i+1][j+1]=(g[i+1][j+1]+2ll*g[i][j])%M,g[i+1][j?j-1:0]=(g[i+1][j?j-1:0]+g[i][j])%M;
	h[0]=1;
	for(register int i=1;i<=5000;++i)
	h[i]=g[i][0];
	f[1][1]=1;
	for(register int i=1;i<5000;++i)
		for(register int j=1;j<=5000;++j)
			f[i+1][j+1]=(f[i+1][j+1]+f[i][j])%M,f[i+1][j-1]=(f[i+1][j-1]+2ll*f[i][j])%M;
	int ans=0;
	for(register int k=0;k<n;++k)
		ans=(ans+(long long)h[k]*f[n-k][m])%M;
	printf("%d\n",ans);
	return 0;
}

Submission Info

Submission Time
Task F - Unhappy Hacking
User ESpace
Language C++14 (GCC 5.4.1)
Score 800
Code Size 1437 Byte
Status AC
Exec Time 206 ms
Memory 195840 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:41:17: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%s",s+1); 
                 ^

Judge Result

Set Name Sample Sub1 Sub2
Score / Max Score 0 / 0 400 / 400 400 / 400
Status
AC × 3
AC × 23
AC × 44
Set Name Test Cases
Sample 0_01, 0_02, 0_03
Sub1 0_01, 0_02, 1_04, 1_05, 1_06, 1_07, 1_08, 1_09, 1_10, 1_11, 1_12, 1_13, 1_14, 1_15, 1_16, 1_17, 1_18, 1_19, 1_20, 1_21, 1_22, 1_23, 1_24
Sub2 0_01, 0_02, 0_03, 1_04, 1_05, 1_06, 1_07, 1_08, 1_09, 1_10, 1_11, 1_12, 1_13, 1_14, 1_15, 1_16, 1_17, 1_18, 1_19, 1_20, 1_21, 1_22, 1_23, 1_24, 2_25, 2_26, 2_27, 2_28, 2_29, 2_30, 2_31, 2_32, 2_33, 2_34, 2_35, 2_36, 2_37, 2_38, 2_39, 2_40, 2_41, 2_42, 2_43, 2_44
Case Name Status Exec Time Memory
0_01 AC 205 ms 195840 KB
0_02 AC 205 ms 195712 KB
0_03 AC 205 ms 195840 KB
1_04 AC 205 ms 195712 KB
1_05 AC 206 ms 195712 KB
1_06 AC 205 ms 195712 KB
1_07 AC 205 ms 195840 KB
1_08 AC 205 ms 195712 KB
1_09 AC 205 ms 195840 KB
1_10 AC 205 ms 195712 KB
1_11 AC 205 ms 195712 KB
1_12 AC 206 ms 195840 KB
1_13 AC 205 ms 195840 KB
1_14 AC 205 ms 195712 KB
1_15 AC 205 ms 195712 KB
1_16 AC 205 ms 195840 KB
1_17 AC 205 ms 195712 KB
1_18 AC 205 ms 195840 KB
1_19 AC 205 ms 195712 KB
1_20 AC 205 ms 195840 KB
1_21 AC 205 ms 195840 KB
1_22 AC 205 ms 195840 KB
1_23 AC 205 ms 195840 KB
1_24 AC 205 ms 195840 KB
2_25 AC 205 ms 195840 KB
2_26 AC 205 ms 195712 KB
2_27 AC 205 ms 195840 KB
2_28 AC 205 ms 195840 KB
2_29 AC 205 ms 195840 KB
2_30 AC 205 ms 195840 KB
2_31 AC 205 ms 195840 KB
2_32 AC 205 ms 195840 KB
2_33 AC 205 ms 195840 KB
2_34 AC 205 ms 195840 KB
2_35 AC 205 ms 195840 KB
2_36 AC 205 ms 195840 KB
2_37 AC 205 ms 195840 KB
2_38 AC 205 ms 195840 KB
2_39 AC 205 ms 195840 KB
2_40 AC 206 ms 195840 KB
2_41 AC 205 ms 195712 KB
2_42 AC 205 ms 195840 KB
2_43 AC 205 ms 195840 KB
2_44 AC 205 ms 195840 KB