CodeForces 809B Glad to see you!
题解:
交互题一般都是需要用二分去完成。
在二分时候每次检查左边和右边哪边会和答案更近, 然后在更近的那段新区间去重复检查, 知道区间长度为1。
在检查的时候,可以使得答案更近贴近于左边,或者右边。
代码:
#include<bits/stdc++.h>
using namespace std;
#define Fopen freopen("_in.txt","r",stdin); freopen("_out.txt","w",stdout);
#define LL long long
#define ULL unsigned LL
#define fi first
#define se second
#define pb push_back
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define lch(x) tr[x].son[0]
#define rch(x) tr[x].son[1]
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
typedef pair<int,int> pll;
const int inf = 0x3f3f3f3f;
const int _inf = 0xc0c0c0c0;
const LL INF = 0x3f3f3f3f3f3f3f3f;
const LL _INF = 0xc0c0c0c0c0c0c0c0;
const LL mod = (int)1e9+;
const int N = 2e5 + ;
char s[N];
int solve(int l, int r){
while(l != r){
int mid1 = l+r >> ;
int mid2 = mid1 + ;
printf("1 %d %d\n", mid2, mid1);
fflush(stdout);
scanf("%s", s);
if(s[] == 'T') l = mid2;
else r = mid1;
}
return l;
}
int solve2(int l, int r){
while(l != r){
int mid1 = l+r >> ;
int mid2 = mid1+;
if((l+r)% == ){
mid1--;
mid2--;
}
printf("1 %d %d\n", mid1, mid2);
fflush(stdout);
scanf("%s", s);
if(s[] == 'T') r = mid1;
else l = mid2;
}
return l;
}
int main(){
int n, k;
scanf("%d%d", &n, &k);
int p1 = solve(, n);
int p2 = solve2(, p1);
int p3 = solve(p1, n);
int a[] = {p1, p2, p3};
sort(a, a+);
printf("2 %d %d\n", a[], a[]);
fflush(stdout);
return ;
}
CodeForces 809B Glad to see you!的更多相关文章
- 【二分+交互】codeforces B. Glad to see you!
codeforces.com/contest/809/problem/B 只需要找到2个被选中的,首先,注意到将区间二等分时左侧区间为[l,mid],右侧区间为[mid+1,r],dui(mid,mi ...
- Codeforces.810D.Glad to see you!(交互 二分)
题目链接 \(Description\) 有一个大小为\(k\)的集合\(S\),元素两两不同且在\([1,n]\)内.你可以询问不超过\(60\)次,每次询问你给出\(x,y\),交互库会返回\(\ ...
- codeforces 810 D. Glad to see you!(二分+互动的输入方式)
题目链接:http://codeforces.com/contest/810/problem/D 题意:两个人玩一场游戏要猜出Noora选的f种菜的任意两种.一个人猜点另一个人回答 TAK如果 ,(x ...
- Glad to see you! CodeForces - 810D (交互+二分)
This is an interactive problem. In the output section below you will see the information about flush ...
- Codeforces Round#415 Div.2
A. Straight «A» 题面 Noora is a student of one famous high school. It's her final year in school - she ...
- CF 810 D. Glad to see you!
codeforces 810 D. Glad to see you! http://codeforces.com/contest/810/problem/D 题意 大小为k的集合,元素的范围都在[1, ...
- python爬虫学习(5) —— 扒一下codeforces题面
上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...
- 【Codeforces 738D】Sea Battle(贪心)
http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...
- 【Codeforces 738C】Road to Cinema
http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants ...
随机推荐
- Linux升级GCC
升级原因 测试需要使用DOClever,下载了最新的node8.11,运行node 时候报错 [root@app_test bin]# node www module.js:681 return pr ...
- DDMS 视图 Emulator Control 为灰色
Emulator Control 模拟发送短信时,发现所有选项均为灰色,如图所示: 解决方法: 确认以下四种情形或方法 已测试 Genymotion 模拟器和真机均不行,而Eclipse自带模拟器可以 ...
- 【iOS】NSNotification 常用方法
NSNotification 常用的几个方法,代码如下: // 发送通知 [[NSNotificationCenter defaultCenter] postNotificationName:@&qu ...
- Chrome 跨域 disable-web-security 关闭安全策略
谷歌浏览器暂时关闭跨域. 当遇到以下情况,则可以简单的使用 关闭Chrome 安全策略跨域 开发时跨域,上线后,部署在一个域名下没有跨域问题 开发时,临时解决跨域问题 只有开发时用这个,其他时候,就不 ...
- PHP xdebug API接口优化揪出了getimagesize这个鬼
在API优化list中,公司客户系统的服务号客服有个获取聊天消息的接口getHistory请求时间很长,就去优化了下,记下过程. 一,配置环境,追踪使用Xdebug: 1.在https://xdebu ...
- [AI开发]目标检测之素材标注
算力和数据是影响深度学习应用效果的两个关键因素,在算力满足条件的情况下,为了到达更好的效果,我们需要将海量.高质量的素材数据喂给神经网络,训练出高精度的网络模型.吴恩达在深度学习公开课中提到,在算力满 ...
- JavaFX 选择文件 导入Excel文件并解析
FXML 控制器 : @FXML public void selectExcel(MouseEvent event) { FileChooser fileChooser = new FileChoos ...
- macos Mojave 出现网络出错 Frame Check Sequence: Bad checksum
问题描述:使用软电话外呼的时候出现Request Timeout . 端口监听之后通过 Wireshark发现错误:`Frame Check Sequence: Bad checksum`,查看wir ...
- powerdesign进军(二)--oracle数据源配置
目录 资源下载(oracle客户端) 配置 查看系统的数据源 powerdesign 连接数据库 title: powerdesign进军(二)--oracle数据源配置 date: 2019-05- ...
- DedeCMS 5.7 sp1远程文件包含漏洞(CVE-2015-4553)
DedeCMS 5.7 sp1远程文件包含漏洞(CVE-2015-4553) 一.漏洞描述 该漏洞在/install/index.php(index.php.bak)文件中,漏洞起因是$$符号使用不当 ...