Submission #838437


Source Code Expand

Copy
#include <bits/stdc++.h>

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using namespace std;

using ll=long long;

const ll mod=1000000007LL;

inline ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
inline ll ADD(const ll &a, const ll &b,const ll &mod) { return a+b<mod?a+b:a+b-mod;}
inline ll SUB(const ll &a, const ll &b,const ll &mod) { return a-b>=0?a-b:a-b+mod;}
inline ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
inline ll INV(ll a,ll mod){ll x,y;extgcd(a,mod,x,y);return (x%mod+mod)%mod;}
inline ll DIV(const ll &a, const ll &b,const ll &mod) {return MUL(a,INV(b,mod),mod);}
inline ll POW(ll a,ll n,ll mod){ll b=1LL;for(a%=mod;n;a=MUL(a,a,mod),n>>=1)if(n&1) b=MUL(b,a,mod); return b;}

ll dp[310][310][310];

string s;

int main(void){
	int n;
	cin >> n >> s;

	if(n>300) return 0;

	const int m=s.size();
	dp[0][0][0]=1LL;
	
	rep(i,n)rep(j,m+1)rep(k,n+1){
		if(k==0 && j!=m && s[j]=='0') 
			dp[i+1][j+1][k]=ADD(dp[i+1][j+1][k],dp[i][j][k],mod);
		else
			dp[i+1][j][k+1]=ADD(dp[i+1][j][k+1],dp[i][j][k],mod);

		if(k==0 && j!=m && s[j]=='1') 
			dp[i+1][j+1][k]=ADD(dp[i+1][j+1][k],dp[i][j][k],mod);
		else
			dp[i+1][j][k+1]=ADD(dp[i+1][j][k+1],dp[i][j][k],mod);

		if(k!=0) 
			dp[i+1][j][k-1]=ADD(dp[i+1][j][k-1],dp[i][j][k],mod);
		else
			dp[i+1][max(0,j-1)][k]=ADD(dp[i+1][max(0,j-1)][k],dp[i][j][k],mod);
	}
	cout << dp[n][m][0] << endl;
	return 0;
}

Submission Info

Submission Time
Task F - Unhappy Hacking
User Hec
Language C++14 (GCC 5.4.1)
Score 400
Code Size 2254 Byte
Status WA
Exec Time 728 ms
Memory 220160 KB

Judge Result

Set Name Sample Sub1 Sub2
Score / Max Score 0 / 0 400 / 400 0 / 400
Status
AC × 2
WA × 1
AC × 23
AC × 23
WA × 21
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 4 ms 256 KB
0_02 AC 28 ms 7168 KB
0_03 WA 4 ms 256 KB
1_04 AC 4 ms 256 KB
1_05 AC 13 ms 2816 KB
1_06 AC 15 ms 3584 KB
1_07 AC 361 ms 111104 KB
1_08 AC 714 ms 219392 KB
1_09 AC 728 ms 220160 KB
1_10 AC 601 ms 175744 KB
1_11 AC 62 ms 16640 KB
1_12 AC 590 ms 181632 KB
1_13 AC 433 ms 132864 KB
1_14 AC 478 ms 131456 KB
1_15 AC 33 ms 7936 KB
1_16 AC 628 ms 194048 KB
1_17 AC 162 ms 43520 KB
1_18 AC 405 ms 123520 KB
1_19 AC 155 ms 41856 KB
1_20 AC 25 ms 8064 KB
1_21 AC 105 ms 33536 KB
1_22 AC 35 ms 11520 KB
1_23 AC 478 ms 147584 KB
1_24 AC 387 ms 122624 KB
2_25 WA 4 ms 256 KB
2_26 WA 4 ms 256 KB
2_27 WA 4 ms 256 KB
2_28 WA 4 ms 256 KB
2_29 WA 4 ms 256 KB
2_30 WA 4 ms 256 KB
2_31 WA 4 ms 256 KB
2_32 WA 4 ms 256 KB
2_33 WA 5 ms 256 KB
2_34 WA 4 ms 256 KB
2_35 WA 4 ms 256 KB
2_36 WA 4 ms 256 KB
2_37 WA 4 ms 256 KB
2_38 WA 4 ms 256 KB
2_39 WA 4 ms 256 KB
2_40 WA 4 ms 256 KB
2_41 WA 4 ms 256 KB
2_42 WA 4 ms 256 KB
2_43 WA 4 ms 256 KB
2_44 WA 4 ms 256 KB