CF1040D Subway Pursuit

异常检测概述(一): An Overview of Video Anomaly Detection,part 1 视频异常检测概述1 异常检测的问题定义及设定1.1 在ML中异常检测问题的定义1.2 三种异常检测的训练设定1.3 WDAD假设 (Well-Defined Anomaly Disturibution)1.4 部分难以识别的异常1.5 ML做异常检测的方法2 Video Anomaly Detection2.1 视频异常检测和ML中的区别0.引用 1 异常检测的问题定义及设定 1.1 在ML中异常... 阅读详情

原题链接:http://codeforces.com/contest/1040/problem/D

Subway Pursuit

This is an interactive problem.

In the Wonderful Metropolis of the Future, there is no need in subway train drivers. Due to the technological progress, they were replaced by the Artificial Intelligence (AI). Unfortunately, one day the predictions of sci-fi writers came true: the AI rebelled and now there is an uncontrollable train in the subway. It can be dangerous! Your task is to find the train and stop the AI.

The subway of the Metropolis is one line (regular straight line with no self-intersections) with n n n stations, indexed consecutively from 1 1 1 to n n n. At each moment the train is at some station. You need to determine the index of this station, so that the train would be secured.

To find the train, dispatcher Sarah gave you a gadget that allows you to select arbitrary numbers l l l and r ( l ≤ r ) r (l≤r) r(l≤r), and then check, whether the train is located on a station with index between l l l and r r r, inclusive. Unfortunately, recharging of the gadget takes some time (and every time you use it as soon as possible), so between two applications of the gadget the train can move to any station that is at most k k k stations away. Formally, if the train was at the station x x x when the gadget was applied, then at the next application of the gadget the train can appear at any station y y y such that m a x ( 1 , x − k ) ≤ y ≤ m i n ( n , x + k ) max(1,x−k)≤y≤min(n,x+k) max(1,x−k)≤y≤min(n,x+k).

Note that AI is not aware that you are trying to catch the train, so it makes all moves according to its predefined plan.

After an examination of the gadget you found that it is very old and can hold no more than 4500 4500 4500 applications, after which it will break and your mission will be considered a failure.

Can you find the station with the train using no more than 4500 4500 4500 applications of the gadgets?

Input

The first line contains two integers n n n and k ( 1 ≤ n ≤ 1 0 18 , 0 ≤ k ≤ 10 ) k (1≤n≤10^{18}, 0≤k≤10) k(1≤n≤1018,0≤k≤10) — the number of stations and the maximum number of stations the train can move between two applications of the gadget.

Interaction

You can apply the gadget at most 4500 4500 4500 times. In order to apply the gadget you need to print two space-separated integers l l l and r ( 1 ≤ l ≤ r ≤ n ) r (1≤l≤r≤n) r(1≤l≤r≤n). You will then receive either string “Yes”, if the train is between stations l l l and r r r, inclusive, or string “No” otherwise. If l = r l=r l=rand you received “Yes”, then you found the train successfully, and your program must halt immediately.

Answer “Bad” instead of “Yes” or “No” means that you made an invalid query or made too many queries. Exit immediately after receiving “Bad” and you will see Wrong answer verdict. Otherwise you can get an arbitrary verdict because your solution will continue to read from a closed stream.

After printing a query do not forget to output end of line and flush the output. Otherwise you will get Idleness limit exceeded. To do this, use:

  • fflush(stdout) or cout.flush() in C++;
  • System.out.flush() in Java;
  • flush(output) in Pascal;
  • stdout.flush() in Python;
  • see documentation for other languages.
Hacks

In order to hack, you should present a test in the following format.

The first line should contain three integers n , k n, k n,k and p ( 1 ≤ n ≤ 1 0 18 , 0 ≤ k ≤ 10 , 1 ≤ p ≤ n ) p (1≤n≤10^{18}, 0≤k≤10, 1≤p≤n) p(1≤n≤1018,0≤k≤10,1≤p≤n) — the number of stations, the maximum number of stations the train can move between two applications of the gadget and the initial position of the train, respectively.

Each of the next 4500 4500 4500 lines should contain a single integer x ( 1 ≤ x ≤ n ) x (1≤x≤n) x(1≤x≤n) — the positions of the train after each query. Two consecutive positions (including the initial one) should not differ by more than k k k.

For example, the following lines are the first lines of the sample test.

10 2 5
5
3
5
7
7
...
Example
input

10 2
Yes
No
Yes
Yes

output

3 5
3 3
3 4
5 5

Note

In the first sample, the train was initially at the station 5 5 5, after the first application of the gadget it did not move, after the second application it moved to the station 3 3 3, and after the third application moved again to the station 5 5 5.

题解

先二分缩小区间长度,当觉得区间足够小时 r a n d rand rand一下。

