Submission #31921160


Source Code Expand

#include <cstdio>
#define MOD 998244353
#define maxn 505
using namespace std;

using LL = long long;
int p[maxn], dp[maxn][maxn];

int main()
{
	int n;
	scanf("%d", &n);
	for(int i=0; i<n; i++)
		scanf("%d", p + i);
	for(int i=1; i<=n; i++)
		dp[i][i] = 1;
	for(int d=1; d<=n; d++)
		for(int l=1, r=d+1; r<=n; l++, r++)
		{
			dp[l][r] = dp[l + 1][r];
			for(int k=l+1; k<r; k++)
				if(p[l] < p[k] && (dp[l][r] += LL(dp[l + 1][k]) * dp[k][r] % MOD) >= MOD)
					dp[l][r] -= MOD;
		}
	printf("%d\n", dp[1][n]);
	return 0;
}

Submission Info

Submission Time
Task G - Pre-Order
User good_coder_666
Language C++ (GCC 9.2.1)
Score 600
Code Size 549 Byte
Status AC
Exec Time 66 ms
Memory 2680 KiB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:12:7: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   12 |  scanf("%d", &n);
      |  ~~~~~^~~~~~~~~~
./Main.cpp:14:8: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   14 |   scanf("%d", p + i);
      |   ~~~~~^~~~~~~~~~~~~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 600 / 600
Status
AC × 2
AC × 35
Set Name Test Cases
Sample example_00.txt, example_01.txt
All example_00.txt, example_01.txt, hand_00.txt, hand_01.txt, hand_02.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, random_24.txt, random_25.txt, random_26.txt, random_27.txt, random_28.txt, random_29.txt
Case Name Status Exec Time Memory
example_00.txt AC 8 ms 1644 KiB
example_01.txt AC 2 ms 1636 KiB
hand_00.txt AC 66 ms 2652 KiB
hand_01.txt AC 21 ms 2644 KiB
hand_02.txt AC 1 ms 1712 KiB
random_00.txt AC 53 ms 2596 KiB
random_01.txt AC 1 ms 1624 KiB
random_02.txt AC 43 ms 2488 KiB
random_03.txt AC 25 ms 2392 KiB
random_04.txt AC 3 ms 1876 KiB
random_05.txt AC 2 ms 1944 KiB
random_06.txt AC 2 ms 1864 KiB
random_07.txt AC 1 ms 1752 KiB
random_08.txt AC 42 ms 2516 KiB
random_09.txt AC 5 ms 1940 KiB
random_10.txt AC 51 ms 2536 KiB
random_11.txt AC 41 ms 2532 KiB
random_12.txt AC 48 ms 2584 KiB
random_13.txt AC 49 ms 2580 KiB
random_14.txt AC 58 ms 2604 KiB
random_15.txt AC 48 ms 2544 KiB
random_16.txt AC 48 ms 2544 KiB
random_17.txt AC 43 ms 2532 KiB
random_18.txt AC 55 ms 2628 KiB
random_19.txt AC 58 ms 2680 KiB
random_20.txt AC 56 ms 2628 KiB
random_21.txt AC 57 ms 2628 KiB
random_22.txt AC 50 ms 2584 KiB
random_23.txt AC 62 ms 2640 KiB
random_24.txt AC 60 ms 2648 KiB
random_25.txt AC 32 ms 2576 KiB
random_26.txt AC 54 ms 2612 KiB
random_27.txt AC 58 ms 2676 KiB
random_28.txt AC 44 ms 2648 KiB
random_29.txt AC 28 ms 2576 KiB