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次幂的和 对于随机序列, ...
随机推荐
- Java实现二叉树地遍历、求深度和叶子结点的个数
一.分析 二叉树是n个结点所构成的集合,它或为空树,或为非空树.对于非空树,它有且仅有一个根结点,且除根结点以外的其余结点分为两个互不相交的子集,分别称为左子树和右子树,它们本身又都是二叉树. 显而易 ...
- 作业8:常用java命令(二)
一.jinfo(Configuration Info for Java) 1.功能:jinfo可以实时地查看和调整虚拟机的各项参数. 2.参数: 选项 作用 -flag name 打印改名字的VM设置 ...
- CSS——font使用方法
<style> p{ /*font-style: italic;/*设置字体为斜体*/ font-variant: small-caps; font-weight: bolder;/*设置 ...
- (转载)项目中表、类、包、JSP命名规范
对于Java(包括在jsp中)的代码,类名一律用pascal标记法,每个单词的头个字母大写:参数,方法一律用camel标记法,首字母是小写的,能不缩写的都不缩写! 项目名 = 数据库名 ...
- json返回数据多个是数组,单个就不是处理方案
/// <summary> /// 计算方案 当前返回的对象 /// </summary> [JsonConverter(ty ...
- MVC4学习要点记一
强类型的辅助方法:这些helper的特征是名称后面加上了 For , 这些叫做强类型的辅助方法. 共用布局页:可以在Views文件夹下面新建一个视图页,命名为_ViewStart.cshtml,将这部 ...
- base64编码处理大文件
在做项目的时候遇到需要将文件转为base64编码,并存储在文件中. 在将文件转为base64编码是会将文件读入内存,进行base64编码,输出到文件中.代码入下: FileInputStream st ...
- Plugin 表格列自定义显示隐藏插件TableCustom.js
TableCustom 案例展示 下载地址 https://github.com/chaorenzeng/TableCustom.js.git 快速使用 1.引入TableCustom.css和Tab ...
- js之语句(表达式语句,复合语句,声明语句)
语句就是JavaScript整句或命令,以分号结束,用来执行以使某件事发生.下面将介绍三种语句:表达式语句,复合语句,声明语句. 一.表达式语句 表达式语句是javascript中最简单的语句 < ...
- 销售订单(SO)-API-登记销售订单
登记销售订单可以在新增订单的时候就登记:并不是去修改 flow_status 为booked,而是赋值action request:就下面两句 l_action_request_tbl(l_actio ...