PROBLEM C/A. Nephren gives a riddle

  http://codeforces.com/contest/896/problem/A

  codeforces 896a 897c

  预第i个串的长度,由于k最大1e18,所以超过1e18的长度直接标记为无限大,不用计算

  然后递归搜索即可

#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm> using namespace std; typedef long long ll; const ll INF=3e18;
const ll M=1e4+44;
const ll N=1e5+44; char f0[M]={"What are you doing at the end of the world? Are you busy? Will you save us?"};
char s1[M]={"What are you doing while sending \""};
char s2[M]={"\"? Are you busy? Will you send \""};
char s3[M]={"\"?"};
ll lf0,ls1,ls2,ls3;
ll q;
ll len[N]; char solve(ll n,ll k)
{
if(n==0)
return f0[k-1];
if(k<=ls1)
return s1[k-1];
k-=ls1;
if(k<=len[n-1])
return solve(n-1,k);
k-=len[n-1];
if(k<=ls2)
return s2[k-1];
k-=ls2;
if(k<=len[n-1])
return solve(n-1,k);
k-=len[n-1];
return s3[k-1];
} int main()
{
ll n,k;
lf0=strlen(f0);
ls1=strlen(s1);
ls2=strlen(s2);
ls3=strlen(s3);
len[0]=lf0;
for(ll i=1;i<=100000;i++)
len[i]=3e18;
for(ll i=1;i<=100000;i++)
{
len[i]=len[i-1]*2+ls1+ls2+ls3;
if(len[i]>1e18)
break;
}
scanf("%I64d",&q);
while(q--)
{
scanf("%I64d%I64d",&n,&k);
if(k>len[n])
cout<<".";
else cout<<solve(n,k);
}
return 0;
}

  

PROBLEM D/B. Ithea Plays With Chtholly

  http://codeforces.com/contest/896/problem/B

  codeforces 986b 897d

  从第一个位置开始维持一个从左到右不下降的序列,记为左序列;从左右一个位置开始维持一个从右到左不上升的序列,记为右序列

  取中间值midpi=c/2,每次取到一个数,如果这个数小于等于midpi,放入左边的序列,并且维持左序列从左到右不下降;

  如果这个数大于midpi,放入右序列,并且维持右序列从右到左不上升。

  相遇即是成功

  这样最坏情况不超过题目要求

#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cmath> using namespace std; const int M=1e3+44; int n,m,c,num,midpi;
int mp[M];
int s[M],li1,li2,ri1,ri2,flagli,flagri; bool check()
{
// for(int j=1;j<=n;j++)
// cout<<s[j]<<' ';
// cout<<endl;
for(int i=1;i<=n;i++)
if(s[i]==-1)
return false;
for(int i=1;i<n;i++)
if(s[i]>s[i+1])
return false;
// cout<<"true"<<endl;
return true;
} void xf()
{
fflush(stdout);
scanf("%d",&num);
} bool answer(int ans)
{
printf("%d\n",ans);
s[ans]=num;
if(check())
{
fflush(stdout);
return true;
}
else
{
fflush(stdout);
scanf("%d",&num);
return false;
}
} void init()
{
int a,b,pi=0;
a=c/n; b=c%n;
for(int i=1;i<=b;i++)
for(int j=1;j<=a+1;j++)
mp[++pi]=i;
for(int i=b+1;i<=n;i++)
for(int j=1;j<=a;j++)
mp[++pi]=i;
} void solve()
{
// init();
memset(s,-1,sizeof(s));
int flag;
midpi=c/2;
li1=1; li2=n/2; ri1=li2+1; ri2=n;
flagli=flagri=0;
for(int i=1;i<=m;i++)
{
// cout<<"id:"<<i<<endl;
if(num<=midpi)
{
for(int j=li1;j<=ri2;j++)
if(s[j]==-1 || s[j]>num)
if(answer(j))
return ;
else break;
}
else
{
for(int j=ri2;j>=li1;j--)
if(s[j]==-1 || s[j]<num)
if(answer(j))
return ;
else break;
}
}
} int main()
{
scanf("%d%d%d",&n,&m,&c);
xf();
solve();
return 0;
} /* 3 12 7
4
5 */

  

