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!的更多相关文章

  1. 【二分+交互】codeforces B. Glad to see you!

    codeforces.com/contest/809/problem/B 只需要找到2个被选中的,首先,注意到将区间二等分时左侧区间为[l,mid],右侧区间为[mid+1,r],dui(mid,mi ...

  2. Codeforces.810D.Glad to see you!(交互 二分)

    题目链接 \(Description\) 有一个大小为\(k\)的集合\(S\),元素两两不同且在\([1,n]\)内.你可以询问不超过\(60\)次,每次询问你给出\(x,y\),交互库会返回\(\ ...

  3. codeforces 810 D. Glad to see you!(二分+互动的输入方式)

    题目链接:http://codeforces.com/contest/810/problem/D 题意:两个人玩一场游戏要猜出Noora选的f种菜的任意两种.一个人猜点另一个人回答 TAK如果 ,(x ...

  4. Glad to see you! CodeForces - 810D (交互+二分)

    This is an interactive problem. In the output section below you will see the information about flush ...

  5. 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 ...

  6. CF 810 D. Glad to see you!

    codeforces 810 D. Glad to see you! http://codeforces.com/contest/810/problem/D 题意 大小为k的集合,元素的范围都在[1, ...

  7. python爬虫学习(5) —— 扒一下codeforces题面

    上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...

  8. 【Codeforces 738D】Sea Battle(贪心)

    http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...

  9. 【Codeforces 738C】Road to Cinema

    http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants ...

随机推荐

  1. CEPH 自动化测试用例介绍

    1.QA 的内部逻辑关系. 首先用一个图表示一下QA的内部的逻辑关系. 2.QA的脚本介绍 3.QA脚本运行

  2. 后端基于方法的权限控制--Spirng-Security

    后端基于方法的权限控制--Spirng-Security 默认情况下, Spring Security 并不启用方法级的安全管控. 启用方法级的管控后, 可以针对不同的方法通过注解设置不同的访问条件: ...

  3. form提交的几种方式

    背景 一直使用postman作为restful接口的调试工具,但是针对post方法的几种类型,始终不明白其含义,今天彻底了解了下 form提交的来源 html页面上的form表单 <form a ...

  4. 5月29日 Java性能调优指南 读后感

    并行垃圾收集器 串行垃圾收集器 并发标记清除(CMS)垃圾收集器 Garbage First(G1)垃圾收集器 没有深入的学习G1的原理,只是看了大概的思想; SA工具:待学习

  5. Vsftp服务器配置文件详解

    vsftp软件是我们常见的FTP服务器搭建软件,所有的配置都是基于vsftpd.conf这个配置文件的.vsftpd.conf里面主要包括安全配置,传输,用户还有权限等相关的选项.现在我们讲解下关于V ...

  6. 利用tensorboard可视化checkpoint模型文件参数分布

    写在前面: 上周微调一个文本检测模型seglink,将特征提取层进行冻结,只训练分类回归层,然而查看tensorboard发现里面有histogram显示模型各个参数分布,看了目前这个训练模型参数分布 ...

  7. 普通Apache的安装与卸载

    Apache安装与卸载ctrl+F快捷查找 1.下载apache 64位解压 官网:http://httpd.apache.org/ 文件使用记事本或者sublime2.修改 打开apache目录下的 ...

  8. 自己实现spring核心功能 二

    前言 上一篇我们讲了spring的一些特点并且分析了需要实现哪些功能,已经把准备工作都做完了,这一篇我们开始实现具体功能. 容器加载过程 我们知道,在spring中refesh()方法做了很多初始化的 ...

  9. Java进程故障排查

    故障分析 # 导致系统不可用情况(频率较大): 1)代码中某个位置读取数据量较大,导致系统内存耗尽,进而出现Full GC次数过多,系统缓慢: 2)代码中有比较消耗CPU的操作,导致CPU过高,系统运 ...

  10. MySQL MGR集群单主模式的自动搭建和自动化故障修复

    随着MySQL MGR的版本的升级以及技术成熟,在把MHA拉下神坛之后, MGR越来越成为MySQL高可用的首选方案.MGR的搭建并不算很复杂,但是有一系列手工操作步骤,为了简便MGR的搭建和故障诊断 ...