Time limit: 1 second Memory limit: 256 MB on a table 2 n We have 2n coins. n n coins on…
- User
Time limit: 1 second Memory limit: 256 MB on a table 2 n We have 2n coins. n n coins on top of the table with the numbers 1 to n n and n n coins at the bottom of the table with the numbers 1 to n n are located. We know that some (perhaps zero) coins are counterfeit, and the rest are genuine. Genuine coins together, and fake coins together, are of equal weight. We also know that the weight of fake coins is less than the weight of original coins.
Original shape
for every i i and J j, the weight of the coin i Cover the table with a coin from above J We compared from the bottom side of the table and if:
The weight of the coin i The higher the i, the lower the coin J j was down sign < The weight of the coin i The higher i, the more coins J j was down sign > The weight of the coin i i above, equal to the coin J j was down = sign in the line i 1st column J Jam is a table n x n We have written n×n.
Now we want to determine from this table which coins are genuine and which coins are fake. There may be a contradiction in the given table or we may not be able to determine the situation uniquely with the help of this data. We want you to write a program that detects these three states and declares the result.
Read the examples to understand the question better.
input In the first line of input, integer and positive number n n is given to you. 1 ≤ n ≤ 2 , , 000 1≤n≤2,,000
in n n next line, per line n Given n characters, one of <, = or >. It means a coin i iam from J j is less than (<), greater than (>) or equal to (=).
output If the given information is contradictory, the term invalid, otherwise, if we could not uniquely identify the fake or original status, the term not unique, and otherwise, in two lines, in each line a string of 0 (fake) and 1 (original). n Print n indicating the fake or genuine status of the coins at the top and bottom of the table, respectively.
examples Sample entry 1 4 <=<< <=<< =>== <=<< Plain text Sample output 1 0010 1011 Plain text Explanation of sample 1 Sample input 2 3 =<< <=< <<= Plain text Sample output 2 disabled Plain text Explanation of sample 2 Sample entry 3 1
Plain text Sample output 3 not unique write code in java17
- Assistant