I didn’t understand the program logic speacially the query function.
Regarding the interactive problem lost number from codeforces
see we have first made following observation.
a) product of any two numbers are always distinct.
ie if a * b = x then its only a and b that can make x.
b) we have only 6 elements in our array, that means total 6! (720)different array possible.
c) now all we have to identify is the correct array among those 720 array.
how we can do that.
first we query product of adjacent elements
we will have
[ a[0]*a[1] , a[1]*a[2] , a[2]*a[3], a[3]*a[4] ]
also we have array p= [ 4, 8, 15, 16, 23, 42 ]
generate all its permuatation and check whether
[ p[0]*p[1] , p[1]*p[2] , p[2]*p[3], p[3]*p[4] ] == [ a[0]*a[1] , a[1]*a[2] , a[2]*a[3], a[3]*a[4] ]
if it is then that is a valid permuation that staisfy the given constraint.
note : we dont bother about the last element , becuase if we have already determined first five element then 6th is already known to us(we only have 6 different no)
But here are we fixing the query as product of adjacent elements right? But in the sample test case for the first two elements they have taken squares of themselves to determine the nos. So when we are fixing the query as the product of adjacent elements then how are we passing all test cases and getting verdict as accepted?
Like in these interactive problems I am unable to understand which all will actually be our input Or output? And also what to fix the query as?
sample case is for example purpose, thier algorithm/stratergy is not similar to ours .
already explained above what we are doing, why we are doing and how we are doing?
pls check input and output format from the question ->link
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.
How do we get the array a for the hidden test cases?
We have not created any logic to build array a in our code right
How will the compiler understand that the 1st element of array a will be the product of 0 th and 1st index of the given array nos?
So if the compiler gives the 0 th index as the product of other two elements then we will get the wrong array as output right
we dont get array a direclty,
that is why we are using queries and our algorithm to determine what the array would be
we have , here it is->
see its our responsibility to observe the problem and determine how array should look like , compiler has no role in it.
thats our logic, compiler has nothing to do with it.
at the end whaterver output(array) we will print, online judge will match with correct output , if it matches then u get ac verdict otherwise wa.
No the logic building of Array a I understood. But for the hidden or runtime tcs we are not giving any input right. But in the sample tc we have actually given array a as input.There I have the doubt actually that what happens for hidden tcs which occur during runtime and we don’t give input for them
see whatever query u will make , in return u will get the product, this is only informtation available to us and the logic that we have framed is based on this only.
determining the array is our task so why they would provide us in input.
no . … . . . .,in input we are given response of our queries, that is not the array a