Codeforces Round #449 [ C/A. Nephren gives a riddle ] [ D/B. Ithea Plays With Chtholly ]
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 ]的更多相关文章
- Codeforces Round #449 (Div. 2)
Codeforces Round #449 (Div. 2) https://codeforces.com/contest/897 A #include<bits/stdc++.h> us ...
- Codeforces Round #449 (Div. 2)ABCD
又掉分了0 0. A. Scarborough Fair time limit per test 2 seconds memory limit per test 256 megabytes input ...
- 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 最后填出一个单调非 ...
- Codeforces Round #449
960 asteri 1384 492 00:04 -1 892 01:33 960 PEPElotas 1384 488 00:06 896 00:26 960 ...
- 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> # ...
- 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 ...
- Codeforces Round #449 Div. 2 A B C (暂时)
A. Scarborough Fair 题意 对给定的长度为\(n\)的字符串进行\(m\)次操作,每次将一段区间内的某一个字符替换成另一个字符. 思路 直接模拟 Code #include < ...
- 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 ...
- CF&&CC百套计划1 Codeforces Round #449 C. Willem, Chtholly and Seniorious (Old Driver Tree)
http://codeforces.com/problemset/problem/896/C 题意: 对于一个随机序列,执行以下操作: 区间赋值 区间加 区间求第k小 区间求k次幂的和 对于随机序列, ...
随机推荐
- 小a的强迫症 题解
题面: 小a是一名强迫症患者,现在他要给一群带颜色的珠子排成一列,现在有N种颜色,其中第i种颜色的柱子有num(i)个.要求排列中第i种颜色珠子的最后一个珠子,一定要排在第i+1种颜色的最后一个珠子之 ...
- id和class的区别
id和class是定义css样式用到的,不同的是定义样式时的写法不一样,使用id选择样式时,定义的格式为 #main{width:20px;} ,使用class时用到的是 .main{width:20 ...
- [转载]VS2005的工程用VS2010打开后,用VS2005不能打开的解决方法
首先,在“项目”菜单里,把项目属性“目标平台”改为框架2.0,保存退出. 然后,用记事本或用编辑文本文件的方式打开你的项目文件,后缀为.sln 第一行:把“Microsoft Visual Studi ...
- jmeter压测实践
技巧一:命令行执行 命令执行:指定参数,报告的存储位置 jmeter -n -t baidu_requests_results.jmx -r -l baidu_requests_results.jtl ...
- iframe标签(页面嵌套)
本文链接:https://blog.csdn.net/weixin_44540236/article/details/92760494 两个不同的页面但是它们的基本框架都是一样,每点击一次左边的导航栏 ...
- IntelliJ IDEA(Community版本)本地模式的下载、安装及其使用
对于初学者来说可以先使用免费的社区版本练练手. ideaIC-2017.3.5——>社区版 ideaIU-2017.3.5——>旗舰版 一.IntelliJ IDEA(Community版 ...
- Python中文分词组件 jieba
jieba "结巴"中文分词:做最好的Python中文分词组件 "Jieba" Feature 支持三种分词模式: 精确模式,试图将句子最精确地切开,适合文本分 ...
- multiple类型的select option在django后台如何取值
之前前端的select都是单选类型,在新的场景中允许用户选择多个条件, 前端的代码如下: <form action="{% url 'info:result-list' %}" ...
- jvm监控工具jconsole进行远程监控配置
[环境] SUSE linux11 + jdk1.6 + tomcat7 [场景] 最近在做性能测试,想通过我本地(win7)上的jdk来远程监控上述服务器的jvm相关信息. [配置] 配置上述服务器 ...
- Oracle笔记(七) 数据更新、事务处理、数据伪列
一.数据的更新操作 DML操作语法之中,除了查询之外还有数据的库的更新操作,数据的更新操作主要指的是:增加.修改.删除数据,但是考虑到emp表以后还要继续使用,所以下面先将emp表复制一份,输入如下指 ...