这套题最后一题不会,然后先放一下,最后一题应该是大数据结构题

A:求连续最长严格递增的的串,O(n)简单dp

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
using namespace std;
typedef long long LL;
const int N = 1e5+;
const int INF = 0x3f3f3f3f;
int n,dp[N],a[N],cnt,mx;
int main(){
scanf("%d",&n);a[]=INF;
for(int i=;i<=n;++i){
scanf("%d",&a[i]);
dp[i]=;
if(a[i]>a[i-])dp[i]=dp[i-]+;
mx=max(mx,dp[i]);
}
printf("%d\n",mx);
return ;
}

B:水题,map乱搞

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <vector>
using namespace std;
typedef long long LL;
const int N = 1e5+;
const int INF = 2e9;
map<int,int>mp;
int a[],cnt;
int main(){
for(int i=;;++i){
if((1ll<<i)>INF)break;
a[++cnt]=(<<i);
}
LL ret=;
int x,n;scanf("%d",&n);
for(int i=;i<=n;++i){
scanf("%d",&x);
for(int j=cnt;j>;--j){
if(a[j]<=x)break;
int tmp=a[j]-x;
if(mp.find(tmp)!=mp.end())
ret+=mp[tmp];
}
if(mp.find(x)==mp.end())mp[x]=;
++mp[x];
}
printf("%I64d\n",ret);
return ;
}

C:一个典型的二分题,judge如何判断全被覆盖?只要用一下离线求和数组非0就好

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <vector>
using namespace std;
typedef long long LL;
const int N = 1e5+;
const int INF = 2e9;
LL a[N],b[N];
int n,m,c[N];
bool judge(LL r){
memset(c,,sizeof(c));
for(int i=;i<=m;++i){
int x=lower_bound(a+,a++n,b[i]-r)-a;
int y=upper_bound(a+,a++n,b[i]+r)-a;
++c[x];--c[y];
}
for(int i=;i<=n;++i){
c[i]+=c[i-];
if(!c[i])return false;
}
return true;
}
int main(){
scanf("%d%d",&n,&m);
for(int i=;i<=n;++i)
scanf("%I64d",&a[i]);
sort(a+,a++n);
n=unique(a+,a++n)-a-;
for(int i=;i<=m;++i)
scanf("%I64d",&b[i]);
sort(b+,b++m);
m=unique(b+,b++m)-b-;
LL l=,r=INF;
while(l<r){
LL mid=(l+r)>>;
if(judge(mid))r=mid;
else l=mid+;
}
printf("%I64d\n",(l+r)>>);
return ;
}

D:一个简单的分类讨论,因为最多走k,以k为周期即可

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <vector>
using namespace std;
typedef long long LL;
const int N = 1e5+;
const int INF = 2e9;
LL d,k,a,b,t;
int main(){
scanf("%I64d%I64d%I64d%I64d%I64d",&d,&k,&a,&b,&t);
if(d<=k){
printf("%I64d\n",d*a);
return ;
}
LL ret=k*a;d-=k;
if(d<=k){
ret+=min(d*a+t,d*b);
printf("%I64d\n",ret);
return ;
}
LL t1=k*a+t,t2=k*b;
if(t2<=t1){
printf("%I64d\n",ret+d*b);
return ;
}
else {
ret+=d/k*t1;
d-=d/k*k;
if(d==){printf("%I64d\n",ret);return ;}
t1=t+d*a,t2=d*b;
ret+=min(t1,t2);
printf("%I64d\n",ret);
}
return ;
}

E:求从每个点出发路径长度为k的边权和以及边权最小值,刚开始还以为是快速幂,结果发现发现这条路唯一确定,直接倍增即可

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <vector>
using namespace std;
typedef long long LL;
const int N = 1e5+;
const int INF = 2e9;
struct Node{
int v,mn;
LL sum;
}f[N][];
LL retsum[N],k;
int n,retmin[N],cur[N];
void solve(){
for(int j=;(1ll<<j)<=k;++j)if(k&(1ll<<j)){
for(int i=;i<n;++i){
retsum[i]+=f[cur[i]][j].sum;
if(retmin[i]==-)retmin[i]=f[cur[i]][j].mn;
else retmin[i]=min(retmin[i],f[cur[i]][j].mn);
cur[i]=f[cur[i]][j].v;
}
}
for(int i=;i<n;++i)
printf("%I64d %d\n",retsum[i],retmin[i]);
}
int main(){
scanf("%d%I64d",&n,&k);
for(int i=;i<n;++i)scanf("%d",&f[i][].v),cur[i]=i,retmin[i]=-;
for(int i=;i<n;++i)scanf("%d",&f[i][].mn),f[i][].sum=f[i][].mn;
for(int j=;(1ll<<j)<=k;++j){
for(int i=;i<n;++i){
f[i][j].v=f[f[i][j-].v][j-].v;
f[i][j].sum=f[i][j-].sum+f[f[i][j-].v][j-].sum;
f[i][j].mn=min(f[i][j-].mn,f[f[i][j-].v][j-].mn);
}
}
solve();
return ;
}

