Polynomial Equation

시간 제한1.5초메모리 제한1024 MB

요약
체 F_p 위의 이변수 다항식 P와 차수 상한 d가 주어질 때, (P+S)(Q(x)-Q(y))=R(x)-R(y)를 만족하는 일변수 Q, R과 저차 다항식 S가 존재하는지 판정하고 존재하면 Q, R을 출력한다.
난이도

어려움10점 중 9점

유형
수학, 정수론, 조합론, 그리디
정답자
아직 제출이 없습니다

문제

Busy Beaver has a polynomial equation that he doesn't know how to solve, and he needs your help!

For a bivariate polynomial P(x,y)=∑_i,j≥0a_i,jxiyjP(x,y)=\sum\limits\_{i,j \ge 0}a\_{i,j}x^iy^j, define its degree deg⁡P=max⁡_a_i,j≠0(i+j)\deg P = \max\limits\_{a\_{i,j}\neq 0}(i+j). For example, deg⁡(x+y+xy)=2\deg (x + y + xy) = 2. Furthermore, we take the degree of the zero polynomial deg⁡0\deg 0 to be −1-1.

Given a bivariate polynomial P(x,y)P(x,y) with integer coefficients and an integer d≥−1d \geq -1, determine whether there exists a bivariate polynomial S(x,y)S(x, y) and non-constant univariate polynomials Q,RQ, R such that

  • for p=109+7p = 10^9 + 7, we have (P(x,y)+S(x,y))(Q(x)−Q(y))=R(x)−R(y)(P(x, y) + S(x, y))(Q(x) - Q(y)) = R(x) - R(y) as polynomials in F_p\[x,y]\mathbb F\_p\[x, y]1,
  • deg⁡S≤d\deg S \leq d.

If a solution exists, output any valid Q,RQ, R. Note that you do not need to output SS.


1i.e. when expanded, the two sides of the equation have equal coefficients modulo pp.

입력

Each test contains multiple test cases. The first line contains the number of test cases TT (1≤T≤1001 \leq T \leq 100). The description of the test cases follows.

The first line of each test case contains two integers n,dn, d (1≤n≤2.5⋅1031 \leq n \leq 2.5 \cdot 10^3, −1≤d<n-1 \leq d < n) --- the value of deg⁡P\deg P and the upper bound on deg⁡S\deg S, respectively.

The ii-th of the next n+1n + 1 lines contains n+2−in + 2 - i integers a_i−1,0,…,a_i−1,n+1−ia\_{i-1, 0}, \dots, a\_{i-1, n+1-i} (0≤a_i,j<109+70 \leq a\_{i,j} < 10^9 + 7) --- the coefficients of PP so that P(x,y)=∑_i,j≥0,i+j≤na_i,jxiyjP(x,y)=\sum\limits\_{i,j \ge 0, i+j \leq n}a\_{i,j}x^iy^j. It is guaranteed that PP has degree nn, i.e. at least one of a_0,n,a_1,n−1,…,a_n,0a\_{0,n}, a\_{1,n-1}, \dots, a\_{n,0} is nonzero.

It is guaranteed that the sum of nn across all test cases is no more than 2.5⋅1032.5 \cdot 10^3.

출력

The first line of output for each test case should contain the string "YES" (without quotes) if a solution exists, and "NO" (without quotes) otherwise.

If you claim that a solution exists, continue outputting the solution as follows:

The second line of output for each test case should contain three integers q,rq, r (1≤q,r≤5⋅1031 \leq q, r \leq 5 \cdot 10^3) --- the degrees of the polynomials Q,RQ, R respectively.

The third line of output for each test case should contain q+1q + 1 integers b_0,…,b_qb\_0, \dots, b\_q (0≤b_i<109+70 \leq b\_i < 10^9 + 7, b_q≠0b\_q \neq 0) --- the coefficients of Q(t)=∑_i=0qb_itiQ(t) = \sum\_{i=0}^q b\_i t^i.

The fourth line of output for each test case should contain r+1r + 1 integers c_0,…,c_rc\_0, \dots, c\_r (0≤c_i<109+70 \leq c\_i < 10^9 + 7, c_r≠0c\_r \neq 0) --- the coefficients of R(t)=∑_i=0rc_itiR(t) = \sum\_{i=0}^r c\_i t^i.

Note that you do not need to output SS --- the judge will determine if a suitable choice of SS exists for your claimed Q,RQ, R.

힌트

In the first test case, the given polynomial is P(x,y)=13x2+13y2+9x+9y+40.P(x, y) = 13x^2 + 13y^2 + 9x + 9y + 40. We can take S=0S = 0, Q(t)=13t2+9t+20Q(t) = 13t^2 + 9t + 20, R(t)=(13t2+9t+20)2R(t) = (13t^2 + 9t + 20)^2, which gives a valid solution.

In the second test case, it can be shown that no solution exists.

예제1

  1. 예제 1

    입력
    5
    2 -1
    40 9 13
    9 0
    13
    4 2
    1000000000 1 1000000001 2 1
    1 1000000000 2 0
    999999999 2 1
    2 0
    1
    4 2
    1000000000 1 1000000001 2 1
    1 1000000000 1 0
    999999999 1 1
    2 0
    1
    4 2
    120 50 61 235 169
    50 81 119 0
    61 119 169
    235 0
    169
    9 5
    17 18 19 20 21 22 2 6 0 1
    16 8 8 4 8 0 2 0 0
    15 8 0 4 0 0 0 0
    14 4 4 2 4 0 1
    13 8 0 4 0 0
    12 0 0 0 0
    2 2 0 1
    6 0 0
    0 0
    1
    
    예상 출력
    YES
    2 4
    20 9 13
    400 360 601 234 169
    NO
    YES
    2 6
    1 1 1
    2 4 7 7 6 3 1
    NO
    YES
    3 12
    0 2 0 1
    0 0 0 16 16 24 32 12 24 2 8 0 1