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

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. String类的使用 Part1

    String类的属性 1:Chars属性 获取当前 String 对象中位于指定位置的 Char 对象. 2:Length属性 获取当前 String 对象中的字符数. eg:获取字符串中  字母, ...

  2. FileOutputStream和FileInputStream

    package one.string; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFound ...

  3. Java中Integer的源码学习

      一.开始 public final class Integer extends Number implements Comparable<Integer> 1).由于类修饰符中有关键字 ...

  4. Lambda 表达式型的排序法

    int[] arry = {3,9,5,7,64,51,35,94 }; foreach (int i in arry.OrderBy(i => i)) Console.WriteLine(i) ...

  5. 89. Gray Code

    题目: The gray code is a binary numeral system where two successive values differ in only one bit. Giv ...

  6. office开发心得——基于模板开发

    这几天正在写一个小程序,但用到生成word表格和Excel表格.到网上查了一些资料,发现如果生成表格模板相对比较固定即可把其制作成模板,需要设置什么格式可以直接在模板中设置,而程序仅需替换相应的内容即 ...

  7. 【c++】中文设置

    #include <iostream> #include <string> #include<locale> using namespace std; ; int ...

  8. 量化生产力Quantifying Productivity

    I'm always on a lookout for interesting datasets to collect, analyze and interpret. And what better ...

  9. 经典K线组合图解 > 正文

    日K线波段中上下影线的箱体操作法(完整) http://video.sina.com.cn/v/b/130809461-2486130757.html!!经典K线组合图解 > 正文 http:/ ...

  10. Collection_Compare

    冒泡 package com.bjsxt.sort.bubble; import java.util.Arrays; public class BubbleSort1 { /** * @param a ...