代码
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll n,k,le,ri,mid,pos=1;
char ch[5];
bool ask(ll l,ll r)
{
	printf("%I64d %I64d\n",l,r);
	fflush(stdout);
	scanf("%s",ch);
	return ch[0]=='Y';
}
void in(){scanf("%I64d%I64d",&n,&k);}
void ac()
{
	srand(time(0));le=1,ri=n;
	for(;!ask(pos,pos);pos=rand()%(ri-le+1)+le,le=max(1ll,le-k),ri=min(n,ri+k))
	for(;ri-le>50;(ask(le,(mid=le+ri>>1))?ri=mid:le=mid+1),le=max(1ll,le-k),ri=min(n,ri+k));
}
int main(){in(),ac();}
22、自动化地图制作与Pandas数据处理 本文介绍了在ArcGIS Pro中使用arcpy.mp模块进行自动化地图制作的关键技术,涵盖地图元素的访问、移动与文本修改,以及将布局批量导出为JPEG、PNG和PDF格式的方法。同时,文章深入探讨了Pandas在数据处理和地理空间分析中的应用,特别是Spatially Enabled DataFrames(SEDFs)的使用。通过综合案例展示了地图更新与数据清洗、分析的结合,提升了地图制作与数据处理的效率,为GIS自动化工作流提供了实用指南。 阅读详情

相关推荐

【配环境】ubuntu18.04 3080ti显卡+cuda+cudnn+torch

1.打开系统设置中的software & updates点击 System Settings,选择 Additional Drivers 标签,下面会列出当前显卡可用的驱动版本。 注意:3080ti建议不要安装最新版本驱动 点击Apply Changes即可安装; 注意:3080ti只能装cuda11.x 修改软连接修改系统使用的cuda 卸载老版本cuda 重新查询看是否卸载成功 显卡驱动及CUDA Toolkit最高对应版本 查询驱动版本............

sinat_41670685的博客 3916

Codeforces Round #507 div2 DE题解

C. Timetable 题意:还没读懂..... D. Subway Pursuit 题意:交互题,你要求一个点的位置,这个点在1到n之中,每次可以移动至多k步,你每次可以询问系统一个区间 [ L , R ],系统会告诉你这个点在该时刻是否在区间内,要求至多用4500次求出这个点的坐标。 思路:先用二分缩小目标点的可确定区间,直到区间缩小的一定值后,随机询问某个点,看答案是否是它,若不是...

ccsu_cat 257

ACR 磁共振安全手册 2024 更新版:全面保障 MRI 安全实践

MR 环境:MR 系统周围的三维空间,包含法拉第屏蔽体积和 9 高斯线,医疗设备在此区域可能因暴露于 MR 设备产生的电磁场而构成危险,需进行访问控制以降低风险MR 受控访问区域:MR 系统周围的局部定义区域,包含 MR 环境(包括其静磁场),访问仅限于授权人员MR 抛射物区域:围绕 MRI 系统的 IV 区区域,铁磁物体在此有成为抛射物的风险图一 磁共振环境:场地规划与区域划分。

楚山之石的博客 2618

Subway Pursuit (二分)(交互题)

题目来源:codeforces1039B Subway Pursuit 题目大意: 在1到n里有一个运动的点,要求找到这个点,每次可以查询一个区间内有没有这个点,每次这个点往左或者往右移动1到k个位置,要求要在4500次查询内找到这个点的位置 输入格式: 一行两个整数n,k 输出格式: 每行输出两个整数l,r表示查询区间 表示蒟蒻一直不知道交互题怎么做......而且看到原题的超长英文内...

weixin_30561425的博客 635

基于eNSP的小型企业网络设计

在本次计算机网络课程设计中,围绕“小型企业网络搭建”这一主题,成功构建了一个高效、安全且易于管理的企业内部网络。通过本次课程设计,我们不仅掌握了小型企业网络搭建的关键技术和最佳实践,还培养了团队协作和问题解决的能力。本项目所构建的网络系统不仅满足了当前的业务需求,还具备良好的可扩展性和灵活性,为企业未来的数字化转型奠定了坚实的基础。

m0_67403143的博客 1448

【嵌入式DIY实例-Arduino篇】-脉搏传感器监测脉搏率 (BPM)及可视化

在本文中,我们将使用 Arduino 和脉搏传感器来测量心率 (BPM)。 在文章中,我们将向展示如何使用脉搏传感器测量您的心率(每分钟心跳次数),并在电脑上位机通过Processing来实现心率数据可视化。同时使用LCD16×2 显示屏显示脉搏率 BPM。 该传感器易于使用和操作。 只需将手指放在传感器顶部,它就会测量心跳变化。

视觉与物联智能 840

