http://codeforces.com/contest/862/problem/D

交互题

fflush(stdout)

调试:

先行给出结果,函数代替输入

 #include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <time.h>
#include <string>
#include <set>
#include <map>
#include <list>
#include <stack>
#include <queue>
#include <vector>
#include <bitset>
#include <ext/rope>
#include <algorithm>
#include <iostream>
using namespace std;
#define ll long long
#define minv 1e-6
#define inf 1e9
#define pi 3.1415926536
#define E 2.7182818284
const ll mod=1e9+;//
const int maxn=1e3+; char str[maxn];
int pos[],s,t,len=inf,x,y;
char result[maxn]="01\0";
int nn=; int cal()
{
int i,v=;
for (i=;i<=nn;i++)
if (str[i]!=result[i-])
v++;
return v;
} //'l'-'r' must have num
void work(int l,int r,int num)
{
if (l==r)
{
pos[num]=l;
return;
} int i,m=(l+r)>>;
for (i=l;i<=m;i++)
str[i]=((str[i]-) ^ )+;
printf("? %s\n",str+);
fflush(stdout);
scanf("%d",&x);
// x=cal(); for (i=l;i<=m;i++)
str[i]=((str[i]-) ^ )+; if (y-x==m-l+)
{
pos[num]=l;
return;
}
else
{
if (m-l+<len)
{
len=m-l+;
s=l;
t=m;
}
} if (x-y!=m-l+)
work(l,m,num);
else
work(m+,r,num);
} int main()
{
int n,i;
scanf("%d",&n); for (i=;i<=n;i++)
str[i]='';
str[n+]='\0';
printf("? %s\n",str+);
fflush(stdout);
scanf("%d",&y);
// y=cal();
work(,n,); if (len>)
{
for (i=;i<=n;i++)
str[i]='';
str[n+]='\0';
printf("? %s\n",str+);
fflush(stdout);
scanf("%d",&y);
// y=cal();
if (len==inf)
s=,t=n;
work(s,t,);
} printf("! %d %d",pos[],pos[]);
return ;
}

D. Mahmoud and Ehab and the binary string Codeforces Round #435 (Div. 2)的更多相关文章

  1. Codeforces 862D. Mahmoud and Ehab and the binary string (二分)

    题目链接:Mahmoud and Ehab and the binary string 题意: 一道交互题,首先给出一个字符串的长度l.现在让你进行提问(最多15次),每次提问提出一个字符串,会返回这 ...

  2. codeforces D. Mahmoud and Ehab and the binary string(二分)

    题目链接:http://codeforces.com/contest/862/submission/30696399 题解:这题一看操作数就知道是二分答案了.然后就是怎么个二分法,有两种思路第一种是找 ...

  3. Codeforces 862D. Mahmoud and Ehab and the binary string 【二分】(交互)

    <题目链接> 题目大意: 有一个长度为n(n<1000)的01串,该串中至少有一个0和一个1,现在由你构造出一些01串,进行询问,然后系统会给出你构造的串与原串的   Hamming ...

  4. Codeforces.862D.Mahmoud and Ehab and the binary string(交互 二分)

    题目链接 \(Description\) 有一个长为\(n\)的二进制串,保证\(01\)都存在.你可以询问不超过\(15\)次,每次询问你给出一个长为\(n\)的二进制串,交互库会返回你的串和目标串 ...

  5. 【二分】Codeforces Round #435 (Div. 2) D. Mahmoud and Ehab and the binary string

    题意:交互题:存在一个至少有一个0和一个1的长度为n的二进制串,你可以进行最多15次询问,每次给出一个长度为n的二进制串,系统返回你此串和原串的海明距离(两串不同的位数).最后要你找到任意一个0的位置 ...

  6. E. Mahmoud and Ehab and the function Codeforces Round #435 (Div. 2)

    http://codeforces.com/contest/862/problem/E 二分答案 一个数与数组中的哪个数最接近: 先对数组中的数排序,然后lower_bound #include &l ...

  7. 【构造】【分类讨论】Codeforces Round #435 (Div. 2) C. Mahmoud and Ehab and the xor

    题意:给你n,x,均不超过10^5,让你构造一个无重复元素的n个元素的非负整数集合(每个元素不超过10^6),使得它们的Xor和恰好为x. 如果x不为0: 随便在x里面找一个非零位,然后固定该位为0, ...

  8. 【Codeforces Round #435 (Div. 2) A】Mahmoud and Ehab and the MEX

    [链接]h在这里写链接 [题意] 在这里写题意 [题解] 让x没有出现,以及0..x-1都出现就可以了. [错的次数] 0 [反思] 在这了写反思 [代码] #include <bits/std ...

  9. 【Codeforces Round #435 (Div. 2) B】Mahmoud and Ehab and the bipartiteness

    [链接]h在这里写链接 [题意] 让你在一棵树上,加入尽可能多的边. 使得这棵树依然是一张二分图. [题解] 让每个节点的度数,都变成二分图的对方集合中的点的个数就好. [错的次数] 0 [反思] 在 ...

