#P10441. [JOIST 2024] 乒乓球 / Table Tennis
[JOIST 2024] 乒乓球 / Table Tennis
Problem Description
A table tennis tournament was held in the kingdom of JOI. beavers numbered from to participated in the tournament, and they played a round-robin tournament.
You learned the following information about the match results from Bitaro.
- There are no drawn matches.
- There are exactly ways to choose beavers that form a “triple paradox”. Note that beavers () form a “triple paradox” if and only if exactly one of the following two conditions holds.
-
- Beaver defeated beaver , beaver defeated beaver , and beaver defeated beaver .
-
- Beaver defeated beaver , beaver defeated beaver , and beaver defeated beaver .
You are not sure whether the information provided by Bitaro is correct, so you decided to think about whether there are any match results consistent with Bitaro’s information. Write a program that, based on the information provided by Bitaro, determines whether there are any match results consistent with it; if there are, find any such match results.
Input Format
One test case consists of scenarios, numbered from to . Each scenario specifies the following values.
- The number of beavers participating in the tournament.
- The number of ways to choose beavers that form a “triple paradox”.
The input format is as follows.
For each scenario, the input format is as follows.
Output Format
For each scenario, write the answer to standard output in the following order.
In some scenarios, if there exist any match results consistent with the information, output in the following format.
- Yes
- ...
Here, for (), it is a string of length consisting of characters '0' and '1'. The -th character of is '0' if beaver was defeated by beaver , and '1' if beaver defeated beaver . If multiple results exist, you may output any one of them.
In some scenarios, if there are no match results consistent with the information, output No.
2
3 1
4 4
Yes
0
10
No
1
5 3
Yes
0
11
001
0101
Hint
Sample Explanation 1
There are scenarios.
In this sample output, for scenario , the result is: beaver defeated beaver , beaver defeated beaver , and beaver defeated beaver . Therefore, beavers form a “triple paradox”. There is no other way to choose beavers, so there are exactly way to choose beavers that form a “triple paradox”.
Another possible output for scenario is as follows.
Yes
1
01
In scenario , there are no match results consistent with the information. Therefore, output No.
This sample input satisfies the constraints of subtasks .
Sample Explanation 2
In this sample output, for scenario , the result is: beaver defeated beaver , beaver defeated beaver , and beaver defeated beaver . Therefore, beavers form a “triple paradox”. There are two other ways to choose beavers that form a “triple paradox”: choosing beavers and choosing beavers . Therefore, there are exactly ways to choose beavers that form a “triple paradox”.
This sample input satisfies the constraints of all subtasks.
Constraints
- .
- .
- .
- The sum of over the scenarios does not exceed 5000.
- All given values are integers.
Subtasks
- (5 points) .
- (4 points) The sum of over the scenarios does not exceed 7.
- (23 points) The sum of over the scenarios does not exceed 20.
- (30 points) The sum of over the scenarios does not exceed 150.
- (15 points) The sum of over the scenarios does not exceed 600.
- (23 points) No additional constraints.
Translated by ChatGPT 5