- 博客(19)
- 收藏
- 关注
原创 ICPC Southeastern Europe Contest 2019 H. Absolute Game
H. Absolute GameAlice and Bob are playing a game. Alice has an array a of n integers, Bob has an array b of n integers. In each turn, a player removes one element of his array. Players take turns alt...
2020-04-14 20:58:26
448
原创 ICPC Southeastern Europe Contest 2019 D Game on a Tree
Game on a TreeAlice and Bob play a game on a tree. Initially, all nodes are white.Alice is the first to move. She chooses any node and put a chip on it. The node becomes black. After that players ta...
2020-04-14 20:42:43
560
原创 快速幂模板
快速幂模板#include <iostream>#include <algorithm>#include <cstring>#include <cstdio>#include <cmath>#include <map>#include <stack>#define maxn 500050#defi...
2020-01-09 11:52:17
195
原创 汉诺塔Ⅱ(上) -奇怪的汉诺塔(简单递推)
96. 奇怪的汉诺塔汉诺塔问题,条件如下:1、这里有A、B、C和D四座塔。2、这里有n个圆盘,n的数量是恒定的。3、每个圆盘的尺寸都不相同。4、所有的圆盘在开始时都堆叠在塔A上,且圆盘尺寸从塔顶到塔底逐渐增大。5、我们需要将所有的圆盘都从塔A转移到塔D上。6、每次可以移动一个圆盘,当塔为空塔或者塔顶圆盘尺寸大于被移动圆盘时,可将圆盘移至这座塔上。请你求出将所有圆盘从塔A移动到塔D,...
2019-10-28 21:20:46
876
原创 AcWing-95. 费解的开关(基础算法,简单递推)
95. 费解的开关你玩过“拉灯”游戏吗?25盏灯排成一个5x5的方形。每一个灯都有一个开关,游戏者可以改变它的状态。每一步,游戏者可以改变某一个灯的状态。游戏者改变一个灯的状态会产生连锁反应:和这个灯上下左右相邻的灯也要相应地改变其状态。我们用数字“1”表示一盏开着的灯,用数字“0”表示关着的灯。下面这种状态1011101101101111000011011在改变了最左上角的灯的状...
2019-10-09 20:38:00
497
原创 CodeForces - 1213D2-Equalizing by Division (hard version)(简单思维)
CodeForces - 1213D2-Equalizing by Division (hard version) The only difference between easy and hard versions is the number of elements in the array.You are given an array a consisting of n integers....
2019-09-30 08:24:02
213
原创 Codeforces-1217C-The Number Of Good Substrings(思维+枚举)
Codeforces-1217C-The Number Of Good SubstringsYou are given a binary string s (recall that a string is binary if each character is either 0 or 1).Let f(t) be the decimal representation of integer t ...
2019-09-29 23:22:35
360
原创 codeforces 1217B-Zmei Gorynich(简单思维)
codeforces 1217B-Zmei GorynichYou are fighting with Zmei Gorynich — a ferocious monster from Slavic myths, a huge dragon-like reptile with multiple heads!Initially Zmei Gorynich has x heads. You can...
2019-09-29 23:09:56
423
原创 CodeForces-1209D-Cow and Snacks (并查集)
CodeForces-1209D-Cow and SnacksThe legendary Farmer John is throwing a huge party, and animals from all over the world are hanging out at his house. His guests are hungry, so he instructs his cow Bes...
2019-09-29 09:07:39
462
原创 CodeForces 1209 C.Paint the Digits
CodeForces1209 C.Paint the DigitsYou are given a sequence of n digits d1d2…dn. You need to paint all the digits in two colors so that:each digit is painted either in the color 1 or in the color 2;i...
2019-09-27 21:51:21
334
原创 POJ--1742 Coins(DP,多重背包)
POJ–1742 Coins给定N种硬币,其中第 i 种硬币的面值为Ai,共有Ci个。从中选出若干个硬币,把面值相加,若结果为S,则称“面值S能被拼成”。求1~M之间能被拼成的面值有多少个。输入格式输入包含多组测试用例。每组测试用例第一行包含两个整数N和M。第二行包含2N个整数,分别表示A1,A2,…,AN和C1,C2,…,CN。当输入用例N=0,M=0时,表示输入终止,且该用例无...
2019-09-22 20:25:37
308
原创 简单位运算 + DFS练习
92. 递归实现指数型枚举(位运算 + DFS)从 1~n 这 n 个整数中随机选取任意多个,输出所有可能的选择方案。输入格式输入一个整数n。输出格式每行输出一种方案。同一行内的数必须升序排列,相邻两个数用恰好1个空格隔开。对于没有选任何数的方案,输出空行。本题有自定义校验器(SPJ),各行(不同方案)之间的顺序任意。数据范围1≤n≤15输入样例:3输出样例:322...
2019-09-20 21:14:45
307
1
原创 AcWing 273. 分级 (线性DP)
AcWing 273. 分级 给定长度为N的序列A,构造一个长度为N的序列B,满足:1、B非严格单调,即B1≤B2≤…≤BN或B1≥B2≥…≥BN。2、最小化 S=∑Ni=1|Ai−Bi|。只需要求出这个最小值S。输入格式第一行包含一个整数N。接下来N行,每行包含一个整数Ai。输出格式输出一个整数,表示最小S值。数据范围1≤N≤2000,1≤|Ai|≤109输入样例:7...
2019-09-08 16:38:17
506
原创 271. 杨老师的照相排列 (线性DP)
271. 杨老师的照相排列杨老师希望给他的班级拍一张合照。学生们将站成左端对齐的多排,靠后的排站的人数不能少于靠前的排。例如,12名学生(从后向前)可以排列成每排5,3,3,1人,如下所示:X X X X XX X XX X XX同时,杨老师希望同行学生身高从左到右依次降低,同列学生身高从后向前依次降低。还以12名学生为例,给学生们编号(号码越小代表身高越高)后,按照此规则可进行...
2019-09-04 21:43:39
431
原创 AcWing 91. 最短Hamilton路径
AcWing 91. 最短Hamilton路径给定一张 n 个点的带权无向图,点从 0~n-1 标号,求起点 0 到终点 n-1 的最短Hamilton路径。 Hamilton路径的定义是从 0 到 n-1 不重不漏地经过每个点恰好一次。输入格式第一行输入整数n。接下来n行每行n个整数,其中第i行第j个整数表示点i到j的距离(记为a[i,j])。对于任意的x,y,z,数据保证 a[x,x...
2019-09-03 16:28:20
302
原创 CF-812b - sagheer, the hausmeister(DP)
B. Sagheer, the HausmeisterSome people leave the lights at their workplaces on when they leave that is a waste of resources. As a hausmeister of DHBW, Sagheer waits till all students and professors l...
2019-08-22 22:24:49
167
原创 B. Balanced Substring (DP + 前缀和 + map)
B. Balanced SubstringYou are given a string s consisting only of characters 0 and 1. A substring [l, r] of s is a string slsl + 1sl + 2… sr, and its length equals to r - l + 1. A substring is called ...
2019-08-21 00:17:37
365
原创 CH5101
题目:熊大妈的奶牛在小沐沐的熏陶下开始研究信息题目。小沐沐先让奶牛研究了最长上升子序列,再让他们研究了最长公共子序列,现在又让他们研究最长公共上升子序列了。小沐沐说,对于两个数列A和B,如果它们都包含一段位置不一定连续的数,且数值是严格递增的,那么称这一段数是两个数列的公共上升子序列,而所有的公共上升子序列中最长的就是最长公共上升子序列了。奶牛半懂不懂,小沐沐要你来告诉奶牛什么是最长公共上...
2019-08-18 20:57:22
308
1
原创 HDU1300——Pearls (DP)
题目:Problem DescriptionIn Pearlania everybody is fond of pearls. One company, called The Royal Pearl, produces a lot of jewelry with pearls in it. The Royal Pearl has its name because it delivers to ...
2019-08-18 20:49:03
216
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