-->
当前位置:首页 > 题库

PROGRAMMING:Latin squares

Luz5年前 (2021-05-10)题库507
A Latin Square is an n-by-n array filled with n different digits, each digit occurring exactly once in each row and once in each column. (The name “Latin Square” was inspired by the work of Leonhard Euler, who used Latin characters in his papers on the topic.)
Latin square is ñ-ñ Array full ñ There are three different numbers, each of which appears exactly once in each row and column(“ The name "Latin square" is inspired by the work of Leonhard Euler, who used Latin characters in his papers on the subject.)
A Latin Square is said to be in reduced form if both its top row and leftmost column are in their natural order. The natural order of a set of digits is by increasing value.
It is said that there is a Latin square. If its top row and leftmost column are in natural order, it is. The natural order of a set of numbers is achieved by adding value.
Your team is to write a program that will read an n-by-n array, and determine whether it is a Latin Square, and if so, whether it is in reducedreduced form.
Your team is going to write a program that will read ñ-ñ Array, and determine whether it is a Latin rectangle, and if so, whether it meets the above requirements.
###Input format:
The first line of input contains a single integer n (2≤n≤36).
The first line of input contains an integer ññ ( 2≤n≤36)(2≤ ñ ≤3 6 )。
Each of the next nn lines contains nn digits in base nn, with the normal digits ‘0’ through ‘9’ for digit values below 10 and uppercase letters ‘A’ through ‘ZZ’ representing digit values 10 through 35. All digits will be legal for base nn; for instance, if n is 3, the only legal characters in the nn input lines describing the square will be ‘0’, ‘1’, and ‘2’.
The first line of input contains an integer ñ( 2≤ ñ ≤3 6 )。
The number of n * N in the next line, 0-9 is 0-9, and the part over 10 is represented by A-Z. All the numbers are legal ñ; For example, if ñ Is 3, the input lines are '0', '1' and '2'.
###Output format:
If the given array is not a Latin Square, print “No” on a single line (without quotation marks). If it is a Latin Square, but not in reducedreduced form, print “Not Reduced” on a single line (without quotation marks). If it is a Latin Square in reducedreduced form, print “Reduced” on a single line (without quotation marks).
If it is not a Latin rectangle, print "no"; if it is, but the top line and the leftmost line are not incremental sequence, print "not reduced"; otherwise, print "reduced";
###Input example:
Here is a set of inputs. For example:
```in
three
012
one hundred and twenty
two hundred and one
```
###Output example:
The corresponding output is given here. For example:
```out
Reduced
```







answer:If there is no answer, please comment