Codeforces Round #449 [ C/A. Nephren gives a riddle ] [ D/B. Ithea Plays With Chtholly ]的更多相关文章

  1. Codeforces Round #449 (Div. 2)

    Codeforces Round #449 (Div. 2) https://codeforces.com/contest/897 A #include<bits/stdc++.h> us ...

  2. Codeforces Round #449 (Div. 2)ABCD

    又掉分了0 0. A. Scarborough Fair time limit per test 2 seconds memory limit per test 256 megabytes input ...

  3. CF&&CC百套计划1 Codeforces Round #449 B. Ithea Plays With Chtholly

    http://codeforces.com/contest/896/problem/B 题意: 交互题 n张卡片填m个1到c之间的数,1<=n*ceil(c/2)<=m 最后填出一个单调非 ...

  4. Codeforces Round #449

    960  asteri 1384     492 00:04 -1 892 01:33     960 PEPElotas 1384     488 00:06 896 00:26       960 ...

  5. CF&&CC百套计划1 Codeforces Round #449 A. Nephren gives a riddle

    http://codeforces.com/contest/896/problem/A 第i个字符串嵌套第i-1个字符串 求第n个字符串的第k个字母 dfs #include<map> # ...

  6. Codeforces Round #449 (Div. 2) C. DFS

    C. Nephren gives a riddle time limit per test 2 seconds memory limit per test 256 megabytes input st ...

  7. Codeforces Round #449 Div. 2 A B C (暂时)

    A. Scarborough Fair 题意 对给定的长度为\(n\)的字符串进行\(m\)次操作,每次将一段区间内的某一个字符替换成另一个字符. 思路 直接模拟 Code #include < ...

  8. Codeforces Round #449 (Div. 2)-897A.Scarborough Fair(字符替换水题) 897B.Chtholly's request(处理前一半) 897C.Nephren gives a riddle(递归)

    A. Scarborough Fair time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  9. CF&&CC百套计划1 Codeforces Round #449 C. Willem, Chtholly and Seniorious (Old Driver Tree)

    http://codeforces.com/problemset/problem/896/C 题意: 对于一个随机序列,执行以下操作: 区间赋值 区间加 区间求第k小 区间求k次幂的和 对于随机序列, ...

随机推荐

  1. DLL导出函数

    使用DEF文件从DLL导出 模块定义(.def)文件时包含一个或多个描述DLL各种属性的Module语句的文本文件.如果不使用_declspec(dllexport)关键字导出DLL的函数,则DLL需 ...

  2. k8s之statefulSet-有状态应用副本集控制器

    1.概述 无状态应用更关注群体,任何一个成员都可以被取代,有状态应用关注的是个体.用deployment控制器管理的nginx.myapp等都属于无状态应用,像mysql.redis.zookeepe ...

  3. tensorflow零起点快速入门(3)

    创造并运行数据 创造了-3到3的32条数据,然后通过sess.run获取并显示输出数据. x=tf.linspace(-3.0,3.0,32) print(x) sess=tf.Session() r ...

  4. MySQL中导入Excel表格中的数据

    在数据库中建立好响应的数据库.表(参考excel表格中列中的名字和内容): 将excel表格另存为txt文件,选择“文本文件(制表符分割)”: 打开相应的txt文件,只留下要导入的数据(windows ...

  5. 转SSL/TLS协议

    TLS名为传输层安全协议(Transport Layer Protocol),这个协议是一套加密的通信协议.它的前身是SSL协议(安全套接层协议,Secure Sockets Layer).这两个协议 ...

  6. 怎样在 Linux 上查看某个端口的相关信息?

    比如 TCP端口 / UDP端口 / 端口占用程序的进程号 等, 这些信息都可以使用: netstat -atunlp | grep 端口号 来进行获取. 比如我们想获取 22 端口的相关信息: 这里 ...

  7. redis的keys常用操作及redis的特性

    redis的keys常用操作 1.获得所有的keys: keys * 2.可以模糊查询 keys:keys  my* 3.删除keys:del mymkey1 mykey2 4.是否存在keys:ex ...

  8. JS-数值转换

    JS数值转换 JS数值转换的方式有4种:Number(),parseInt(),parseFloat(),数据类型*1或者/1. 他们的区别在于: 1.Number():可以将非数值转为数值 如果是B ...

  9. Cesium中的样条插值

    Cesium中的样条插值 在cesium里,提供了三种样条插值方法,LinearSpline,CatmullRomSpline,HermiteSpline.在具体的实例上,可以使用样条插值法利用已知的 ...

  10. Delphi 动态链接库编程

    樊伟胜