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. [转帖]PostgreSQL的用户、角色和权限管理

    PostgreSQL的用户.角色和权限管理 2018年05月18日 14:02:29 jerry-89 阅读数 6143 https://blog.csdn.net/eagle89/article/d ...

  2. 大数据备忘录———将数据从oracle导入impala中

    上周遇到了将数据从oracle导入到impala的问题,这个项目耽误了我近一周的时间,虽然是种种原因导致的,但是还是做个总结. 需求首先是跑数据,跑数据这个就不叙述,用的是公司的平台. 讲讲耽误我最久 ...

  3. Yii源码分享-底层+view层1

    文件:https://files.cnblogs.com/files/cwlife/YII%E7%BB%A7%E6%89%BF%E6%A0%91.xmind.zip 视屏:https://v.qq.c ...

  4. CSS float和position属性

    1. 浮动 CSS float属性定义了元素在水平方向的浮动.该元素从网页的正常流动(文档流)中移除,对于浮动元素后的块级元素,块级元素将会被浮动元素覆盖,并且会接着其上一个文档流中的元素,按文档流的 ...

  5. PB赋值粘贴

    复制:string ls_templs_temp = trim(sle_1.text)Clipboard(ls_temp) 粘贴:string ls_templs_temp = Clipboard() ...

  6. singleWsdl和wsdl区别,Axis2和CXF对比

    WebService是一个SOA(面向服务的编程)的架构,它是不依赖于语言,不依赖于平台,可以实现不同的语言间的相互调用,通过Internet进行基于Http协议的网络应用间的交互. 其实WebSer ...

  7. 弹窗插件 layer

    官方网站 http://layer.layui.com/ Github 地址 https://github.com/sentsin/layer //在这里面输入任何合法的js语句 layer.open ...

  8. linq to xml运用示例

    代码: using System; using System.Collections.Generic; using System.Linq; using System.Web; using Syste ...

  9. fastadmin中关联表时A为主表,想让B表和C表关联时怎么办?

    $sql = Db::connect('数据库')->table('C表')->where('status', 'normal')->field('字段 别称[不可与其他表重复]') ...

  10. 性能测试分析工具nmon文件分析时报错解决办法

    1.使用nmon analyzer V334.xml分析数据时,如果文件过大,可以修改Analyser页签中的INTERVALS的最大值: 2.查找生成的nmon文件中包含的nan,删掉这些数据(需要 ...