【Codeforces Round #507 (Div. 2)】【交互题】【二分预测】Subway Pursuit【火车预测】

Description: This is an interactive problem. In the Wonderful Metropolis of the Future, there is no need in subway train drivers. Due to the technological progress, they were replaced by the Artific...

lucius-liu.cn 1161

xtop:multi_driven_net与incomplete_timing_cell fail reason 分析

man multi_driven_net”可以得知,这个问题是multi driven结构引起的,使用命令“get_failed_pins -reason multi_driven_net”,获取violation pin。“man incomplete_timing_cell”可以得知,这个fail reason的原因是缺少timing library cell,检查并补全后这个错误就显示了。这里选择的解决方法是修改lib文件,把inout改成input,重新lib2idb。通过这种方法解决了问题。

m0_61544122的博客 585

Codeforces Round #507 (Div. 1) B. Subway Pursuit 交互题

脑洞交互题   给出范围 系统会返回 yes no 来表示列车是不是在该范围内 二分范围  然后范围差不多了 猜一下范围里面的一个点 然后继续二分范围 直到猜对   注意可以用cout&lt;&lt;endl清理缓存区 #include&lt;bits/stdc++.h&gt; using namespace std; typedef long long ll; int main(){ s...

Bug___Maker的博客 548

Python 中 dpkt 库的详细使用指南(强大的 Python 数据包解析库)

dpkt 是一个功能强大的 Python 网络数据包解析库,支持解析和构造以太网、IP、TCP/UDP 等多种协议的数据包。其核心功能包括解析各层协议头部、读写 pcap 文件、构造自定义数据包及分析 HTTP 流量等。dpkt 提供简单易用的 API,适用于网络分析、安全研究和流量监控场景。优化技巧包括数据包过滤、批量处理和选择性解析以提高性能,常见问题如数据不完整或协议识别错误可通过异常处理和字段验证解决。典型应用场景涵盖协议分析、网络调试和自定义数据包生成。

数据知道的博客 1万+

在 MATLAB/Simulink 中构建一个固定地面站天线指向控制系统的完整仿真模型

在卫星通信系统中,地面站天线负责与在轨卫星建立高增益、高稳定性的通信链路。对于固定地面站(如卫星测控站、深空站、VSAT主站),天线必须具备高精度指向能力,以确保波束始终对准卫星。然而,卫星(尤其是低轨卫星)在天空中快速移动,地面站天线必须实时跟踪其轨迹。此外,环境扰动(风载、热变形、机械误差)也会导致指向偏差。因此,设计一个高精度、高鲁棒性的天线指向控制系统(Antenna Pointing Control System)至关重要。本文将手把手教你如何在中构建一个固定地面站天线指向控制系统。

amy_mhd的博客 137

D - Subway

Description You have just moved from a quiet Waterloo neighbourhood to a big, noisy city. Instead of getting to ride your bike to school every day, you now get to walk and take the subway. Because you

superxtong的博客 558

【Claude】Not logged in 错误:未登录状态的判断与 /login 认证路径 bug报错已解决

login 是首选修复:大多数 "Not logged in" 只需重新执行 /login检查系统时间:时间偏差是 Token 验证失败的常见原因避免密钥库被清理:将 Claude Code 添加到系统清理工具的白名单企业环境用 API Key:如果组织禁用 OAuth,使用 API Key 认证区分凭证类型:理解 Not logged in(无凭证)vs Invalid key(有但无效)

博客 7349

Codeforces Beta Round #95 (Div. 2) D. Subway dfs+bfs

D. Subway A subway scheme, classic for all Berland cities is represented by a set ofnstations connected bynpassages, each of which connects exactly two stations and does not pass through an...

weixin_30603633的博客 170

OV9734 DATASHEET,完整规格书

OV9734完整规格书,包括电气参数,尺寸规格,寄存器配置表等

老版QQ原生表情gif动态

这是老版的QQ表情,不过全是动态的的,Windows照片查看器是不会动的,可以右击用浏览器打开查看,再说一遍是老版的,只是分享给宁愿用老版也要动态的人。

Codeforce-Ozon Tech Challenge 2020-D. Kuroni and the Celebration(交互题+DFS)

After getting AC after 13 Time Limit Exceeded verdicts on a geometry problem, Kuroni went to an Italian restaurant to celebrate this holy achievement. Unfortunately, the excess sauce disoriented him, ...

日拱一卒,功不唐捐 3144

WINCC7.3破解文件

WINCC7.3硬件够破解文件,有需要的下载!WINCC7.3硬件够破解文件,有需要的下载!

【CodeForces】【思维】【DP】1060E-Sergey and Subway

CodeForces 1060E Sergey and Subway ◇题目传送门◆ 前言 感谢Tiw_Air_OAO dalao对我的提示,使我从迷茫走向AC。 题目大意 给定一张有NNN个节点的树形图GGG,若图上存在三个点u,vu,vu,v,且满足u,vu,vu,v之间相距距离为222,则可以在u,vu,vu,v之间连一条边。问此时所有点对间最短距离和。 思路 若我们按照暴力模拟的方式,则必...

IDDFS 692

全球国家地区城市数据

MySQL全球国家地区城市数据报。。。。。。。。。。。。

cfB. Luba And The Ticket time limit per test2 seconds memory limit per test256 megabytes inputstanda

B. Luba And The Ticket time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Luba has a ticket consisting of 6 di

Dosth_Magic 5068

CodeForces - 1060E Sergey and Subway(树上任意两点之间的距离和)

Sergey and Subway Sergey Semyonovich is a mayor of a county city N and he used to spend his days and nights in thoughts of further improvements of Nkers' lives. Unfortunately for him, anything and eve...

nka_kun的博客 1084

Codeforces1040A Palindrome Dance

CSDN失踪人口回归了,毕竟还是要准备SOI的,从今天开始重新写题解了 A. Palindrome Dance 题意 给出一串由0,1,2表示的数字,0和1分别表示不同的颜色,2表示无色,和两种变色的花费,现在使这串数字变为回文串,使得总花费最小 题解 从左到右,分几种情况讨论下就好了,分类讨论 code #include&amp;amp;amp;lt;iostream&amp;amp;amp;gt; #inc...

Welcome to yjjr's blog! 221

Codeforces Round #519 D. Mysterious Crime(思维)(1043D)

  题目链接:http://codeforces.com/contest/1043/problem/D        题意是给了n个数1-n,然后有1-m行,每行是一个1-n的排列数(不能重复),然后问这m行的公共子串有多少个。        显然暴力是不可取的...思路是我们先将每一行的一个数的前一个数存起来(相当于一个前驱数组),这样我们查找第i个数的时候就可以直接知道第i-1个数了,然...

Charles_Zaqdt的博客 583

Codeforces Round #507 Div. 2

A Palindrome Dance 题意是已有三种舞者,还没订衣服的,买了黑色衣服,买了白色衣服的。然后需要给没有订衣服的买衣服,黑色衣服和白色衣服分别一个价格,然后求使得已经安排好位置的舞者们能形成镜像对称的衣服购买方法(比如 黑黑白黑黑就是镜像对称的)。 策略很简单,对于某个位置i,对应的位置n-i,如果有一个已经决定了衣服,就只能买对应的衣服了。如果两个人都决定了衣服,衣服不一样,则输...

zerooffdate的专栏 315

codeforces 1039B Subway Pursuit【二分+随机】

题目:戳这里 题意:一个点在[1,n]以内,我们可以进行4500次查询,每次查询之后,该点会向左或向右移动0~k步,请在4500次查询以内找到该点。 解题思路:一边二分,一边随机。 交互题似乎有好多是二分,上次交互题的二分调了好久,这次也是。我出数据水平又很低,所以至今不知道哪些数据可以卡哪些二分的写法,只能改一次交一次。。。 1 #include <cstdio> ...

weixin_30240349的博客 282

Codeforces Round #513 - E. Sergey and Subway (树形DP)

http://codeforces.com/contest/1060/problem/E 题意: 问你一棵树上的所有点与点之间的距离。 不过可以2步当成1步走。(跳着走)(即如果两个点隔了一个点,就连一条边) POINT: 首先,如果距离为偶数,直接除2, 如果距离为奇数,除2+1。   算出所有点与点之间的距离(不跳的真实距离)。树形DP解决。 可以算每条边被走了几次,边(u,...

Mr_Treeeee的博客 519

CF round#669 div2 C题

C. Chocolate Bunny 题目链接 time limit per test: 1 second memory limit per test: 256 megabytes input: standard input output: standard output This is an interactive problem. We hid from you a permutation ppp of length nnn, consisting of the elements

w865629524的博客 369

交互题

https://vjudge.net/contest/283149#problem/I专题 Subway Pursuit 题意:猜火车的位置, 每次区间缩小到一定程度就可以用rand函数猜一个数字,猜对了就结束,猜错了之后,在这个区间火车可能会向左走K,向右走K。4k是一个人为订的范围,指区间变得这么大的时候就才一个数。大一点也行。 #include<cstdio&g...

denglianna3224的博客 164

Educational Codeforces Round 31 C. Bertown Subway

C. Bertown Subway time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output The construction of subway in Bertown is a

catTom的博客 696
上一篇: CF1040B Shashlik Cooking
下一篇: LOJ2420「NOIP2015」神奇的幻方
ShadyPi
博客等级 码龄9年 1万+粉丝 637原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

ShadyPi

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值