#P8798. [蓝桥杯 2022 国 A] 括号序列树

[蓝桥杯 2022 国 A] 括号序列树

Problem Description

There is a binary tree. The root node contains an empty string. For each node, the string on its left child is the string of its parent with one left parenthesis appended at the end, and the string on its right child is the string of its parent with one right parenthesis appended at the end. Each leaf node in the tree corresponds one-to-one to a valid bracket sequence consisting of nn pairs of parentheses.

Given nn, find the number of edges in a maximum matching of this tree.

Input Format

The input consists of one line containing an integer nn.

Output Format

Output one line containing an integer, representing the number of sequences that satisfy the condition. The answer may be very large, so output the remainder when divided by 998244353998244353.

9
10350

Hint

[Test Case Scale and Assumptions]

  • For 20%20\% of the test cases, n10n \leq 10.
  • For 40%40\% of the test cases, n300n \leq 300.
  • For 60%60\% of the test cases, n5000n \leq 5000.
  • For 85%85\% of the test cases, n105n \leq 10^5.
  • For all test cases, 1n1061 \leq n \leq 10^6.

Lanqiao Cup 2022 National Contest Group A, Problem J.

Translated by ChatGPT 5