CF1425F.Flamingoes of Mystery
普及/提高-
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
This is an interactive problem. You have to use a flush operation right after printing each line. For example, in C++ you should use the function fflush(stdout), in Java — System.out.flush(), in Pascal — flush(output) and in Python — sys.stdout.flush().
Mr. Chanek wants to buy a flamingo to accompany his chickens on his farm. Before going to the pet shop, Mr. Chanek stops at an animal festival to have fun. It turns out there is a carnival game with a flamingo as the prize.
There are N mysterious cages, which are numbered from 1 to N. Cage i has Ai (0≤Ai≤103) flamingoes inside (1≤i≤N). However, the game master keeps the number of flamingoes inside a secret. To win the flamingo, Mr. Chanek must guess the number of flamingoes in each cage.
Coincidentally, Mr. Chanek has N coins. Each coin can be used to ask once, what is the total number of flamingoes inside cages numbered L to R inclusive? With L<R.
这是一个交互式问题。每次输出一行后,你必须立即执行刷新操作。例如,在 C++ 中应使用函数 fflush(stdout),在 Java 中使用 System.out.flush(),在 Pascal 中使用 flush(output),而在 Python 中使用 sys.stdout.flush()。
Chanek 先生想买一只火烈鸟,来陪伴他农场里的鸡。在前往宠物店之前,Chanek 先生先去参加一场动物节庆活动放松一下。结果发现,现场有一个以火烈鸟为奖品的游园游戏。
共有 N 个神秘笼子,编号从 1 到 N。笼子 i 中有 Ai (0≤Ai≤103) 只火烈鸟 (1≤i≤N)。然而,游戏主持人将每个笼子中的火烈鸟数量严格保密。为了赢得火烈鸟,Chanek 先生必须准确猜出每个笼子中火烈鸟的数量。
巧合的是,Chanek 先生恰好有 N 枚硬币。每枚硬币可使用一次,用于询问编号从 L 到 R(含端点)的所有笼子中火烈鸟的总数。其中要求 L<R。
输入格式
Use standard input to read the responses of your questions.
Initially, the judge will give an integer N (3≤N≤103), the number of cages, and the number of coins Mr. Chanek has.
For each of your questions, the jury will give an integer that denotes the number of flamingoes from cage L to R inclusive.
If your program does not guess the flamingoes or ask other questions, you will get "Wrong Answer". Of course, if your program asks more questions than the allowed number, your program will get "Wrong Answer".
使用标准输入读取你所提问题的回答。
首先,评测系统会给出一个整数 N (3≤N≤103),表示笼子的数量,以及陈先生所拥有的硬币数量。
对于你提出的每个问题,评测系统将返回一个整数,表示从第 L 个笼子到第 R 个笼子(含端点)中火烈鸟的总数。
如果你的程序未能猜出火烈鸟的分布,或提出其他无关问题,你将得到“Wrong Answer”(答案错误)。当然,若你的程序提问次数超过允许的最大次数,也将得到“Wrong Answer”(答案错误)。
输出格式
To ask questions, your program must use standard output.
Then, you can ask at most N questions. Questions are asked in the format "? L R", (1≤L<R≤N).
To guess the flamingoes, print a line that starts with "!" followed by N integers where the i-th integer denotes the number of flamingo in cage i. After answering, your program must terminate or will receive the "idle limit exceeded" verdict. You can only guess the flamingoes once.
要提出问题,你的程序必须使用标准输出。
然后,你最多可以提出 N 个问题。每个问题的格式为 “? L R”,其中 1≤L<R≤N。
要猜测火烈鸟的数量,请输出一行以 “!” 开头的内容,后跟 N 个整数,其中第 i 个整数表示第 i 个笼子中的火烈鸟数量。回答完毕后,你的程序必须终止;否则将收到 “idle limit exceeded”(空闲时间超限)判据。你只能猜测一次火烈鸟的数量。
输入输出样例
输入#1
6 5 15 10
输出#1
? 1 2 ? 5 6 ? 3 4 ! 1 4 4 6 7 8
说明/提示
In the sample input, the correct flamingoes amount is [1,4,4,6,7,8].
在样例输入中,正确的火烈鸟数量为 [1,4,4,6,7,8]。
输入解题思路,AI测评打分。不知道怎么写?