[AGM 2022 资格赛] 括号

Luogu
IDLGP8235
Time1000ms
Memory512MB
DifficultyP3
2022O2优化AGM
给你一棵 $n$ 个节点的树,其中一号点填了一个左括号,你需要给其余每个点填上 `(` 或 `)`,使得树上合法括号路径数量最多,保证答案唯一。 ## Input 第一行一个数 $n$。 接下来 $n-1$ 行,每行两个正整数 $x,y$ 表示 $x$ 与 $y$ 有一条边相连。 ## Output 一行一个长度为 $n$ 的括号串。 [samples] ## Note #### 数据规模与约定 对于 $100\%$ 的数据,保证 $1 \leq n\leq 10^5$。 #### 说明 翻译自 [AGM 2022 Qualification Round G Parenthesis](https://judge.agm-contest.com/public/problems/5/text)。
Samples
Input #1
3
1 2
1 3
Output #1
())
API Response (JSON)
{
  "problem": {
    "name": "[AGM 2022 资格赛] 括号",
    "description": {
      "content": "给你一棵 $n$ 个节点的树,其中一号点填了一个左括号,你需要给其余每个点填上 `(` 或 `)`,使得树上合法括号路径数量最多,保证答案唯一。",
      "description_type": "Markdown"
    },
    "platform": "Luogu",
    "limit": {
      "time_limit": 1000,
      "memory_limit": 524288
    },
    "difficulty": {
      "LuoguStyle": "P3"
    },
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "LGP8235"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "给你一棵 $n$ 个节点的树,其中一号点填了一个左括号,你需要给其余每个点填上 `(` 或 `)`,使得树上合法括号路径数量最多,保证答案唯一。\n\n## Input\n\n第一行一个数 $n$。\n\n接下来 $n-1$ 行,每行两个正整数 $x,y$ 表示 $x$ 与 $y$ 有一条边相连。\n\n## Output\n\n一行一个长度为 $n$ 的括号串。\n\n[samples]\n\n## Note\n\n#### ...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments