CF1408G.Clusterization Counting

省选/NOI-

通过率:0%

时间限制:3.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

There are nn computers in the company network. They are numbered from 11 to nn.

For each pair of two computers 1≤i<j≤n1 \leq i \lt j \leq n you know the value ai,ja_{i,j}: the difficulty of sending data between computers ii and jj. All values ai,ja_{i,j} for i<ji \lt j are different.

You want to separate all computers into kk sets A1,A2,…,AkA_1, A_2, \ldots, A_k, such that the following conditions are satisfied:

  • for each computer 1≤i≤n1 \leq i \leq n there is exactly one set AjA_j, such that i∈Aji \in A_j;
  • for each two pairs of computers (s,f)(s, f) and (x,y)(x, y) (s≠fs \neq f, x≠yx \neq y), such that ss, ff, xx are from the same set but xx and yy are from different sets, as,f<ax,ya_{s,f} \lt a_{x,y}.

For each 1≤k≤n1 \leq k \leq n find the number of ways to divide computers into kk groups, such that all required conditions are satisfied. These values can be large, so you need to find them by modulo 998 244 353998\,244\,353.

公司网络中有 nn 台计算机,编号为 11 到 nn。

对于每一对满足 1≤i<j≤n1 \leq i \lt j \leq n 的计算机,已知一个值 ai,ja_{i,j}:表示在计算机 ii 与 jj 之间传输数据的难度。所有满足 i<ji \lt j 的 ai,ja_{i,j} 值互不相同。

你需要将全部计算机划分为 kk 个集合 A1,A2,…,AkA_1, A_2, \ldots, A_k,使得以下条件成立:

  • 对于每台计算机 1≤i≤n1 \leq i \leq n,恰好存在一个集合 AjA_j,使得 i∈Aji \in A_j;
  • 对于任意两对计算机 (s,f)(s, f) 和 (x,y)(x, y)(其中 s≠fs \neq f,x≠yx \neq y),若 ss、ff、xx 属于同一集合,而 xx 与 yy 属于不同集合,则必有 as,f<ax,ya_{s,f} \lt a_{x,y}。

对每个 1≤k≤n1 \leq k \leq n,求出将计算机划分为 kk 个组、且满足上述所有条件的方案数。答案可能很大,因此需对 998 244 353998\,244\,353 取模。

输入格式

The first line contains a single integer nn (1≤n≤15001 \leq n \leq 1500): the number of computers.

The ii-th of the next nn lines contains nn integers ai,1,ai,2,…,ai,na_{i,1}, a_{i,2}, \ldots, a_{i,n}(0≤ai,j≤n(n−1)20 \leq a_{i,j} \leq \frac{n (n-1)}{2}).

It is guaranteed that:

  • for all 1≤i≤n1 \leq i \leq n ai,i=0a_{i,i} = 0;
  • for all 1≤i<j≤n1 \leq i \lt j \leq n ai,j>0a_{i,j} \gt 0;
  • for all 1≤i<j≤n1 \leq i \lt j \leq n ai,j=aj,ia_{i,j} = a_{j,i};
  • all ai,ja_{i,j} for i<ji \lt j are different.

第一行包含一个整数 nn(1≤n≤15001 \leq n \leq 1500):计算机的数量。

接下来的 nn 行中,第 ii 行包含 nn 个整数 ai,1,ai,2,…,ai,na_{i,1}, a_{i,2}, \ldots, a_{i,n}(0≤ai,j≤n(n−1)20 \leq a_{i,j} \leq \frac{n (n-1)}{2})。

保证满足以下条件:

  • 对所有 1≤i≤n1 \leq i \leq n,有 ai,i=0a_{i,i} = 0;
  • 对所有 1≤i<j≤n1 \leq i \lt j \leq n,有 ai,j>0a_{i,j} \gt 0;
  • 对所有 1≤i<j≤n1 \leq i \lt j \leq n,有 ai,j=aj,ia_{i,j} = a_{j,i};
  • 所有满足 i<ji \lt j 的 ai,ja_{i,j} 互不相同。

输出格式

Print nn integers: the kk-th of them should be equal to the number of possible ways to divide computers into kk groups, such that all required conditions are satisfied, modulo 998 244 353998\,244\,353.

输出 nn 个整数:其中第 kk 个整数应等于将计算机划分为 kk 个组的方案数(需满足所有给定条件),并对 998 244 353998\,244\,353 取模。

输入输出样例

  • 输入#1

    4
    0 3 4 6
    3 0 2 1
    4 2 0 5
    6 1 5 0

    输出#1

    1 0 1 1
  • 输入#2

    7
    0 1 18 15 19 12 21
    1 0 16 13 17 20 14
    18 16 0 2 7 10 9
    15 13 2 0 6 8 11
    19 17 7 6 0 4 5
    12 20 10 8 4 0 3
    21 14 9 11 5 3 0

    输出#2

    1 1 2 3 4 3 1

说明/提示

Here are all possible ways to separate all computers into 44 groups in the second example:

  • 1,2,3,4,5,6,7{1, 2}, {3, 4}, {5}, {6, 7};
  • 1,2,3,4,5,6,7{1}, {2}, {3, 4}, {5, 6, 7};
  • 1,2,3,4,5,6,7{1, 2}, {3}, {4}, {5, 6, 7}.

第二个示例中,将所有计算机划分为 44 组的所有可能方式如下:

  • 1,2,3,4,5,6,7{1, 2}, {3, 4}, {5}, {6, 7};
  • 1,2,3,4,5,6,7{1}, {2}, {3, 4}, {5, 6, 7};
  • 1,2,3,4,5,6,7{1, 2}, {3}, {4}, {5, 6, 7}。

输入解题思路,AI测评打分。不知道怎么写?

首页