传送门:http://codeforces.com/problemset/problem/732/B Cormen - The Best Friend Of a Man time limit per test1 second memory limit per test256 megabytes Problem Description Recently a dog was bought for Polycarp. The dog's name is Cormen. Now Polycarp has…
题意:给定n和k表示,狗要在任意连续两天散步次数要至少为k,然后就是n个数,表示每天的时间,让你增加最少次数使得这个条件成立. 析:贪心,策略是从开始到最后暴力,每次和前面一个相比,如果相加不够k,那么就给当前加上差. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000") #include <cstdio> #include <string> #include <cstdlib>…
B. Cormen - The Best Friend Of a Man time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Recently a dog was bought for Polycarp. The dog's name is Cormen. Now Polycarp has a lot of troubles. Fo…
传送门:http://codeforces.com/problemset/problem/16/C Monitor time limit per test0.5 second memory limit per test64 megabytes Problem Description Reca company makes monitors, the most popular of their models is AB999 with the screen size a × b centimeter…
PS:这一场真的是上分场,只要手速快就行.然而在自己做的时候不用翻译软件,看题非常吃力非常慢,还有给队友讲D题如何判断的时候又犯了一个毛病,一定要心平气和,比赛也要保证,不要用翻译软件做题: Codeforces732A 水题: #include<cstdio> #include<math.h> #include<queue> #include<map> #include<string> #include<string.h> #inc…
acmicpc.info acmicpc.info http://acmicpc.info/archives/224 此网站聚合了各种ICPC相关信息. 国内Online Judge 用户体验极佳的vjudge 虚拟OJ:https://vjudge.net/ 这个网站的特色就是用户可以自己举办比赛,vjudge支持数十个OJ网站,用户可以从这些OJ网站上选择题目,可以选择一些同类型题目形成一个题集.但是vjudge上的题目并不会永久保存,过一段时间就被清空了. 非常活跃的hdu 杭州电子科技大…
Internet,人们通常称为因特网,是当今世界上覆盖面最大和应用最广泛的网络.根据英语构词法,Internet是Inter + net,Inter-作为前缀在英语中表示“在一起,交互”,由此可知Internet的目的是让各个net交互.所以,Internet实质上是将世界上各个国家.各个网络运营商的多个网络相互连接构成的一个全球范围内的统一网,使各个网络之间能够相互到达.各个国家和运营商构建网络采用的底层技术和实现可能各不相同,但只要采用统一的上层协议(TCP/IP)就可以通过Internet…
通过爬虫 获取 官方文档库 如果想获取 相应的库 修改对应配置即可 代码如下 from urllib.parse import urljoin import requests from lxml import etree def get_data(page_num, key, file_name): """ 解析 page_num: 爬取页数 key: 爬取的关键字 file_name: 存入的文件 """ headers = { 'author…
codeforce 7C C. Line time limit per test1 second memory limit per test256 megabytes A line on the plane is described by an equation Ax + By + C = 0. You are to find any point on this line, whose coordinates are integer numbers from  - 5·1018 to 5·101…
D. The Child and Sequence time limit per test 4 seconds memory limit per test 256 megabytes input standard input output standard output At the children's day, the child came to Picks's house, and messed his house up. Picks was angry at him. A lot of…
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output Recently a dog was bought for Polycarp. The dog's name is Cormen. Now Polycarp has a lot of troubles. For example, Cormen likes going for a walk.…
 传送门 Description Recently a dog was bought for Polycarp. The dog's name is Cormen. Now Polycarp has a lot of troubles. For example, Cormen likes going for a walk. Empirically Polycarp learned that the dog needs at least k walks for any two consecutiv…
three version are provided. disjoint set, linked list version with weighted-union heuristic, rooted tree version with rank by union and path compression, and a minor but substantial optimization for path compression version FindSet to avoid redundanc…
Cormen — The Best Friend Of a Man time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Recently a dog was bought for Polycarp. The dog's name is Cormen. Now Polycarp has a lot of troubles. For e…
又水了一发Codeforce ,这次继续发发题解顺便给自己PKUSC攒攒人品吧 CodeForces 438C:The Child and Polygon: 描述:给出一个多边形,求三角剖分的方案数(n<=200). 首先很明显可能是区间dp,我们可以记f[i][j]为从i到j的这个多边形的三角剖分数,那么f[i][j]=f[i][k]*f[j][k]*(i,j,k是否为1个合格的三角形) Code: #include<cstdio> #include<iostream> #…
codeforce 375_2 标签: 水题 好久没有打代码,竟然一场比赛两次卡在边界条件上....跪 b.题意很简单...纯模拟就可以了,开始忘记了当字符串结束的时候也要更新两个值,所以就错了 #include<cstdio> #include<cstring> #include<algorithm> using namespace std; const int N = 300; char a[N]; int main() { int n; int l; int su…
codeforce 367dev2_c dp 标签: dp 题意: 你可以通过反转任意字符串,使得所给的所有字符串排列顺序为字典序,每次反转都有一定的代价,问你最小的代价 题解:水水的dp...仔细想想就有了,一个位置要么反转要么就不反转...保证在满足条件时候转移 扔个代码: #include<cstdio> #include<cstring> #include<string> #include<iostream> #include<algorith…
三维dp&codeforce 369_2_C 标签: dp codeforce 369_2_C 题意: 一排树,初始的时候有的有颜色,有的没有颜色,现在给没有颜色的树染色,给出n课树,用m种燃料涂,将相邻相同颜色的树划为一组,最后使得组数为k,并且所用燃料的量最小,给出了每棵树涂j种燃料的用量,如果存在这种涂法输出最小用量,不存在输出-1: 题解: 很容易看出是一个三维dp, dp[i][j][k] 表示处理到第i棵树,最后一棵树为颜色j,现在已经分成的组数为k的时候的最小用量 转移方程如果当前…
强连通分量 标签: 图论 算法介绍 还记得割点割边算法吗.回顾一下,tarjan算法,dfs过程中记录当前点的时间戳,并通过它的子节点的low值更新它的low,low值是这个点不通过它的父亲节点最远可以到达的dfn值最小的点,如果当前的节点的low>他父亲节点的dfn说明它不能通过其他的边到达它的父亲,那么它和他父亲的这条边就是割边,在这个算法中有三个标号,VIS数组,标记为0表示没有被访问到,标记为1表示这个点正在搜索它的自孩子,标记为2表示这个点已经处理过了,就是已经找到了它属于哪个联通块,…
[树状数组]区间出现偶数次数的异或和(区间不同数的异或和)@ codeforce 703 D PROBLEM 题目描述 初始给定n个卡片拍成一排,其中第i个卡片上的数为x[i]. 有q个询问,每次询问给定L和R表示,询问的区间[L,R]内的卡片所有出现了偶数次的数的异或和是多少. 输入 输入一行两个整数n,q. 第二行n个整数,第i个数为x[i]. 接下来q行,每行两个整数L和R,表示询问的区间. 输出 输出q行,其中第i行表示第i次询问的区间出现偶数次的数的异或和. 样例输入 3 1 3 7…
堆和堆的应用:堆排序和优先队列 https://mp.weixin.qq.com/s/dM8IHEN95IvzQaUKH5zVXw 堆和堆的应用:堆排序和优先队列 2018-02-27 算法与数据结构 来源: Spground spground.github.io/2017/07/07/堆和堆的应用:堆排序和优先队列/ 1.堆 堆(Heap))是一种重要的数据结构,是实现优先队列(Priority Queues)首选的数据结构.由于堆有很多种变体,包括二项式堆.斐波那契堆等,但是这里只考虑最常见…
http://www.lydsy.com/JudgeOnline/problem.php?id=1926 https://www.luogu.org/problemnew/show/P2468 幸福幼儿园B29班的粟粟是一个聪明机灵.乖巧可爱的小朋友,她的爱好是画画和读书,尤其喜欢Thomas H. Cormen的文章.粟粟家中有一个R行C列的巨型书架,书架的每一个位置都摆有一本书,上数第i行.左数第j列摆放的书有Pi,j页厚. 粟粟每天除了读书之外,还有一件必不可少的工作就是摘苹果,她每天必须…
An arithmetic progression is such a non-empty sequence of numbers where the difference between any two successive numbers is constant. This constant number is called common difference. For example, the sequence 3, 7, 11, 15 is an arithmetic progressi…
You are given a sequence of numbers a1, a2, ..., an, and a number m. Check if it is possible to choose a non-empty subsequence aij such that the sum of numbers in this subsequence is divisible by m. Input The first line contains two numbers, n and m…
In the capital city of Berland, Bertown, demonstrations are against the recent election of the King of Berland. Berland opposition, led by Mr. Ovalny, believes that the elections were not fair enough and wants to organize a demonstration at one of th…
Two players play a game. The game is played on a rectangular board with n × m squares. At the beginning of the game two different squares of the board have two chips. The first player's goal is to shift the chips to the same square. The second player…
To confuse the opponents, the Galactic Empire represents fractions in an unusual format. The fractions are represented as two sets of integers. The product of numbers from the first set gives the fraction numerator, the product of numbers from the se…
Prime Number CodeForces - 359C Simon has a prime number x and an array of non-negative integers a1, a2, ..., an. Simon loves fractions very much. Today he wrote out number on a piece of paper. After Simon led all fractions to a common denominator and…
A tournament is a directed graph without self-loops in which every pair of vertexes is connected by exactly one directed edge. That is, for any two vertexes u and v (u ≠ v) exists either an edge going from u to v, or an edge from v to u. You are give…
此主要讨论图像处理与分析.虽然计算机视觉部分的有些内容比如特 征提取等也可以归结到图像分析中来,但鉴于它们与计算机视觉的紧密联系,以 及它们的出处,没有把它们纳入到图像处理与分析中来.同样,这里面也有一些 也可以划归到计算机视觉中去.这都不重要,只要知道有这么个方法,能为自己 所用,或者从中得到灵感,这就够了. 8. Edge Detection 边缘检测也是图像处理中的一个基本任务.传统的边缘检测方法有基于梯度 算子,尤其是 Sobel 算子,以及经典的 Canny 边缘检测.到现在,Cann…