Logo
(追記) (追記ここまで)

27701번 - Matrix nightmare 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 1024 MB21150.000%

문제

As Obi-Wan would put it: “This isn’t the problem statement you are looking for. Move along.”

The double factorial numbers are the numbers $d_i$ defined by the following recursive formula: $d_0 = 1,ドル and $∀i > 0$ : $d_i = d_{i-1} \cdot i!$. For example, $d_3 = 1! \cdot 2! \cdot 3! = 12$.

Sequences of length $n$ with all elements belonging into the set $\{0, \dots ,n-1\}$ are called limited sequences of order $n$. For example, $(0, 2, 0, 1)$ is a limited sequence of order 4ドル$. The set of all limited sequences of order $n$ will be denoted $S_n$.

The spread factor of a sequence $A = (a_0, \dots , a_{n-1})$ is the value $σ(A) = \displaystyle\prod_{i=0}^{n-1}\prod_{j=i+1}^{n-1}{(a_i - a_j)}$.

There is a direct isomorphism between pairs of sequences and sequences of pairs. Formally: Let $A, B ∈ S_n$. We can denote their elements as follows: $A = (a_0, \dots , a_{n-1}),ドル $B = (b_0, \dots , b_{n-1})$. The corresponding sequence of pairs $\left((a_0, b_0), \dots ,(a_{n-1}, b_{n-1})\right)$ will be denoted $P_{A,B}$.

Pairs of integers can be ordered lexicographically in the usual fashion: $(a, b) ≤ (c, d)$ if either $a < c,ドル or ($a = c ∧ b ≤ d$). A sequence $P = (p_0, \dots , p_{n-1})$ of pairs of integers is ordered lexicographically if for all $i,ドル $p_i ≤ p_{i+1}$. Let $ρ(P) =$ [if $P$ is ordered lexicographically then 1ドル$ else 0ドル$].

Let $M$ be a $n \times n$ matrix, with rows and columns indexed from 0ドル$ to $n - 1$. Elements of $M$ will be denoted $m_{r,c}$. A matrix is called a $\mathbb{Z}$-var matrix if each element in the matrix is either an integer or a variable. The $n$-step traversal weight of $M$ is the following value

$$φ(M) = \frac{1}{d_{n-1}^2} \cdot \sum_{A=(a_0,\dots ,a_{n-1}), A∈S} \sum_{B=(b_0,\dots ,b_{n-1}), B∈S} \left( ρ\left(P_{A,B}\right) \cdot \left|ρ(A) \right| \cdot ρ(B) \cdot \prod_{i=0}^{n-1}{m_{a_i,b_i}}\right) $$

Given is a multivariate polynomial $p$ with integer coefficients. Produce any reasonably small $\mathbb{Z}$-var matrix $M$ such that $φ(M) = p$.

입력

The first line of the input file contains an integer $t$ specifying the number of test cases. Each test case is preceded by a blank line.

Each test case consists of a single line describing the polynomial. The variables are the letters a through z, the syntax will be clear from the input file. Each polynomial in the input file contains less than 50ドル$ operations (i.e., additions, subtractions and multiplications)

출력

For each test case output one matrix in the following format: First its size $n,ドル then all its elements in row major order. The elements may be separated by any positive amounts of whitespace. The size of the matrix must not exceed 70ドル$. All integers must be between $-10^9$ and 10ドル^9,ドル inclusive.

If for a given polynomial no such matrix exists, output a single zero instead

제한

예제 입력 1

1
xy

예제 출력 1

2
1 y
x 0

힌트

출처

Contest > Internet Problem Solving Contest > IPSC 2012 M번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /