Table Tennis

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

요약
N과 M이 주어질 때, 순환하는 세 선수 조합이 정확히 M개인 라운드 로빈 토너먼트 결과를 하나 구성하거나, 불가능하면 No를 출력한다.
난이도

어려움10점 중 8점

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

문제

A table tennis competition was held in JOI Kingdom. NN beavers numbered from 11 to NN participated in this competition, and a round-robin tournament was conducted.

You were told the following information about the result of this competition from Bitaro.

  • There were no draw match.

  • There are exactly MM ways to choose 33 beavers which are trilemma. Note that 33 beavers ii, jj, kk (1≤i<j<k≤N1 ≤ i < j < k ≤ N) are trilemma if and only if exactly one of the following 22 conditions is satisfied.

    • Beaver ii beat beaver jj, beaver jj beat beaver kk, and beaver kk beat beaver ii.
    • Beaver ii beat beaver kk, beaver kk beat beaver jj, and beaver jj beat beaver ii.

You don’t know whether the information from Bitaro is correct, so you decided to think whether there are any results of this competition which accord with the information from Bitaro.

Write a program which, given the information from Bitaro, judge whether there are any results of this competition which accord with the information, and if so, finds one such result of this competition.

입력

A test case consists of QQ scenarios, numbered from 11 to QQ. The following values are specified for each scenario.

  • The number of beavers NN which participated in the competition.
  • The number of ways MM to choose 33 beavers which are trilemma.

The format of the input data is as follows.

QQ

(Input for Scenario 11)

(Input for Scenario 22)

⋮\vdots

(Input for Scenario QQ)

The format of the input data for each scenario is as follows.

NN MM

출력

Write to standard output the answer of Scenario 1,2,…,Q1, 2, \dots , Q in order as follows.

In some scenario, if there are any results of this competition which accord with the information, output as follows.

Yes

S_2S\_2

S_3S\_3

⋮\vdots

S_NS\_N

Here, S_iS\_i (2≤i≤N2 \le i \le N) is a string of which characters are '0' or '1' and length is i−1i-1. jj-th character of S_iS\_i is '0' means beaver ii was defeated beaver jj, and jj-th character of S_iS\_i is '1' means beaver ii won beaver jj. If multiple results exist, you can output any of them.

In some scenario, if there are not any results of this competition which accord with the information, output No.

제한

  • 1≤Q1 ≤ Q.
  • 3≤N≤5,0003 ≤ N ≤ 5\\, 000.
  • 0≤M≤16N(N−1)(N−2)0 ≤ M ≤ \frac{1}{6}N(N - 1)(N - 2).
  • The sum of NN for the QQ scenarios is less than or equal to 5,0005\\, 000.
  • Given values are all integers.

예제2

  1. 예제 1

    입력
    2
    3 1
    4 4
    
    예상 출력
    Yes
    0
    10
    No
    
  2. 예제 2

    입력
    1
    5 3
    
    예상 출력
    Yes
    0
    11
    001
    0101