luogu#P5271. OwenOwl 不学车也不删库
OwenOwl 不学车也不删库
Background
mcfx and ComeIntoPower like to make up problem backgrounds when they are bored. OwenOwl asked “buddy” zcysky why they did this, and “buddy” zcysky replied like this:

OwenOwl felt very upset, so one day he found J, and asked J to create 20010910 pointers to point the three of them to Azerbaijan to keep sunset company there.
While the three of them were touring Azerbaijan, OwenOwl smashed the car, and the repository was restored.
However, since mcfx and ComeIntoPower had previously posted too many nasty problems using the ID OwenOwl, OwenOwl’s reputation had already been damaged. To prove that the nasty ones were those two and not himself, OwenOwl made an easy “sign-in” problem.
Problem Description
Let be a prime number.
You are given an undirected complete graph with vertices (there is an undirected edge between any two vertices). The vertices are labeled from to .
Now you need to find some complete subgraphs on vertices such that every edge in the original graph belongs to one and only one of these complete subgraphs.
Obviously, the number of complete subgraphs you need to find is . You can see that this expression is always an integer.
Input Format
One line containing two positive integers .
Output Format
If there is no solution, output one line NO.
Otherwise, output one line YES, then output lines. Each line contains numbers, representing the vertex labels of one complete subgraph you found.
You may output any valid solution in any order.
2 2
YES
0 1
2 0
3 0
1 2
1 3
3 2
3 1
YES
0 1 2
Hint
For of the testdata, .
For of the testdata, .
Another of the testdata has .
For of the testdata, is a positive integer, is prime, and .
In addition, the total output size is guaranteed not to exceed 2MB, but you should still pay attention to the time spent on output.
Translated by ChatGPT 5