F:不会,看了看别人的代码,并不能看懂,还是太弱

Educational Codeforces Round 15 套题的更多相关文章

  1. Codeforces Educational Codeforces Round 15 D. Road to Post Office

    D. Road to Post Office time limit per test 1 second memory limit per test 256 megabytes input standa ...

  2. Codeforces Educational Codeforces Round 15 C. Cellular Network

    C. Cellular Network time limit per test 3 seconds memory limit per test 256 megabytes input standard ...

  3. Codeforces Educational Codeforces Round 15 A. Maximum Increase

    A. Maximum Increase time limit per test 1 second memory limit per test 256 megabytes input standard ...

  4. Educational Codeforces Round 15 (A - E)

    比赛链接:http://codeforces.com/contest/702 A. Maximum Increase A题求连续最长上升自序列. [暴力题] for一遍,前后比较就行了. #inclu ...

  5. Educational Codeforces Round 27 补题

    题目链接:http://codeforces.com/contest/845 A. Chess Tourney 水题,排序之后判断第n个元素和n+1个元素是不是想等就可以了. #include < ...

  6. cordforce Educational Codeforces Round 47 补题笔记 <未完>

    题目链接 http://codeforces.com/contest/1009 A. Game Shopping 直接模拟即可,用了一个队列来存储账单 #include <iostream> ...

  7. Educational Codeforces Round 15 [111110]

    注意一个词:连续 #include<stdio.h> #include<stdlib.h> #include<string.h> #include<bits/ ...

  8. Educational Codeforces Round 15 C. Cellular Network(二分)

    C. Cellular Network time limit per test 3 seconds memory limit per test 256 megabytes input standard ...

  9. Educational Codeforces Round 15 C 二分

    C. Cellular Network time limit per test 3 seconds memory limit per test 256 megabytes input standard ...

随机推荐

  1. jfinal想用到中大型项目中的项目经验分享

    jfinal 用在大项目中更加方便实用,节省无数的开发时间,代码量相对 SSH 减少 75% 至 90%,对于项目结构来说,简单提以下几点: 1:先分大模块,大模块内部可以根据划分的model分成子包 ...

  2. 由CHAR(2)引发的BUG

    我们在设计数据库标志位字段时,为考虑其扩展性,一般会设置为CHAR(2),例如 FLAG CHAR(2),这样我们就需要注意了,如果你给字段 FLAG赋值为‘0’,它在数据库中的真实情况是‘0+空格’ ...

  3. moto xt800 刷机到2.2.2

    老机器啊,原来2.1的系统大多数软件都不能装sbf刷机包+工具+教程下载地址:http://u.115.com/file/bhdlwl2x 刷完之后如果RSD Lite显示刷机结果为失败,不要担心,手 ...

  4. 李洪强iOS开发之Foundation框架—结构体

    Foundation框架—结构体 一.基本知识 Foundation—基础框架.框架中包含了很多开发中常用的数据类型,如结构体,枚举,类等,是其他ios框架的基础. 如果要想使用foundation框 ...

  5. lintcode 中等题:N Queens II N皇后问题 II

    题目: N皇后问题 II 根据n皇后问题,现在返回n皇后不同的解决方案的数量而不是具体的放置布局. 样例 比如n=4,存在2种解决方案 解题: 和上一题差不多,这里只是求数量,这个题目定义全局变量,递 ...

  6. 《HTTP权威指南》笔记

    http://blog.csdn.net/sunorry?viewmode=contents有些笔记 MIME 类型是一种文本标记,表示一种主要的对象类型和一个特定的子类型,中间由一条斜杠来分隔:te ...

  7. QEvent大全,有中文解释

    简述 QEvent 类是所有事件类的基类,事件对象包含事件参数. Qt 的主事件循环(QCoreApplication::exec())从事件队列中获取本地窗口系统事件,将它们转化为 QEvents, ...

  8. HDU5086——Revenge of Segment Tree(BestCoder Round #16)

    Revenge of Segment Tree Problem DescriptionIn computer science, a segment tree is a tree data struct ...

  9. redhat 安装telnet服务

    系统默认不安装telnet服务的,所有要安装的话,可以加载redhat 光盘.我的操作是在VM上完成的 vm加载系统光盘:设备状态选择已连接,ISO映像文件选择完整的镜像文件路径,例如: D:\sof ...

  10. Java中中文拼音的排序问题

    最近做一个手机数据同步的应用开发,需要提供地址簿信息按照姓名的拼音次序进行排序.但仔细考察Java提供的Collator之后,发现其中文拼音排序存在严重的问题.Java提供Collator来支持不同语 ...