Mark and the Online Exam solution codeforces
Solution – CLICK HERE
Mark is administering an online exam consisting oftrue-false questions. However, he has lost all answer keys. He needs a way to retrieve the answers before his client gets infuriated.
Fortunately, he has access to the grading system. Thus, for each query, you can input the answers to allquestions, and the grading system will output how many of them are correct.
He doesn’t have much time, so he can use the grading system at mosttimes. Help Mark determine the answer keys.
Note that answer keys are fixed in advance and will not change depending on your queries.
The first line of the input consists of an integer( ) — the number of questions.
After reading T‘ and ‘F‘., you can start making queries to the grading system. For each query, print a line containing a string of length consisting of only letters ‘
- T‘ means that you answer the -question true. ‘
- F‘ means that you answer the -question false. ‘
After a successful query, you should read an integer If you read , then you found the answers, and your program should not make any more queries.( ) — the number of correct answers.
If your program reads Wrong answer verdict. Otherwise, you can get an arbitrary verdict because your solution will continue to read from a closed stream.instead of the number of correct answers, it means that you either made an invalid query or exceeded the query limits. Exit immediately after receiving , and you will see
After printing a query do not forget to output end of line and flush the output. Otherwise, you will get Idleness limit exceeded. To do this, use:
- fflush(stdout) or cout.flush() in C++;
- System.out.flush() in Java;
- flush(output) in Pascal;
- stdout.flush() in Python;
- see documentation for other languages.
To hack, use the following format:
The first line contains an integer( ) — the number of questions.
The second line contains a string T‘ and ‘F‘ — the answer key.of length consisting of only ‘
3 1 3
4 0 3 4
FTFF TTTT TFTT
The empty lines in the example are just for you to better understand the interaction process. You’re not required to print them.
In the first example, there are true‘, ‘true‘, and ‘false‘, respectively.questions, and the answer to each question is ‘
- The first query, guessing the answers to be ‘false‘, ‘true‘, and ‘true‘, respectively, guesses only one question — the -nd question — correctly.
- Then, in the second query, the program correctly guesses the answer key. The interaction ends here.
In the second example, there are true‘, ‘false‘, ‘true‘, and ‘true‘, respectively.questions, and the answer to each question is ‘
- The first query guessed none of the questions correctly, resulting in the answer .
- The second query guessed the -st, -rd, and -th question correctly, resulting in the answer .
- In the third query, the program correctly guesses the answer key. Then, the interaction ends.