【昨晚打校赛,5个小时打完很累了,所以搞忘出题了。。。对不起学弟们,不过出的题都亲自写过一遍,可以保证题目和代码长度都不长,题目难度不大】

【A:bush博弈】

#include<bits/stdc++.h>
using namespace std;
int main()
{
int T,N,K;
scanf("%d",&T);
while(T--){
scanf("%d%d",&N,&K);
if(N%(K+)==) puts("B");
else puts("A");
}
return ;
}

【B:DP求最长公共子序列,可以反推前缀】

#include<bits/stdc++.h>
using namespace std;
const int maxn=;
char a[maxn],b[maxn],ans[maxn];
int dp[maxn][maxn];
int main()
{
int L1,L2,i,j,k;
scanf("%s%s",a+,b+);
L1=strlen(a+); L2=strlen(b+);
for(i=;i<=L1;i++)
for(j=;j<=L2;j++){
dp[i][j]=max(dp[i-][j],dp[i][j-]);
if(a[i]==b[j]) dp[i][j]=max(dp[i][j],dp[i-][j-]+);
}
i=L1;j=L2;k=;
while(i>=&&j>=){
if(a[i]==b[j]) ans[++k]=a[i],i--,j--;
else if(dp[i-][j]>=dp[i][j-]) i--;
else j--;
}
for(i=k;i>=;i--) cout<<ans[i];
return ;
}

【C:nlogn的算法求最长递增子序列】

#include<bits/stdc++.h>
using namespace std;
const int maxn=;
int a[maxn];
int main()
{
int N,x,i,L=,pos=;
scanf("%d",&N);
for(i=;i<=N;i++){
scanf("%d",&x);
pos=upper_bound(a+,a+L+,x)-a;
a[pos]=x;
L=max(L,pos);
}
cout<<L<<endl;
return ;
}

【D:简单处理矩阵:求最大的区间全是1】:问题转化为枚举上下边界,然后连续的一块算。

#include<bits/stdc++.h>
using namespace std;
const int maxn=;
int a[maxn][maxn],sum[maxn][maxn];
int main()
{
int N,M,i,j,k,ans=;
scanf("%d%d",&N,&M);
for(i=;i<=N;i++)
for(j=;j<=M;j++){
scanf("%d",&a[i][j]);
sum[i][j]=sum[i-][j]+a[i][j];
}
for(i=;i<=N;i++)
for(j=i;j<=N;j++){
int L=;
for(k=;k<=M;k++)
if(sum[j][k]-sum[i-][k]==j-i+){ L++;ans=max(ans,(j-i+)*L);}
else L=;
}
printf("%d\n",ans);
return ;
}

【E:区间DP求最长回文,更优的算法有manecher等】

#include<bits/stdc++.h>
using namespace std;
const int maxn=;
char c[maxn];
int dp[maxn][maxn];
int main()
{
int L,i,j,ans=;
scanf("%s",c+);
L=strlen(c+);
for(i=L;i>=;i--){
for(j=i;j<=L;j++){
if(j-i+==) dp[i][j]=;
else if(j-i+==) dp[i][j]=(c[i]==c[j]?:);
else if(dp[i+][j-]!=&&c[i]==c[j]) dp[i][j]=dp[i+][j-]+;
ans=max(ans,dp[i][j]);
}
}
printf("%d\n",ans);
return ;
}

