Codeforces Round #117 (Div. 2)

代码


A. Battlefield

any trench in meters numerically does not exceed b.

  • 这个条件意味着每次都是在蓄能开始时走向下一条线段,也就是说每条线段相当于花费了\(a+b\)的时间。
  • bfs,用\(d_i\)表示到达线段i需要经过最少的线段条数,到达\(B\)的时候直接计算欧几里得距离。

B. Vasya's Calendar

  • \[ans = \sum_{i=1}^{n-1}{d-a_i}\]

C. Optimal Sum

  • 考虑去掉绝对值符号。
  • 假定最后和为非负数,那么\(k\)次操作将前\(k\)小的负数转化成整数。
  • 将长度为\(len\)的窗口\([l,r]\)逐渐往右移,优先队列维护绝对值大的负数。
  • 弹出\(a[r-len]\)时,判断该位置是否有变号。
  • 加入\(a[r]\)时,如果是负数,需要考虑是否变号,有两种情况:
  1. 操作次数仍有剩余,那么显然直接变号。
  2. 否则,考虑之前变号的负数绝对值最小的那个,是否小于\(|a[r]|\)而进行替换。
  • 若最后和为负数,将\(a_i\)取反后再做一次即可。

D. Common Divisors

  • kmp求出所有循环串的长度。
  • 假设循环串长度为\(L\), 判断\(s[0..L]=t[0..L]\)。

E. Wooden Fence

  • \(f(i,j,k)\)表示长度为\(i\),最后一块类型为\(j\),旋转状态为\(k\)的方案数。

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

  1. Codeforces Round #117 (Div. 2) D.Common Divisors(KMP最小循环节)

    http://codeforces.com/problemset/problem/182/D 题意:如果把字符串a重复m次可以得到字符串b,那么我们称字符串a为字符串b的一个因子,现在给定两个字符串S ...

  2. Educational Codeforces Round 117 (Rated for Div. 2)

    Educational Codeforces Round 117 (Rated for Div. 2) A. Distance https://codeforces.com/contest/1612/ ...

  3. 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 ...

  4. Codeforces Round #354 (Div. 2) ABCD

    Codeforces Round #354 (Div. 2) Problems     # Name     A Nicholas and Permutation standard input/out ...

  5. Codeforces Round #368 (Div. 2)

    直达–>Codeforces Round #368 (Div. 2) A Brain’s Photos 给你一个NxM的矩阵,一个字母代表一种颜色,如果有”C”,”M”,”Y”三种中任意一种就输 ...

  6. cf之路,1,Codeforces Round #345 (Div. 2)

     cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅.....   ...

  7. Codeforces Round #279 (Div. 2) ABCDE

    Codeforces Round #279 (Div. 2) 做得我都变绿了! Problems     # Name     A Team Olympiad standard input/outpu ...

  8. Codeforces Round #262 (Div. 2) 1003

    Codeforces Round #262 (Div. 2) 1003 C. Present time limit per test 2 seconds memory limit per test 2 ...

  9. Codeforces Round #262 (Div. 2) 1004

    Codeforces Round #262 (Div. 2) 1004 D. Little Victor and Set time limit per test 1 second memory lim ...

随机推荐

  1. Hibernate缓存机制 (2013-07-02 13:51:32)转载▼

    标签: java web hibernate 缓存 代码        分类: javaweb 缓存是位于应用程序与物理数据源之间,用于临时存放复制数据的内存区域,目的是为了减少应用程序对物理数据源访 ...

  2. SharePoint 2010 BCS - 简单实例(一)数据源添加

    博客地址 http://blog.csdn.net/foxdave 本篇基于SharePoint 2010 Foundation. 我的数据库中有一个病人信息表Patient,现在我就想把这个表中的数 ...

  3. Format a Hard Drive in Csharp C#格式化总结

    using System; using System.Diagnostics; using System.IO; using System.Linq; using System.Management; ...

  4. jQuery中 判断事件

    $('button.top').on('mousedown', function() { var $this = $(this); if ($this.hasClass('settop')) { $t ...

  5. STM32串口USART1的使用方法

    前言: 通用同步异步收发器(USART)提供了一种灵活的方法来与使用工业标准NR 异步串行数据格式的外部设备之间进行全双工数据交换. USART利用分数波特率发生器提供宽范围的   波特率选择,支持同 ...

  6. (转)html5开发之viewport使用

    原文:http://www.php100.com/html/webkaifa/HTML5/2012/0831/10979.html 随着高端手机(Andriod,Iphone,Ipod,WinPhon ...

  7. Java Inner class && nested class

    Java中,Inner Class(不被 static修饰)可以访问outer class 的所有成员(包括私有成员),同时,内部类 的创建必须经由外部类的实例! nested class 有stat ...

  8. Jdk配置串在profile中

    JAVA_HOME=/home/will/appSource/jdk1.7.0_25PATH=$JAVA_HOME/bin:$PATHCLASSPATH=.:$JAVA_HOME/lib/dt.jar ...

  9. codeforces 707D-(DFS+bitset)

    题目链接:http://codeforces.com/contest/707/problem/D 根据询问建立一棵树然后DFS. #include<bits/stdc++.h> using ...

  10. Android沉浸式(侵入式)标题栏(状态栏)Status(二)

     Android沉浸式(侵入式)标题栏(状态栏)Status(二) 附录1以xml写style实现了Android沉浸式(侵入式)状态栏(标题栏),同样以上层Java代码实现.在附录文章1的基础上 ...