Submission #836831


Source Code Expand

Copy
/*
*/

//#pragma comment(linker, "/STACK:16777216")
#define _CRT_SECURE_NO_WARNINGS

#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>
#include <memory.h>
#include <assert.h>

#define y0 sdkfaslhagaklsldk
#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define norm asdfasdgasdgsd

#define eps 1e-9
#define M_PI 3.141592653589793
#define bs 1000000007
#define bsize 350

using namespace std;

const int INF = 1e9;
const int N = 200000;

int n;
string st;
int dp[320][320][320];

void add(int&a, int b)
{
	a += b;
	if (a >= bs)
		a -= bs;
}

int main(){
	//freopen("fabro.in","r",stdin);
	//freopen("fabro.out","w",stdout);
	//freopen("F:/in.txt", "r", stdin);
	//freopen("F:/output.txt", "w", stdout);
	ios_base::sync_with_stdio(0);
	//cin.tie(0);

	cin >> n;
	cin >> st;
	dp[0][0][0] = 1;
	for (int i = 0; i < n; i++)
	{
		for (int len = 0; len <= i; len++)
		{
			for (int cp = 0; cp <= st.size(); cp++)
			{
				// add char
				add(dp[i + 1][len + 1][cp == len&&cp<st.size() ? cp + 1 : cp], dp[i][len][cp]);
				add(dp[i + 1][len + 1][cp], dp[i][len][cp]);
				// remove char
				int new_len = len - 1;
				if (new_len<0)
					new_len++;
				add(dp[i + 1][new_len][min(new_len, cp)], dp[i][len][cp]);
			}
		}
	}

	cout << dp[n][st.size()][st.size()];

	cin.get(); cin.get();
	return 0;
}

Submission Info

Submission Time
Task F - Unhappy Hacking
User LeBron
Language C++14 (GCC 5.4.1)
Score 400
Code Size 1654 Byte
Status TLE
Exec Time 2112 ms
Memory 68224 KB

Compile Error

./Main.cpp:33:0: warning: "M_PI" redefined
 #define M_PI 3.141592653589793
 ^
In file included from /usr/include/c++/5/cmath:44:0,
                 from /usr/include/c++/5/complex:44,
                 from ./Main.cpp:10:
/usr/include/math.h:372:0: note: this is the location of the previous definition
 # define M_PI  3.14159265358979323846 /* pi */
 ^

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
TLE × 12
RE × 9
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 157 ms 57600 KB
0_03 RE 506 ms 65024 KB
1_04 AC 4 ms 256 KB
1_05 AC 168 ms 57600 KB
1_06 AC 154 ms 57600 KB
1_07 AC 241 ms 57728 KB
1_08 AC 295 ms 57856 KB
1_09 AC 294 ms 57856 KB
1_10 AC 293 ms 57728 KB
1_11 AC 168 ms 57600 KB
1_12 AC 276 ms 57728 KB
1_13 AC 270 ms 57728 KB
1_14 AC 249 ms 57728 KB
1_15 AC 175 ms 56832 KB
1_16 AC 280 ms 57088 KB
1_17 AC 185 ms 55680 KB
1_18 AC 237 ms 55808 KB
1_19 AC 181 ms 54912 KB
1_20 AC 13 ms 2816 KB
1_21 AC 90 ms 26240 KB
1_22 AC 15 ms 3840 KB
1_23 AC 247 ms 50816 KB
1_24 AC 176 ms 36992 KB
2_25 RE 355 ms 65024 KB
2_26 RE 374 ms 65024 KB
2_27 TLE 2108 ms 68096 KB
2_28 TLE 2106 ms 44672 KB
2_29 TLE 2106 ms 44928 KB
2_30 RE 1397 ms 66688 KB
2_31 TLE 2112 ms 67456 KB
2_32 RE 1552 ms 67072 KB
2_33 TLE 2106 ms 46592 KB
2_34 TLE 2108 ms 66944 KB
2_35 TLE 2112 ms 68224 KB
2_36 TLE 2106 ms 46592 KB
2_37 TLE 2107 ms 55168 KB
2_38 TLE 2107 ms 63360 KB
2_39 TLE 2106 ms 51968 KB
2_40 TLE 2107 ms 54144 KB
2_41 RE 416 ms 65024 KB
2_42 RE 1932 ms 67584 KB
2_43 RE 971 ms 65920 KB
2_44 RE 793 ms 65664 KB