【CQ18高一暑假前挑战赛2】标程的更多相关文章

  1. 【CQ18高一暑假前挑战赛5】标程

    [A:暴力] #include<bits/stdc++.h> using namespace std; ; int a[maxn],vis[maxn],N,M; int main() { ...

  2. 【CQ18高一暑假前挑战赛4】标程

    [二分或者STL] 二分: #include<bits/stdc++.h> using namespace std; ; int a[maxn]; int main() { ,pos; s ...

  3. 【CQ18高一暑假前挑战赛3.5】标程

    [A:快速幂相关] #include<bits/stdc++.h> using namespace std; int qpow(int a,int x){ a%=;; while(x){ ...

  4. 【CQ18高一暑假前挑战赛3】标程

    [A:LCM] #include<bits/stdc++.h> using namespace std; #define ll long long int main() { ll a,b, ...

  5. 【CQ18高一暑假前挑战赛1】标程

    [A] #include<bits/stdc++.h> using namespace std; #define ll long long ll qpow(ll a,ll x,ll Mod ...

  6. [转]关于一些SPFA的标程

    SPFA算法 求单源最短路的SPFA算法的全称是:Shortest Path Faster Algorithm. 最短路径快速算法-SPFA算法是西南交通大学段凡丁于1994年发表的. 适用范围:给定 ...

  7. [求助][SPOJ MARIOGAM]-高斯消元(内含标程,数据等)

    小蒟蒻开始做概率的题之后,遇到了这道题,然而,他发现自己的程序调试了无数次也无法通过,系统总是返回令人伤心的WA, 于是,他决定把这一天半的时间收集到的资料放在网上, 寻求大家的帮助, 也可以节省后来 ...

  8. hdu6435 Problem J. CSGO标程讲解以及改正标程的一个错误(本来第一个样例过不了2333) 以及 poj2926 五维曼哈顿距离模板

    比赛的时候抄poj2926的模板,但改不来啊orz #include <iostream> #include <cstdio> #include <cstring> ...

  9. 暑假前的flag

    暑假到了,为了简便新开了一个博客,供暑假刷体放一些题解,玩acm1年多了,cf还是蓝名,真是菜的一笔,明年就大三了,马上就要毕业了,然而还是啥也不会,兼职和智障没什么两样,当初大一吹的牛逼说要成为学校 ...

随机推荐

  1. java单测时的等待模块awaitility

    单测时,可以用来等待异步任务完成 在编写自动化测试用例过程中,往往会遇见被测代码有异步或者队列处理的中间过程:如果需要校验这部分结果,必须等待异步操作结束或队列消费完,而这个中间等待的时间是不确定的, ...

  2. 如何查看pip安装包的所有版本;以及ipython的安装

    安装ipython很简单,直接使用pip就行 比如mac环境下:pip install ipython:提示安装失败,原因是pip默认安装的ipython版本6.0+不适用python3.3以下版本 ...

  3. intent 支持的action 动作

    String ACTION_AIRPLANE_MODE_CHANGED Broadcast Action: The user has switched the phone into or out of ...

  4. 如何防范SQL注入式攻击

    一.什么是SQL注入式攻击? 所谓SQL注入式攻击,就是攻击者把SQL命令插入到Web表单的输入域或页面请求的查询字符串,欺骗服务器执行恶意的SQL命令.在某些表单中,用户输入的内容直接用来构造(或者 ...

  5. yarn 基本用法

    1.初始化一个新的项目 yarn init 2.添加一个依赖包 yarn add [package] yarn add [package]@[version] yarn add [package]@[ ...

  6. linux遍历目录源代码

    <pre code_snippet_id="1622396" snippet_file_name="blog_20160324_1_744516" nam ...

  7. 找top 10信息

    本文章内容来源于<程序猿面试宝典>. 题目: 有1千万条短信,以文本文件的形式保存.一行一条,有反复.请用5分钟时间,找出反复出现最多的前10条. 解析: 某些面试者想用数据库的办法来实现 ...

  8. iOS移动开发周报-第19期

    iOS移动开发周报-第19期 前言 欢迎国内的iOS同行或技术作者向我提交周报线索,线索可以是新闻.教程.开发工具或开源项目,将相关文章的简介和链接在微博上发布并 @唐巧_boy 即可. [摘要]:本 ...

  9. React_Redux_Router

    一.react_redux 比较好的blog: blog1, blog2, blog3 主要根据前两个blog总结如下: 1. React在组件内部(包括子组件)为单向数据流且自上向下通过props传 ...

  10. EasyPlayer开源流媒体移动端播放器推出RTSP-RTMP-HTTP-HLS全功能Pro版

    EasyPlayerPro介绍 Android EasyPlayerPro专业版全功能播放器,是由EasyDarwin开源团队维护的一款支持RTSP.RTMP.HTTP.HLS多种流媒体协议的播放器版 ...