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. opencv 工程的保存

    一个项目的保存,只要保存工程底下的.CPP  .h   .dll  .lib  输入输出文件即可 最终保存的文件

  2. Hash(哈希)

    一.基本概念 Hash,一般翻译做"散列",也有直接音译为"哈希"的,就是把任意长度的输入(又叫做预映射, pre-image),通过散列算法,变换成固定长度的 ...

  3. vc设置窗口透明

    ::SetWindowLong(GetSafeHwnd(), GWL_EXSTYLE, ::GetWindowLongPtr(GetSafeHwnd(), GWL_EXSTYLE) | WS_EX_L ...

  4. WebService的原理和过程

    转自:http://blog.csdn.net/xiaoqiang081387/article/details/5694304 (一).XML WebService作用  XML WebService ...

  5. M1-S70卡片介绍

    卡片有4K的存储空间,有32个小扇区和8个大扇区.小扇区的结构为:每扇区有4块,每块16个字节,一共64字节,第3块为密钥和控制字节:大扇区的结构为:每扇区16块,每块16个字节,一共256字节,第1 ...

  6. AFNnetworking入门

    AFNetworking官网入门教程简单翻译,学习 AFNetworking 是一个能够快速使用的ios和mac os x下的网络框架,它是构建在Foundation URL Loading Syst ...

  7. 【Zhejiang University PATest】02-1. Reversing Linked List

    Given a constant K and a singly linked list L, you are supposed to reverse the links of every K elem ...

  8. PHP_ArrayList

      <?php //遍历数组的2种方式 $arr=array( "1"=>"hello", "2"=>"my&q ...

  9. Git使用详细教程

    参考网址: http://www.admin10000.com/document/5374.html http://blog.sina.com.cn/s/blog_4f3b79d0010166ab.h ...

  10. JS-OC通信之Cordova简介

    Cordova 是一个可以让 JS 与原生代码(包括 Android 的 java,iOS 的 Objective-C 等)互相通信的一个库,并且提供了一系列的插件类,比如 JS 直接操作本地数据库的 ...