随机推荐

  1. VGG——Very deep convolutional networks for large-scale image recognition

    1. 摘要 在使用非常小(3×3)的卷积核情况下,作者对逐渐增加网络的深度进行了全面的评估,通过设置网络层数达 16-19 层,最终效果取得了显著提升. 2. 介绍 近来,卷积神经网络在大规模图像识别 ...

  2. linux磁盘扩容日志

    //针对ext4文件格式的操作系统(如CentOS6):// umount /dev/vdb e2fsck -f /dev/vdb resize2fs /dev/vdb mount /dev/vdb ...

  3. OGG 问题

    1.启动复制时报 "ERROR OGG-15050 Oracle GoldenGate Delivery, l***.prm: Error loading Java VM runtime l ...

  4. PSP Daily软件beta版本——基于NABCD评论,及改进建议

    1.根据(不限于)NABCD评论作品的选题: 此软件的用户人群较为明确,即:用户(软件工程课上学生)记录例行报告.写每周PSP表格和统计的需求.潜在用户还有未来该课堂的学生和需要用PSP方法记录任务完 ...

  5. “Hello World!”团队第五周第七次会议

    博客内容: 一.会议时间 二.会议地点 三.会议成员 四.会议内容 五.todo list 六.会议照片 七.燃尽图 八.checkout&push代码 一.会议时间 2017年11月16日  ...

  6. 第33次Scrum会议(11/21)【欢迎来怼】

    一.小组信息 队名:欢迎来怼小组成员队长:田继平成员:李圆圆,葛美义,王伟东,姜珊,邵朔,阚博文 小组照片 二.开会信息 时间:2017/11/21 11:35~11:57,总计22min.地点:东北 ...

  7. mybatis之insert语句报错Cause: java.sql.SQLException: sql injection violation, syntax error: ERROR. token : WHERE,

    报错日志:org.springframework.jdbc.UncategorizedSQLException: Error updating database. Cause: java.sql.SQ ...

  8. 读取.properties配置文件并保存到另一个.properties文件内

    代码如下 import java.io.BufferedInputStream; import java.io.FileInputStream; import java.io.FileOutputSt ...

  9. Daily Scrum (2015/10/21)

    今天可以说是项目正式开始的第一天,由于大家缺乏做团队项目的经验,对TFS的使用都还不太熟悉,所以今天大家的主要工作是熟悉TFS的使用和对代码进行初步的理解.我们预计需要2-3天时间来理解透彻源代码.以 ...

  10. 【Alpha发布】贡献分分配

    最后贡献分分配: (1211)王嘉豪:32 (1186)黄雨萌:36 (1182)佘彦廷:40 (1208)何小松:50 (1200)鲁聃:62 (1174)邢浩:64 (1193)刘乾:66