Lets discuss a nice interactive problem today!
We are talking about this problem : -Problem - E - Codeforces
It has striking similarity with :- CodeChef: Practical coding for everyone (Benefits of Practicing Long Challenge )
My solution:-H529Vn - Online C++0x Compiler & Debugging Tool - Ideone.com
Quick Explanation:-
1)We print numbers from ‘1’ to ‘100’.
2)Now, we get to know 100 possible values of ‘x’ , one of them is our answer for sure .
3)In these type of problems, you should always think in terms of brute force
4) Say, in next-query, we print:- “101…200”, we get 100 possibilities again.
5)What we can do is create a 2-D array before asking the 2nd query, and store all the possibilities (this is the hard part to think about if you don’t have experience with ‘GUESSPRIME’ problem of Codechef.)
6)As soon as we get the answer from the jury for our 2nd query, we compare it with all the possibilities of our 2-D array, if anyone matches, we print that number
7)This gives WA , (why?) , the high level idea here is :- All the numbers in the 2nd query, if you xor them with all possibilities of ‘x’ from the query ‘1’ , none of them should match! If they match, you’ll get many incorrect values in your 2-D array(your 2-D array will guess 4-5 XOR VALUES AND YOU HAVE TO GUESS ONLY ONE.)
8)Hail to the bruteforce!! We do brute-force to find a sequence of 100 numbers for the second query in which none of the pairs will have same xor
9)Finally, we get AC.
Credit:-All credit goes to @l_returns as he taught me , how can we just use:-cin,cout,endl and be super-safe in interactive problems
If time permits, I’ll try to put detailed editorials of problems C and D as well