ASoroban

打表题

Code#include <iostream>#include <string>
using namespace std;
const string A[10]={"O-|-OOOO","O-|O-OOO","O-|OO-OO","O-|OOO-O","O-|OOOO-","-O|-OOOO","-O|O-OOO","-O|OO-OO","-O|OOO-O","-O|OOOO-"};
int main()
{int n;cin>>n;if(n==0)cout<<A[0]<<endl;while(n>0){cout<<A[n%10]<<endl;n/=10;}return 0;
}

BFence

前缀和。。。

Code#include <iostream>using namespace std;
const int N=150000;
int n,k,h[N+10];
int main()
{cin>>n>>k;h[0]=0;int minnum=(n+1)*101,ans=1;for(int i=1;i<=n;i++){cin>>h[i];h[i]+=h[i-1];if((i>=k)&&(h[i]-h[i-k]<minnum)){minnum=h[i]-h[i-k];ans=i-k+1;}}cout<<ans<<endl;return 0;
}

CFixing Typos

唯一的动脑子题目还让我写费事了。。。。其实可以贪的。。。。。

Code#include <iostream>
#include <string>#include <cstdio>
#define  one 0
#define  two 1
using namespace std;
const int S=200000;
string s;
char A[S+10];
int  B[S+10];
int  f[S+10][2];
int main()
{getline(cin,s);int len=s.length(),p=0;A[0]='!';B[0]=0;for(int i=0;i<len;i++)if(s[i]==A[p]) B[p]++;else{p++;A[p]=s[i];B[p]=1;}//for(int i=1;i<=p;i++)//    cout<<A[i]<<','<<B[i]<<endl;f[0][0]=f[0][1]=0;for(int i=1;i<=p;i++){f[i][one]=min(f[i-1][one],f[i-1][two])+B[i]-1;if(B[i]>=2)f[i][two]=f[i-1][one]+B[i]-2;else f[i][two]=f[i-1][one];}//for(int i=1;i<=p;i++)cout<<B[i]<<',';cout<<endl;//for(int i=1;i<=p;i++)cout<<f[i][one]<<',';cout<<endl;//for(int i=1;i<=p;i++)cout<<f[i][two]<<',';cout<<endl;for(int i=p;i>=1;i--){if(f[i][two]<f[i][one]){B[i]=2;B[i-1]=1;i--;}else{B[i]=1;}}for(int i=1;i<=p;i++)for(int j=1;j<=B[i];j++)cout<<A[i];cout<<endl;return 0;
}

转载于:https://www.cnblogs.com/lijianlin1995/p/3418297.html

Codeforces Round #211 (Div. 2)相关推荐

  1. Codeforces Round #506 (Div. 3)

    Codeforces Round #506 (Div. 3) 实习期间事不多,对div3 面向题解和数据编程了一波 A. Many Equal Substrings 题目链接 A题就是找后缀和前缀重合 ...

  2. Codeforces Round #563 (Div. 2)/CF1174

    Codeforces Round #563 (Div. 2)/CF1174 CF1174A Ehab Fails to Be Thanos 其实就是要\(\sum\limits_{i=1}^n a_i ...

  3. 构造 Codeforces Round #302 (Div. 2) B Sea and Islands

    题目传送门 1 /* 2 题意:在n^n的海洋里是否有k块陆地 3 构造算法:按奇偶性来判断,k小于等于所有点数的一半,交叉输出L/S 4 输出完k个L后,之后全部输出S:) 5 5 10 的例子可以 ...

  4. Codeforces Round #696 (Div. 2) (A ~ E)超高质量题解(每日训练 Day.16 )

    整理的算法模板合集: ACM模板 点我看算法全家桶系列!!! 实际上是一个全新的精炼模板整合计划 Codeforces Round #696 (Div. 2) (A ~ E)超高质量题解 比赛链接:h ...

  5. Codeforces Round #712 Div.2(A ~ F) 超高质量题解(每日训练 Day.15 )

    整理的算法模板合集: ACM模板 点我看算法全家桶系列!!! 实际上是一个全新的精炼模板整合计划 Codeforces Round #712 Div.2(A ~ F) 题解 比赛链接:https:// ...

  6. Codeforces Round #701 (Div. 2) A ~ F ,6题全,超高质量良心题解【每日亿题】2021/2/13

    整理的算法模板合集: ACM模板 点我看算法全家桶系列!!! 实际上是一个全新的精炼模板整合计划 目录 A - Add and Divide B - Replace and Keep Sorted C ...

  7. Codeforces Round #700 (Div. 2) D2 Painting the Array II(最通俗易懂的贪心策略讲解)看不懂来打我 ~

    整理的算法模板合集: ACM模板 点我看算法全家桶系列!!! 实际上是一个全新的精炼模板整合计划 整场比赛的A ~ E 6题全,全部题目超高质量题解链接: Codeforces Round #700 ...

  8. Codeforces Round #699 (Div. 2) F - AB Tree(贪心、树上DP)超级清晰,良心题解,看不懂来打我 ~

    整理的算法模板合集: ACM模板 点我看算法全家桶系列!!! 实际上是一个全新的精炼模板整合计划 Codeforces Round #699 (Div. 2) F - AB Tree Problem ...

  9. Codeforces Round #699 (Div. 2) (A ~ F)6题全,超高质量良心题解【每日亿题】2021/2/6

    整理的算法模板合集: ACM模板 点我看算法全家桶系列!!! 实际上是一个全新的精炼模板整合计划 Codeforces Round #699 (Div. 2) (A.B.C)[每日亿题]2021/2/ ...

最新文章

  1. opengl 创建context_OpenGL学习笔记1-创建窗口,绘制三角形
  2. poj3617 贪心
  3. JspServlet之Cookie
  4. begin.lydsy 入门OJ题库:1101、1102:那些四位数、那些四位数之二
  5. udp java_Java实现Udp网络编程
  6. python种颜色循环_Python 实现一个颜色色值转换的小工具
  7. 再说WCF Data Contract KnownTypeAttribute
  8. FPGA学习(第8节)-Verilog设计电路的时序要点及时序仿真
  9. Idea Intellij 常用快捷键
  10. android网易云音乐api调用,网易云音乐常用API浅析 – Moonlib
  11. 智能优化算法应用:基于麻雀搜索优化K-means图像分割算法 - 附代码
  12. 时光轴 时间轴 效果
  13. #创建虚拟机器人URDF模型
  14. 16k Star!一个开源的命令行视频播放器
  15. [足式机器人]Part1 三维空间中的跳行Ch03——【Legged Robots that Balance 读书笔记】
  16. cad2016服务器为空,修改CAD2016的服务器地址
  17. 前端开发中HTML 规范
  18. SpringBoot笔记之模板引擎
  19. JAVA格式化日期、时间,及获取每月第几周 每周第几天 每月第几天
  20. SoO of EBGP

热门文章

  1. mysql数据库任务驱动教程答案_MySQL数据库任务驱动式教程
  2. select函数及fd_set介绍
  3. 孪生三兄弟 CycleGAN, DiscoGAN, DualGAN
  4. Java学习小程序(5)猜数字游戏
  5. 完美图解教程 Linux环境VNC服务安装、配置与使用
  6. Redis跳跃表详解
  7. 【linux下dhcp服务的简单搭建及优化部署】
  8. AR与大数据 珠联璧合带来的无限想象空间
  9. 业内大佬怒喷 Windows 10 Cloud:最大的流氓软件!
  10. 《理解 ES6》阅读整理:函数(Functions)(五)Name Property