Nastia has a concealed change p of length n comprising of integers from 1 to n. You, for reasons unknown, need to sort out the change. To do that, you can give her an integer t (1≤t≤2), two unique records I and j (1≤i,j≤n, i≠j), and an integer x (1≤x≤n−1).

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Correct answer will be upvoted else downvoted.

 

 

 

Nastia has a concealed change p of length n comprising of integers from 1 to n. You, for reasons unknown, need to sort out the change. To do that, you can give her an integer t (1≤t≤2), two unique records I and j (1≤i,j≤n, i≠j), and an integer x (1≤x≤n−1). 

 

Contingent upon t, she will reply: 

 

t=1: max(min(x,pi),min(x+1,pj)); 

 

t=2: min(max(x,pi),max(x+1,pj)). 

 

You can ask Nastia at most ⌊3⋅n2⌋+30 times. It is ensured that she won't change her stage contingent upon your questions. Would you be able to figure the change? 

 

Input 

 

The input comprises of a few experiments. First and foremost, you get the integer T (1≤T≤10000) — the number of experiments. 

 

Toward the start of each experiment, you get an integer n (3≤n≤104) — the length of the change p. 

 

It's reliable that the change is fixed ahead of time and that the amount of n in one test doesn't surpass 2⋅104. 

 

Connection 

 

To pose an inquiry, print "? t I j x" (t=1 or t=2, 1≤i,j≤n, i≠j, 1≤x≤n−1) Then, you should peruse the appropriate response. 

 

In the event that we reply with −1 rather than a substantial reply, that implies you surpassed the number of inquiries or made an invalid question. Exit following getting −1 and you will see the Wrong Answer decision. If not, you can get a discretionary decision in light of the fact that your answer will keep on perusing from a shut stream.

Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Public key encryption
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education