随便瞎写,其实没做出多少题:

Chef and Cake

题目大概是用输入的数生成 一个数组并且生成出q个【X,Y】的询问,

数组长度N<=1000000,q<=10^7;

开始用线段树,RMQ,分块能切过去,但是线段树RE,RMQ re ,分块最多40分。

但是一直忽视了区间询问的[X Y]  K<=Y-X+1<=2K; K是给定的数。

然后是利用一些思想。

比如 我们每次求出DP【X】    ----------> 表示 I  in【X,X+K-1] 范围 min(A[i]);A[i] 生成的数组。

询问X,Y的区间最小值 =Mi年(dp[x],dp[y-k+1]);

求出每个dp;

这里利用单调队列,熟悉的应该比较简单。

 #include<cstdio>
#include<algorithm>
#include<cmath>
#include<string.h>
#include<string>
#include<iostream>
#include<vector>
#include<map>
#include<deque>
#include<vector> #define inf 0x3f3f3f
#define N 10000105
#define mod 1000000007 using namespace std;
typedef long long ll;
int a,b,c,d,e,f,g,r,s,t,m,n,k,q;
int L1,La,Lc,Lm,D1,Da,Dc,Dm; ll A[N];
int L[N],R[N]; void work()//生成数据部分
{
ll tmp=t;
for (int x=;x<=n;x++)
{
tmp=tmp*t%s;
if (tmp<=r) A[x]=(A[x-]*A[x-]%m*a+A[x-]*b%m+c)%m;
else A[x]=(A[x-]*A[x-]%m*d+A[x-]*e%m+f)%m;
} for (int i=;i<=q;i++)
{
/* L1=(ll) ((ll)La*L1+Lc)%Lm;
D1=(ll) ((ll)Da*D1+Dc)%Dm;
生成数据有问题,注意La为int La*L1溢出
*/
L1=(ll) ((ll)La*L1+Lc)%Lm;
D1=(ll) ((ll)Da*D1+Dc)%Dm;
L[i]=L1+;
R[i]=min(L[i]+k-+D1,n);
}
} int minarr[N];
int ff[N]; void work2()
{
int i,j,h,t;
h=,t=;//维护一个长度为k的单调递增队列 for (i=;i<=k;i++)
{
while (h<t&&A[i]<=A[ff[t-]]) t--;
ff[t++]=i;
}
j=;
for (;i<=n;i++,j++)
{
minarr[j]=A[ff[h]];
while (h<t&&ff[h]<=i-k) h++;
while (h<t&&A[i]<=A[ff[t-]]) t--;
ff[t++]=i;
}
minarr[j]=A[ff[h]];
} void debug()//debug部分
{
for (int i=;i<=n;i++)
cout<<A[i]<<" ";
cout<<endl;
for (int i=;i<=n-k+;i++)
cout<<minarr[i]<<" ";
cout<<endl;
} int main()
{
while (scanf("%d%d%d",&n,&k,&q)!=EOF){
scanf("%d%d%d%d%d%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f,&r,&s,&t,&m,&A[]);
scanf("%d%d%d%d%d%d%d%d",&L1,&La,&Lc,&Lm,&D1,&Da,&Dc,&Dm);
work();
work2();
// debug(); ll ans1,ans2;
ans1=;
ans2=; for (int i=;i<=q;i++)
{
int tmp=min(minarr[L[i]],minarr[R[i]-k+]);
ans1+=tmp;
ans2=ans2*tmp%mod;
}
printf("%lld %lld\n",ans1,ans2);
}
return ;
}

Devu and binary String

也是很有意思的题目:

大意是:给一个01串,我们可以对每个0 1 翻转,使0->1,1->0.

然后问:用最少的翻转次数,是字符串里面没有连续k字符是一样的。

长标题:开始贪心思路是每连续k个一样就 把最后一个翻转,但是会有问题。

当我们可能反转最后一个使的接下来K-1个和 翻转的一个有成为一样的,显然这样并不是最优的

我们可以把前K个中倒数第二个翻转,结果就更优,基于这种贪心思路,这题可以这么做。

然后注意一下K=1的特判。

Codechef May Challenge 2015的更多相关文章

  1. 大规模视觉识别挑战赛ILSVRC2015各团队结果和方法 Large Scale Visual Recognition Challenge 2015

    Large Scale Visual Recognition Challenge 2015 (ILSVRC2015) Legend: Yellow background = winner in thi ...

  2. Codechef April Challenge 2019 游记

    Codechef April Challenge 2019 游记 Subtree Removal 题目大意: 一棵\(n(n\le10^5)\)个结点的有根树,每个结点有一个权值\(w_i(|w_i\ ...

  3. Codechef October Challenge 2018 游记

    Codechef October Challenge 2018 游记 CHSERVE - Chef and Serves 题目大意: 乒乓球比赛中,双方每累计得两分就会交换一次发球权. 不过,大厨和小 ...

  4. Codechef September Challenge 2018 游记

    Codechef September Challenge 2018 游记 Magician versus Chef 题目大意: 有一排\(n(n\le10^5)\)个格子,一开始硬币在第\(x\)个格 ...

  5. 「Codechef April Lunchtime 2015」Palindromeness

    「Codechef April Lunchtime 2015」Palindromeness 解题思路 : 考虑对于回文子串 \(s\) 贡献的定义: \[ value_s = [\ s[1,\lflo ...

  6. codechef February Challenge 2018 简要题解

    比赛链接:https://www.codechef.com/FEB18,题面和提交记录是公开的,这里就不再贴了 Chef And His Characters 模拟题 Chef And The Pat ...

  7. RecSys Challenge 2015

    [The Task] Given a sequence of click events performed by some user during a typical session in an e- ...

  8. codechef January Challenge 2014 Sereja and Graph

    题目链接:http://www.codechef.com/JAN14/problems/SEAGRP [题意] 给n个点,m条边的无向图,判断是否有一种删边方案使得每个点的度恰好为1. [分析] 从结 ...

  9. Codechef March Challenge 2014——The Street

    The Street Problem Code: STREETTA https://www.codechef.com/problems/STREETTA Submit Tweet All submis ...

随机推荐

  1. 洛谷 P2319 [HNOI2006]超级英雄

    题目描述 题目描述 现在电视台有一种节目叫做超级英雄,大概的流程就是每位选手到台上回答主持人的几个问题,然后根据回答问题的多少获得不同数目的奖品或奖金.主持人问题准备了若干道题目,只有当选手正确回答一 ...

  2. web测试需要注意点

  3. 20道必须掌握的C++面试题

    20道必须掌握的C++面试题 在面试C++方面的工作时,经常会遇到各种面试题,这对应聘人员的知识掌握能力要求较高.本文将为大家带来的就是20道必须掌握的C++面试题,不要错过哦! 问1:请用简单的语言 ...

  4. Low Speed High Torque Hydraulic Motor: Motion Performance

    Crank connecting rod type low speed high torque hydraulic motor is used earlier, which is called Sta ...

  5. 异常:java.lang.NoClassDefFoundError: org/springframework/expression/ParserContext

    异常:java.lang.NoClassDefFoundError: org/springframework/expression/ParserContext 解决方案:缺少spring-expres ...

  6. android 图片

    1,setCompoundDrawables(Drawable left, Drawable top,Drawable right, Drawable bottom) 设置图片出现在textView, ...

  7. js检测对象是否是数组

    js检测对象是否是数组 可以通过instanceof 方法一. var arr=[] arr instanceof Array   //true var obj={} obj instanceof A ...

  8. ubuntu中执行docker info出现警告信息WARNING: No memory limit support 或 WARNING: No swap limit support

    docker info 指令报若下错误:WARNING: No memory limit support 或WARNING: No swap limit support 解决方法: 1.打开/etc/ ...

  9. (2) OpenSSL命令

    openssl命令的格式是"openssl command command-options args",command部分有很多种命令,这些命令需要依赖于openssl命令才能执行 ...

  10. docker-compose文件语法解析(v3.x)

    文件配置 compose文件是一个定义服务(service).网络(network)和卷(volume)的YAML文件 .Compose 文件的默认路径是 ./docker-compose.yml 提 ...