Question: give a code in java ( there should not be plagiarism ) B . Nuts and Bolts 2 seconds, 2 5 6 megabytes Steven has

give a code in java(there should not be plagiarism)
B. Nuts and Bolts
2 seconds, 256 megabytes
Steven has n nuts and n bolts. All nuts have different sizes from 1 to n, and all bolts have different sizes from 1 to n.
The operation Steven can perform is to try to compare one of the nuts with one of the bolts. As a result he will learn if the size of nut is greater, the size of bolt is greater or these nut and bolt match. He wants to find the matching nut for every bolt.
You must help Steven to do the plan, using no more than 5nlog2n operations.
Interaction
This is an interactive problem. Your program should communicate with the jury's program, using standard input and output for that.
At the beginning your program receives the integer n(2n1000)- the number of nuts and bolts.
After that you can make no more than 5nlog2n queries. To do a query, output the character "?", and then numbers i and j(
1in,1jn)- the number of nut and the number of bolt that Steven will try to compare.
As a result, you receive one of the three characters:
"", If the size of the i-th nut is less than the size of the j-th bolt,
"=", if the i-th nut and the j-th bolt match,
">", if the size of the i-th nut is greater than the size of the j-th bolt.
As soon as you can say which nut matches which bolt, output the character "!", and then n distinct integers pi(1pin), where pi is the number of bolt which matches the nut with the number i. After that your program must terminate
Please note that each your message must end with a line break. Also after
outputting each message your program must flush the stream buffer, so
that the outputted information could reach jury's program: for instance, this
can be done by calling "fflush (stdout)" or "cout. flush ()" in
C++, "System.out. Plush ()"in Java, "Console. Out. Flush ()"
in CH, "Elush (output)" in Pascal, "sys . stdout. Flush ()" in
Python.
Emply lines in the sample are given only for convenience, to make it clear
in which order the messages are written. When solving the problem you
must not output empty lines and jury's program won't output empty lines
too.
for sample input/output please refer to the images attached.
give a code in java(please there should not be any plagiarism)
give a code in java ( there should not be

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!