A15566 | Joking (Easy Version)
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
The only difference between this problem and the hard version is the maximum number of questions.
This is an interactive problem.
There is a hidden integer $1 \le x \le n$ which you have to find. In order to find it you can ask at most $\mathbf{82}$ questions.
In each question you can choose a non-empty integer set $S$ and ask if $x$ belongs to $S$ or not, after each question, if $x$ belongs to $S$ , you'll receive "YES", otherwise "NO".
But the problem is that not all answers are necessarily true (some of them are joking), it's just guaranteed that for each two consecutive questions, at least one of them is answered correctly.
Additionally to the questions, you can make at most $2$ guesses for the answer $x$ . Each time you make a guess, if you guess $x$ correctly, you receive ":)" and your program should terminate, otherwise you'll receive ":(".
As a part of the joking, we will not fix the value of $x$ in the beginning. Instead, it can change throughout the interaction as long as all the previous responses are valid as described above.
Note that your answer guesses are always answered correctly. If you ask a question before and after a guess, at least one of these two questions is answered correctly, as normal.
This is an interactive problem.
There is a hidden integer $1 \le x \le n$ which you have to find. In order to find it you can ask at most $\mathbf{82}$ questions.
In each question you can choose a non-empty integer set $S$ and ask if $x$ belongs to $S$ or not, after each question, if $x$ belongs to $S$ , you'll receive "YES", otherwise "NO".
But the problem is that not all answers are necessarily true (some of them are joking), it's just guaranteed that for each two consecutive questions, at least one of them is answered correctly.
Additionally to the questions, you can make at most $2$ guesses for the answer $x$ . Each time you make a guess, if you guess $x$ correctly, you receive ":)" and your program should terminate, otherwise you'll receive ":(".
As a part of the joking, we will not fix the value of $x$ in the beginning. Instead, it can change throughout the interaction as long as all the previous responses are valid as described above.
Note that your answer guesses are always answered correctly. If you ask a question before and after a guess, at least one of these two questions is answered correctly, as normal.
输入格式
The only line of the input contains a single integer $n$ ( $1 \le n \le 10^5$ ), the maximum possible value of $x$ .
输出格式
For each question, if you want to ask about a set $S$ , first print the character '?', then print the size of $S$ and then print the elements of $S$ one by one. Each element should be an integer between $1$ and $n$ , the elements must be distinct. After each question, read a string "YES" or "NO", as explained in the statement. You can make at most $82$ such questions.
If you want to guess for $x$ , first print the character '!' and then print your guess. After each guess, read ":)" or ":(". If you guess $x$ correctly, the answer is ":)" and your program should terminate immediately, otherwise you'll receive ":(". You can make at most $2$ such guesses.
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.
Hacking is not allowed in this problem.
If you want to guess for $x$ , first print the character '!' and then print your guess. After each guess, read ":)" or ":(". If you guess $x$ correctly, the answer is ":)" and your program should terminate immediately, otherwise you'll receive ":(". You can make at most $2$ such guesses.
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.
Hacking is not allowed in this problem.
输入输出样例
输入 #1
6 NO :( NO :)
输出 #1
? 5 1 2 5 4 3 ! 6 ? 4 1 2 3 4 ! 5
If the answer of the first question were correct, then $x$ would have been equal to $6$ , but as we can see in the first guess, $6$ is not the answer.
So the answer of the first question is joking. As we know, the answer of at least one of our two questions is correct, since the answer of the first question was joking, the answer of the second question should be correct.
So we will understand that $x$ is not equal to $1, 2, 3$ or $4$ , and we also knew that $x$ is not equal to $6$ either. Hence $x$ should be equal to $5$ .
So the answer of the first question is joking. As we know, the answer of at least one of our two questions is correct, since the answer of the first question was joking, the answer of the second question should be correct.
So we will understand that $x$ is not equal to $1, 2, 3$ or $4$ , and we also knew that $x$ is not equal to $6$ either. Hence $x$ should be equal to $5$ .
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted