A. k-String

  • 统计每个字母出现次数即可。

B. Special Offer! Super Price 999 Bourles!

  • 枚举末尾有几个9,注意不要爆掉\(long\ long\)的范围。

C. Color Stripe

  • 当\(k\gt 2\)时,若\(s_i==s_{i-1}\),那么枚举新的字母使得\(s_i \ne s_{i-1},s_i \ne s_{i+1}\)。
  • 当\(k\gt 2\)时,则需要枚举首位是\(A\)是\(B\)。在\(AAB\)这种情况下,\(k\gt 2\)做法是错误的。

D. Choosing Capital for Treeland

  • 两遍dfs即可。

E. Parking Lot

  • 两个set分别维护已占用的位置和空闲区间。

Codeforces Round #135 (Div. 2)的更多相关文章

  1. 树形DP Codeforces Round #135 (Div. 2) D. Choosing Capital for Treeland

    题目传送门 /* 题意:求一个点为根节点,使得到其他所有点的距离最短,是有向边,反向的距离+1 树形DP:首先假设1为根节点,自下而上计算dp[1](根节点到其他点的距离),然后再从1开始,自上而下计 ...

  2. 构造 Codeforces Round #135 (Div. 2) B. Special Offer! Super Price 999 Bourles!

    题目传送门 /* 构造:从大到小构造,每一次都把最后不是9的变为9,p - p MOD 10^k - 1,直到小于最小值. 另外,最多len-1次循环 */ #include <cstdio&g ...

  3. 贪心 Codeforces Round #135 (Div. 2) C. Color Stripe

    题目传送门 /* 贪心:当m == 2时,结果肯定是ABABAB或BABABA,取最小改变量:当m > 2时,当与前一个相等时, 改变一个字母 同时不和下一个相等就是最优的解法 */ #incl ...

  4. Codeforces Round #135 (Div. 2) E. Parking Lot 线段数区间合并

    E. Parking Lot time limit per test 2 seconds memory limit per test 256 megabytes input standard inpu ...

  5. Codeforces Round #135 (Div. 2) D. Choosing Capital for Treeland dfs

    D. Choosing Capital for Treeland time limit per test 3 seconds memory limit per test 256 megabytes i ...

  6. Codeforces Round #135 (Div. 2)---A. k-String

    k-String time limit per test 2 seconds memory limit per test 256 megabytes input standard input outp ...

  7. Codeforces Round #135 (Div. 2) D - Choosing Capital for Treeland(两种树形DP)

  8. Codeforces Round #135 (Div. 2) D. Choosing Capital for Treeland

    time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standa ...

  9. Codeforces Round #366 (Div. 2) ABC

    Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate ...

随机推荐

  1. Linux-守护进程的实现

    Some basic rules to coding a daemon prevent unwanted interactions from happening. We state these rul ...

  2. HDU 4085 斯坦纳树

    题目大意: 给定无向图,让前k个点都能到达后k个点(保护地)中的一个,而且前k个点每个需要占据后k个中的一个,相互不冲突 找到实现这个条件达到的选择边的最小总权值 这里很容易看出,最后选到的边不保证整 ...

  3. 基于百度定位及天气获取的DEMO

    demo基于百度定位APIv4.0版.新浪天气(不用查询城市代码). 需求: 1.button实现触发定位监听和天气捕获 2.两个textview 分别显示详细地址.天气. 界面很简陋,侧重功能实现. ...

  4. android listview getviewtypecount和getItemViewType

    package newdemo.jeno.listviewdemo; import android.app.Activity;import android.os.Bundle;import andro ...

  5. 这个setDefaultCloseOperation写不写的区别是什么?

      2009-03-23 13:40提问者采纳   设置用户在此窗体上发起 "close" 时默认执行的操作.必须指定以下选项之一: DO_NOTHING_ON_CLOSE(在 W ...

  6. [安卓]The Google Android Stack

  7. 关于$.getJson

    这是一个Ajax函数的缩写,这相当于: 1 2 3 4 5 6 $.ajax({ dataType: "json", url: url, data: data, success: ...

  8. 迪士尼黑科技:爬墙机器人 VertiGo

    12 月 30 日,迪士尼研发出的一款爬墙机器人曝光了一段有趣的视频.从视频里可看出这个机器人碰到墙壁时迅速地作出反应爬了上去. 据了解,这个爬墙机器人名叫 VertiGo,由迪士尼研究中心和苏黎世联 ...

  9. .a包生成64位

    ./configure  CC="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain ...

  10. iOS-APP的沙河目录

    为了安全的缘故,一个应用只能拥有一些目录,用来写入应用的数据或者首选项参数.当一个应用安装到系统,会创建该应用的home目录.以下列出一些home目录下的主要的子目录:/AppName.app:存放应 ...