TTTTTTTTTTTTTTTTT Gym 100851J Jump 构造】的更多相关文章

题意:首先你输入一个数字n(偶数)(n<=1000),电脑则自动生成一个长度为n的01字符串,你每次可以构造出一个长度为n的01字符串,输入给电脑后电脑进行判定,如果你的字符串与电脑的字符串完全吻合,电脑返回n,如果只有一半吻合,电脑返回n/2,此外电脑返回0;你最多询问n+500次: #include <iostream> #include <cstdio> #include <cstring> #include <cstdlib> #include…
题意:交互题,有一个长度为n(偶数)的二进制串,你需要猜不超过n+500次猜到它.如果你猜的串与原串相同的位数为n,那么会返回n,如果为n/2,那么会返回n/2,否则都会返回零. 先random,直到出现一个n/2为止,将此串视为a串.由于正态分布,肯定能在500次内查到. 然后枚举a的所有相邻元素,将相邻的元素取反后进行询问,如果返回n/2,说明相邻的这两位有一个是对的,一个是错的:如果返回不是n/2,说明这两位要么都对,要么都错. 于是用2-sat的思想,将每个元素拆点,由于是双向边,所以直…
题意:给定长度为N的01串,现在让你猜这个串,猜的次数要不超过N+500次. 每次你猜一个串,系统会返回N/2,或N,或0.当且当有N/2个位置猜对,N个位置猜对,其他. 思路:因为信息不多,没有关联性,所以前期只有瞎猜,直到猜到一个N/2,(如果是N也ok).猜到N/2之后,我们从这个N/2串考虑,有一半的位置是对的,有一半的位置是错的,那么我们先把第一位取反,后面挨个去取反验证,假设取反第i位,输出N/2,说明第i位和第1位正确性相反,否则相同.那么验证完后,只有两种情况,第一位是对的,第一…
Problem I. Instruction 题目连接: http://codeforces.com/gym/100531/attachments Description Ingrid is a head of a big railway station and, among other duties, is responsible for routing trains to the right platforms. The station has one entrance, and there…
---恢复内容开始--- Monocarp has drawn a tree (an undirected connected acyclic graph) and then has given each vertex an index. All indices are distinct numbers from 11 to nn . For every edge ee of this tree, Monocarp has written two numbers: the maximum ind…
题意:给定一个数字,让你构造成一些表达式,最后结果是该数字的概率要大于50%. 析:我们可以把一个数分解是2的多少次幂,然后加起来就好. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000") #include <cstdio> #include <string> #include <cstdlib> #include <cmath> #include <iostr…
题意:给定一个序列,让你经过不超过9的6次方次操作,变成一个有序的,操作只有在一个连续区间,交换前一半和后一半. 析:这是一个构造题,我们可以对第 i 个位置找 i 在哪,假设 i  在pos 位置,那么如果 (pos-i)*2+i-1 <= n,那么可以操作一次换过来, 如果不行再换一种,如果他们之间元素是偶数,那么交换 i - pos,如果是奇数,交换 i - pos+1,然后再经过一次就可以换到指定位置. 代码如下: #pragma comment(linker, "/STACK:1…
There is a beautiful fence near Monocarp's house. The fence consists of nn planks numbered from left to right. The ii -th plank has color aiai . Monocarp's father have decided to give his son mm orders. Each order is a color cjcj . After each order M…
K. Perpetuum Mobile Time Limit: 2 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100187/problem/K Description The world famous scientist Innokentiy almost finished the creation of perpetuum mobile. Its main part is the energy generator which…
Problem H. Hard TestTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100342/attachments Description Andrew is having a hard time preparing his 239-th contest for Petrozavodsk. This time the solution to the problem is based on Di…