Submission #3464785


Source Code Expand

#include <bits/stdc++.h>

#define For(i, l, r) for(register int i = (l), i##end = (int)(r); i <= i##end; ++i)
#define Fordown(i, r, l) for(register int i = (r), i##end = (int)(l); i >= i##end; --i)
#define Set(a, v) memset(a, v, sizeof(a))
#define Cpy(a, b) memcpy(a, b, sizeof(a))
#define debug(x) cout << #x << ": " << (x) << endl
#define DEBUG(...) fprintf(stderr, __VA_ARGS__)

using namespace std;

template<typename T> inline bool chkmin(T &a, T b) { return b < a ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, T b) { return b > a ? a = b, 1 : 0; }

inline int read() {
	int x(0), sgn(1); char ch(getchar());
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') sgn = -1;
	for (; isdigit(ch); ch = getchar()) x = (x * 10) + (ch ^ 48);
	return x * sgn;
}

void File() {
	freopen ("F.in", "r", stdin);
	freopen ("F.out", "w", stdout);
}

const int N = 310, Mod = 1e9 + 7;

int n; char str[N];

int dp[N][N][N];

inline void Add(int &a, int b) {
	if ((a += b) >= Mod) a -= Mod;
}

int main () {

	n = read();
	scanf ("%s", str + 1);

	int len = strlen(str + 1);

	dp[0][0][0] = 1;
	For (i, 0, n - 1) {
		For (j, 0, i) For (k, 0, j) if (dp[i][j][k]) {
			if (k) {
				Add(dp[i + 1][j + 1][k], dp[i][j][k] * 2 % Mod);
				Add(dp[i + 1][j - 1][j == k ? 0 : k], dp[i][j][k]);
			} else {
				Add(dp[i + 1][j + 1][0], dp[i][j][0]);
				Add(dp[i + 1][j + 1][j + 1], dp[i][j][0]);
				Add(dp[i + 1][max(0, j - 1)][0], dp[i][j][0]);
			}
		}
	}
	printf ("%d\n", dp[n][len][0]);

	return 0;

}

Submission Info

Submission Time
Task F - Unhappy Hacking
User zjp_shadow
Language C++14 (GCC 5.4.1)
Score 400
Code Size 1566 Byte
Status RE
Exec Time 154 ms
Memory 114560 KB

Compile Error

./Main.cpp: In function ‘void File()’:
./Main.cpp:23:30: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’, declared with attribute warn_unused_result [-Wunused-result]
  freopen ("F.in", "r", stdin);
                              ^
./Main.cpp:24:32: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’, declared with attribute warn_unused_result [-Wunused-result]
  freopen ("F.out", "w", stdout);
                                ^
./Main.cpp: In function ‘int main()’:
./Main.cpp:40:23: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf ("%s", str + 1);
                       ^

Judge Result

Set Name Sample Sub1 Sub2
Score / Max Score 0 / 0 400 / 400 0 / 400
Status
AC × 2
RE × 1
AC × 23
AC × 23
RE × 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 1 ms 256 KB
0_02 AC 54 ms 112896 KB
0_03 RE 154 ms 114560 KB
1_04 AC 1 ms 256 KB
1_05 AC 54 ms 112896 KB
1_06 AC 54 ms 112896 KB
1_07 AC 54 ms 112896 KB
1_08 AC 54 ms 112896 KB
1_09 AC 53 ms 112896 KB
1_10 AC 54 ms 112896 KB
1_11 AC 54 ms 112896 KB
1_12 AC 54 ms 112896 KB
1_13 AC 55 ms 112896 KB
1_14 AC 54 ms 112896 KB
1_15 AC 53 ms 110848 KB
1_16 AC 53 ms 110976 KB
1_17 AC 52 ms 110848 KB
1_18 AC 52 ms 110848 KB
1_19 AC 51 ms 108800 KB
1_20 AC 6 ms 22784 KB
1_21 AC 26 ms 73984 KB
1_22 AC 7 ms 26880 KB
1_23 AC 49 ms 104704 KB
1_24 AC 36 ms 88320 KB
2_25 RE 154 ms 114560 KB
2_26 RE 153 ms 114560 KB
2_27 RE 97 ms 256 KB
2_28 RE 97 ms 256 KB
2_29 RE 97 ms 256 KB
2_30 RE 98 ms 256 KB
2_31 RE 97 ms 256 KB
2_32 RE 97 ms 256 KB
2_33 RE 97 ms 256 KB
2_34 RE 97 ms 256 KB
2_35 RE 97 ms 256 KB
2_36 RE 97 ms 256 KB
2_37 RE 98 ms 256 KB
2_38 RE 98 ms 256 KB
2_39 RE 97 ms 256 KB
2_40 RE 96 ms 256 KB
2_41 RE 154 ms 114560 KB
2_42 RE 97 ms 256 KB
2_43 RE 97 ms 256 KB
2_44 RE 154 ms 114560 KB