[交互 杂题] Codeforces Gym 100307 NEERC 13 I. Interactive Interception
来源:互联网 发布:mysql 表空间大小 编辑:程序博客网 时间:2024/05/01 22:17
如果已知起点 我们可以直接二分速度
现在我们都不知道
那么我们每次查询希望把起点和速度组成的二元组尽量平均的分开
这个要一个二分来找询问那个点
然后询问(0,R)就好了
#include<cstdio>#include<cstdlib>#include<algorithm>#include<string>#include<iostream>using namespace std;typedef long long ll;const int N=100005;int V,P;int l[N],r[N],mid[N];inline ll f(int t,int c){ ll ret=0; for (int i=0;i<=P;i++){ if (l[i]>r[i]) continue; int mv=c-i; if (!t) mv=mv>=0?V:-1; else mv=mv<0?-1:mv/t; mid[i]=mv; ret+=mv>=r[i]?r[i]-l[i]+1:mv-l[i]+1; } return ret;}int main(){ string ret; freopen("t.in","r",stdin); freopen("t.out","w",stdout); cin>>P>>V; for (int i=0;i<=P;i++) l[i]=0,r[i]=V; ll tot=(ll)(V+1)*(P+1); for (int t=0;;t++){ int L=-1,R=P+t*V,MID; while (L+1<R) if (f(t,MID=(L+R)>>1)*2>=tot) R=MID; else L=MID; f(t,R); printf("check 0 %d\n",R); fflush(stdout); cin>>ret; if (ret=="Yes"){ for (int i=0;i<=P;i++) if (mid[i]<r[i]) r[i]=mid[i]; }else{ for (int i=0;i<=P;i++) if (mid[i]+1>l[i]) l[i]=mid[i]+1; } tot=0; for (int i=0;i<=P;i++) if (l[i]<=r[i]) tot+=r[i]-l[i]+1; if (tot<=1) for (int i=0;i<=P;i++) if (l[i]<=r[i]){ printf("answer %d\n",i+(t+1)*l[i]); fflush(stdout); exit(0); } } return 0;}
0 0
- [交互 杂题] Codeforces Gym 100307 NEERC 13 I. Interactive Interception
- [杂题 交互] Codeforces Gym 101190 NEERC 16 I. Indiana Jones and the Uniform Cave
- [字典树 最小树形图] Codeforces Gym 100307 NEERC 13 D. Dictionary
- [三分套三分] Codeforces Gym 100307 NEERC 13 E. Easy Geometry
- [仙人掌同构 Hash] Codeforces Gym 100307 NEERC 13 C. Cactus Automorphisms
- [物理 杂题] Codeforces Gym 101190 NEERC 16 J. Jenga Boom
- [杂题] Codeforces Gym 101190 NEERC 16 K. Kids Designing Kids
- [杂题] Codeforces Gym 101190 NEERC 16 L. List of Primes
- Codeforces Gym 101190 (NEERC 2016) A. Abbreviation
- CodeForces Gym 100735I
- [扫描线 杂题] Codeforces Gym 101190 NEERC 16 E. Expect to Wait
- [博弈论] Codeforces Gym 101190 NEERC 16 G. Game on Graph
- [构造] Codeforces Gym 101190 NEERC 16 C. Cactus Construction
- [构造] Codeforces Gym 100553 NEERC 14 E. Epic Win!
- Codeforces Gym 101190 (NEERC 2016) F. Foreign Postcards (dp + 期望)
- Codeforces Gym 101190 (NEERC 2016) J. Jenga Boom
- Codeforces Gym 101190 NEERC 2016 B. Binary Code
- codeforces Gym 101097 I Sticks
- 聚合果项目ssm经验总结
- 《C++ primer plus》附录G:STL方法与函数(二) 学习笔记
- Leetcode-Array 1
- 对于\和/的小问题:证明路径中可以混合使用斜杠和反斜杠
- php经典算法
- [交互 杂题] Codeforces Gym 100307 NEERC 13 I. Interactive Interception
- proxy
- 努力
- 小白训练Day4
- 扑克牌游戏
- 使用nasm实现Fibonacci数列
- Opencv中traincascade+LBP的训练过程及方法
- 文章标题 Chinese Girls' Amusement
- 升级Jenkins及gerrit trigger 插件