Codeforces Round #116 (Div. 2, ACM-ICPC Rules)

代码


A. Defragmentation

  • 按颜色分配\(1\)到\(\sum_{i=1}^{m}{n_i}\)位置,那么可以得到\(t_i\)表示位置\(i\)最后占据位置\(t_i\),-1表示该位置为空。
  • 那么会出现两种情况:
  1. \(t_1 \to t_2 \to \cdots \to \ {-1}\),即一条链,从后面往前覆盖。
  2. \(t_1 \to t_2 \to \cdots \to t_i \to t_1\),构成一条链,那么找到一个空位置,将其中一个值暂存在空位置上,变成一条链,最后再把暂存的值放到相应的位置上。

B. Divisibility Rules

  • \(2-type\):\[gcd(d, b, b^2, \cdots, b^k) = 1\]
  • \(3-type\):\[(b-1)\ mod\ d =0\]
  • \(11-type\):\[(b+1)\ mod\ d =0\]
  • \(6-type\):分解质因数,判断每种是否都能表示成前3种之一。

C. Letter

  • 枚举边界,统计前半部分大写字母个数,后半部分小写字母个数。

D. Name

  • 尽可能让前缀相等。
  • \(t\)是\(s\)的前缀情况特判。

E. Cubes

  • 统计每种颜色的位置。
  • 每种颜色单独做,维护左右边界,当操作次数超过k时缩小范围。

F. Mathematical Analysis Rocks!

  • \[p[a[i]] = b[i]\]

Codeforces Round #116 (Div. 2, ACM-ICPC Rules)的更多相关文章

  1. codeforces水题100道 第十八题 Codeforces Round #289 (Div. 2, ACM ICPC Rules) A. Maximum in Table (brute force)

    题目链接:http://www.codeforces.com/problemset/problem/509/A题意:f[i][1]=f[1][i]=1,f[i][j]=f[i-1][j]+f[i][j ...

  2. Codeforces Round #289 (Div. 2, ACM ICPC Rules) E. Pretty Song 算贡献+前缀和

    E. Pretty Song time limit per test 1 second memory limit per test 256 megabytes input standard input ...

  3. Codeforces Round #289 (Div. 2, ACM ICPC Rules) A. Maximum in Table【递推】

    A. Maximum in Table time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  4. 贪心 Codeforces Round #289 (Div. 2, ACM ICPC Rules) B. Painting Pebbles

    题目传送门 /* 题意:有 n 个piles,第 i 个 piles有 ai 个pebbles,用 k 种颜色去填充所有存在的pebbles, 使得任意两个piles,用颜色c填充的pebbles数量 ...

  5. 递推水题 Codeforces Round #289 (Div. 2, ACM ICPC Rules) A. Maximum in Table

    题目传送门 /* 模拟递推水题 */ #include <cstdio> #include <iostream> #include <cmath> #include ...

  6. Codeforces Round #622 (Div. 2) B. Different Rules(数学)

    Codeforces Round #622 (Div. 2) B. Different Rules 题意: 你在参加一个比赛,最终按两场分赛的排名之和排名,每场分赛中不存在名次并列,给出参赛人数 n ...

  7. Codeforces Round #116 (Div. 2, ACM-ICPC Rules) E. Cubes (尺取)

    题目链接:http://codeforces.com/problemset/problem/180/E 给你n个数,每个数代表一种颜色,给你1到m的m种颜色.最多可以删k个数,问你最长连续相同颜色的序 ...

  8. Codeforces Round #116 (Div. 2, ACM-ICPC Rules) C. Letter 暴力

    C. Letter Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/180/problem/C D ...

  9. Codeforces Round #116 (Div. 2, ACM-ICPC Rules) Letter(DP 枚举)

    Letter time limit per test 1 second memory limit per test 256 megabytes input standard input output ...

随机推荐

  1. Hibernate中的多对多映射

    1.需求 项目与开发员工 一个项目,有多个开发人员 一个开发人员,参与多个项目 [多对多] 2.实体bean设计 Project: public class Project { private int ...

  2. SQL CAST, CONVERT 比较

    本文转自:http://www.cnblogs.com/denylau/archive/2010/12/01/1893371.html if (@StartTime > @EndTime)    ...

  3. Oracle Database 11g express edition

    commands : show sys connect sys as sysdba or connect system as sysdba logout or disc clear screen or ...

  4. wince6.0 开机启动定制的程序

    1.prject.bib MediaApp.exe $(_FLATRELEASEDIR)\MediaApp.exe NK H MediaApp.lnk $(_FLATRELEASEDIR)\Media ...

  5. C# 调用配置文件SQL语句 真2B!

    /********************************************************************************* ** File Name : SQ ...

  6. centos下安装node js

    #wget http://nodejs.org/dist/v0.10.24/node-v0.10.24.tar.gz #tar xf node-v0.10.24.tar.gz #cd node-v0. ...

  7. PHP里10个鲜为人知但却非常有用的函数

    levenshtein() 你有没有经历过需要知道两个单词有多大的不同的时候,这个函数就是来帮你解决这个问题的.它能比较出两个字符串的不同程度. 用法: <?php $str1 = " ...

  8. C杂记

    printf主要是为了便于取地址,默认将char,short变成了int,float变成了double:但scanf的时候,因为数据宽度的问题,必须区分%f和%lf. memset 是字符串操作函数: ...

  9. Java中接口作为方法的返回

    在<算法>中的散列表一节,在用拉链法实现散列表的API时要求实现以下一个方法: public Iterable<Key> keys() 我们知道Iterable是一个接口,那么 ...

  10. Python _ 开始介绍对象

    Python的私有变量,函数是在前面加上一个双下划线'__'来声明的,气访问和C++大同小异 例如 class Person: __name='小甲鱼' def print1(self): # 和 c ...