問題一覧 > 通常問題

No.2435 Order All Company

レベル : / AI推定難易度 : 1800 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 40
作問者 : yuyu_5510 / テスター : 0214sh7 ebi_fly noya2 👑 potato167
お気に入りにしたユーザー ProblemId : 10004 / 自分の提出
問題文最終更新日: 2023-08-15 23:38:07
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
traP 作問ハッカソンコンテスト 001 (順位表) の他の問題:

Problem Statement

There are towns numbered from $1$ to $N$. Initially, travel between any of the towns is impossible.

You are going to place orders with construction companies to build bridges, each of which connects $2$ distinct towns and makes travel between them possible. You will build $N-1$ bridges so that travel between all towns becomes possible.

The $K$ construction companies are numbered from $1$ to $K$, and company $i$ can be ordered to build $t_i$ kinds of bridges. For $j=1,2,\dots ,t_i$, the bridge with order number $j$ connects town $a_{ij}$ and town $b_{ij}$.

How many ways are there to place $N-1$ orders in total across the companies such that all of the following conditions are satisfied?

  • When all the ordered bridges are built, travel between all towns is possible by passing through the bridges
  • Orders are placed at least $1$ time with every one of the $K$ construction companies
Here, $2$ ways of ordering are considered different if and only if their sets of pairs of ordered construction company and order number are different.

Find the answer modulo $998244353$.

Constraints

  • $2\leq N \leq 50$
  • $1 \leq K \leq 5$
  • $1 \leq a_{ij}, b_{ij} \leq N$
  • $a_{ij} \neq b_{ij}$
  • $1 \leq t_i$
  • $1 \leq \sum_{i=1}^{K}{t_i} \leq 10^5$
  • All inputs are integers
  • Input

    $N$ $K$
    $t_1$
    $a_{11}$ $b_{11}$
    $\vdots$
    $a_{1t_1}$ $b_{1t_1}$
    $\vdots$
    $t_K$
    $a_{K1}$ $b_{K1}$
    $\vdots$
    $a_{Kt_K}$ $b_{Kt_K}$
    

    Output

    Output the number of ways to place the orders, modulo $998244353$.

    Sample

    Sample 1
    Input
    2 1
    1
    1 2
    Output
    1

    There is only 1 contractor for a bridge that makes travel between the 2 towns possible.

    Sample 2
    Input
    2 1
    4
    1 2
    1 2
    1 2
    1 2
    Output
    4

    The same construction company may be able to take multiple orders for bridges that make travel between the same towns possible.

    Sample 3
    Input
    3 2
    1
    1 2
    1
    1 2
    Output
    0

    There may be no way of ordering that satisfies the conditions.

    Sample 4
    Input
    5 3
    3
    1 2
    2 4
    3 5
    2
    3 4
    4 5
    6
    1 2
    2 3
    3 4
    4 5
    1 3
    1 5
    Output
    56

    提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。