Codeforces Round #435 (Div. 2) D. Mahmoud and Ehab and the binary string
来源:互联网 发布:supreme淘宝正品店 编辑:程序博客网 时间:2024/06/18 08:18
先改第一个位置的看看是1还是0
然后二分区间询问查找另一个数字的位置
#include <iostream>#include <algorithm>#include <sstream>#include <string>#include <queue>#include <cstdio>#include <map>#include <set>#include <utility>#include <stack>#include <cstring>#include <cmath>#include <vector>#include <ctime>#include <bitset>using namespace std;#define pb push_back#define sd(n) scanf("%d",&n)#define sdd(n,m) scanf("%d%d",&n,&m)#define sddd(n,m,k) scanf("%d%d%d",&n,&m,&k)#define sld(n) scanf("%lld",&n)#define sldd(n,m) scanf("%lld%lld",&n,&m)#define slddd(n,m,k) scanf("%lld%lld%lld",&n,&m,&k)#define sf(n) scanf("%lf",&n)#define sff(n,m) scanf("%lf%lf",&n,&m)#define sfff(n,m,k) scanf("%lf%lf%lf",&n,&m,&k)#define ss(str) scanf("%s",str)#define ans() printf("%d",ans)#define ansn() printf("%d\n",ans)#define anss() printf("%d ",ans)#define lans() printf("%lld",ans)#define lanss() printf("%lld ",ans)#define lansn() printf("%lld\n",ans)#define fansn() printf("%.10f\n",ans)#define r0(i,n) for(int i=0;i<(n);++i)#define r1(i,e) for(int i=1;i<=e;++i)#define rn(i,e) for(int i=e;i>=1;--i)#define rsz(i,v) for(int i=0;i<(int)v.size();++i)#define szz(x) ((int)x.size())#define mst(abc,bca) memset(abc,bca,sizeof abc)#define lowbit(a) (a&(-a))#define all(a) a.begin(),a.end()#define pii pair<int,int>#define pli pair<ll,int>#define mp make_pair#define lrt rt<<1#define rrt rt<<1|1#define X first#define Y second#define PI (acos(-1.0))#define sqr(a) ((a)*(a))typedef long long ll;typedef unsigned long long ull;const ll mod = 1000000000+7;const double eps=1e-9;const int inf=0x3f3f3f3f;const ll infl = 10000000000000000;const int maxn= 1000+10;const int maxm = 1000+10;//Pretests passedint in(int &ret){ char c; int sgn ; if(c=getchar(),c==EOF)return -1; while(c!='-'&&(c<'0'||c>'9'))c=getchar(); sgn = (c=='-')?-1:1; ret = (c=='-')?0:(c-'0'); while(c=getchar(),c>='0'&&c<='9')ret = ret*10+(c-'0'); ret *=sgn; return 1;}int a[maxn];int n;int ask(){ printf("? "); r1(i,n)printf("%d",a[i]); puts(""); fflush(stdout); int x; sd(x); return x;}int main(){#ifdef LOCAL freopen("input.txt","r",stdin);// freopen("output.txt","w",stdout);#endif // LOCAL sd(n); int ori = ask(); a[1] = 1; int d1 = ask(); int pos1=0,pos0 = 0; if(d1<ori)pos1=1; else pos0=1; int l = 2,r = n; while(l<r) { int mid = (l+r)>>1; r1(i,n)a[i] = (i<=mid); int d2 = ask(); bool ok = 0; ok|=(pos0==1&&d2<d1+(mid-1)); ok|=(pos1==1&&d2>d1-(mid-1)); if(ok)r=mid; else l=mid+1; } if(pos1)pos0 = l; else pos1= l; printf("! %d %d",pos0,pos1); fflush(stdout); return 0;}
阅读全文
0 0
- Codeforces Round #435 (Div. 2) D. Mahmoud and Ehab and the binary string
- Codeforces Round #435 (Div. 2) 之Mahmoud and Ehab and the MEX
- Codeforces Round #435 (Div. 2) C. Mahmoud and Ehab and the xor
- Codeforces Round #435 (Div. 2) A. Mahmoud and Ehab and the MEX(思路)
- Codeforces Round #435 (Div. 2): C. Mahmoud and Ehab and the xor
- Codeforces Round #435 (Div. 2)-B. Mahmoud and Ehab and the bipartiteness
- Codeforces Round #435 (Div. 2) C. Mahmoud and Ehab and the xor
- Codeforces Round #435 (Div. 2) C. Mahmoud and Ehab and the xor
- Codeforces Round #435 (Div. 2)-Mahmoud and Ehab and the xor(异或)
- Codeforces Round #435 (Div. 2) C. Mahmoud and Ehab and the xor
- Codeforces Round #435 (Div. 2) E. Mahmoud and Ehab and the function
- Codeforces Round #435 (Div. 2) B. Mahmoud and Ehab and the bipartiteness
- Codeforces Round #435 (Div. 2) C. Mahmoud and Ehab and the xor(xor运算应用)
- Codeforces Round #435 (Div. 2) E. Mahmoud and Ehab and the function
- Codeforces Round #435 (Div. 2)B. Mahmoud and Ehab and the bipartiteness(补)
- Codeforces Round #435 (Div. 2)B. Mahmoud and Ehab and the bipartiteness(二分图,染色法)
- Codeforces Round #435 (Div. 2)C. Mahmoud and Ehab and the xor
- Codeforces Round #435 (Div. 2)C. Mahmoud and Ehab and the xor(异或的性质)
- QRegularExpression
- 基于EasyDarwin搭建框架注意事项
- 鼠标事件案例
- js实现页面的打印
- JetBrains公司的产品注册
- Codeforces Round #435 (Div. 2) D. Mahmoud and Ehab and the binary string
- SQL查询的艺术学习笔记--子查询
- AVFrame关于视音频数据存储
- 使用Cobbler批量安装操作系统
- Spring+SpringMVC+MyBatis
- ELF文件格式
- 关于短信发送与HTTP请求的那些事
- Token和session
- 新年的小目标