【昨晚打校赛,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. ccs 中的定位

    一.相对定位 position:relative; 作用: 相对定位 一般加给定位元素父级    特点: (1)不脱离文档流: (2)不改变元素类型: (3)参照物是元素本身: 二.绝对定位 posi ...

  2. 转: 多版本并发控制(MVCC)在分布式系统中的应用 (from coolshell)

    from:  http://coolshell.cn/articles/6790.html 问题 最近项目中遇到了一个分布式系统的并发控制问题.该问题可以抽象为:某分布式系统由一个数据中心D和若干业务 ...

  3. 转:mybatis——select、insert、update、delete

    一.select <!-- 查询学生,根据id --> <select id="getStudent" parameterType="String&qu ...

  4. display:flex不兼容Android、Safari低版本的解决方案 【flex布局】

    引自 http://www.cnblogs.com/shimily/articles/7943370.html <!DOCTYPE html> <html lang="en ...

  5. java 发送微信客服消息

    package com.baosight.wechat.service; import net.sf.json.JSONObject; import org.apache.commons.httpcl ...

  6. iOS移动开发周报-第16期

    iOS移动开发周报-第16期 [摘要]:本期iOS移动开发周报带来如下内容:i​OS 8的新特性,敏感逻辑的保护方案,iOS绘图教程,WKWebView的使用等. 教程 <i​OS 8>: ...

  7. java开发之随笔记录

    1.java 保留两位小数 DecimalFormat df = new DecimalFormat("#.##"); System.out.println(df.format(1 ...

  8. ActiveMQ 消息持久化到Mysql数据库

    [root@txylucky local]# tar -zxvf apache-activemq-5.15.8-bin.tar.gz[root@txylucky local]# mv apache-a ...

  9. ASP.NET车辆管理系统100%源代码

    系统开发环境为VS2010.採用ASP.NET框架.数据库採用SQL Server.系统採用Ajax,具有:GPS导航(实时监控报警).申请审核.流程查看及短信息发送等功能.这个系统界面和功能是我认为 ...

  10. 初识kbmmw 中的smartbind功能

    关于kbmmw smartbind 的开发原因及思路,大家可以参见官方的博客说明和红鱼儿的翻译. 今天我就实例操作一下,给大家演示一下具体实现. 我们新建一个工程 放几个基本的控件 在单元里面加上引用 ...