- 博客(49)
- 收藏
- 关注
原创 Educational Codeforces Round 89 (Rated for Div. 2)D
思路就是构造:以下构造方法学习自heyuyyy大佬#include <iostream>#include <cstring>#include <cstdio>#include <queue>#include <algorithm>#include <cmath>#include <vector>#include <map>using namespace std;#define inf.
2020-07-05 11:40:20
2782
原创 Educational Codeforces Round 89 (Rated for Div. 2) C. Palindromic Paths
解题思路:可发现固定步数到达的点都会在一条对角线上,,因此找到一条对角线i+j-1,然后与在回文路上对应的另一条对角线n+m+1-i-j对比,取0,1数量最小的加到ans里面。#include <iostream>#include <cstring>#include <cstdio>#include <queue>#include <algorithm>#include <cmath>#include <vec..
2020-07-05 10:40:12
3310
原创 Codeforces Round #652 (Div. 2) F BareLee
#include <iostream>#include <cstring>#include <cstdio>#include <queue>#include <algorithm>#include <cmath>#include <vector>#include <map>using namespace std;#define inf 0x7fffffff#define ll long l..
2020-06-30 23:16:01
6463
原创 Codeforces Round #652 (Div. 2) E - DeadLee (贪心)
#include <iostream>#include <cstring>#include <cstdio>#include <queue>#include <algorithm>#include <cmath>#include <vector>#include <map>using namespace std;#define inf 0x7fffffff#define ll long lo.
2020-06-30 23:12:24
4729
原创 Codeforces Round #652 (Div. 2) D TediousLee
DP解题思路:画出leve1~5的图形之后就可以发现,level[i]是由1个level[i-1]和2个level[i-2]再加一个根节点组成的,以level[4]为例:红色的为level[3],绿色的为level[2]两种比较好的理解方式:#include<iostream>#include<cstring>#include<cstdio>#include<cmath>using namespace std;const int m...
2020-06-30 23:06:51
4691
原创 Codeforces Round #652 (Div. 2) AB
A,求一个正多边形有两条边分别平行于X和YB:注意到1…0这样的形式最后一定能变为一个0。那么因为要求字典序最小,所以贪心缩一下就行。#include<iostream>#include<cstdio>#include<cmath>using namespace std;const int maxn = 100000 + 5;int n, s[maxn];int main(){ int T; scanf("%d", &T); while
2020-06-30 22:29:29
214
原创 Codeforces Round 647 (Div. 1)___C. Johnny and Megans Necklace —— 欧拉回路
题目大意:解题思路:#include <iostream>#include <algorithm>#include <cstring>#include <cstdio>#include <vector>#include <cmath>#include <set>#include <map>#include <queue>#include <iomanip>#in
2020-06-27 22:21:00
150
原创 图论
最短路问题系列:优先队列不一定什么时候都有效,有时候暴力反而更快并查集可维护连通性求桥算法:有向图无环->至少一个点无出边记得缩图缩点缩环技巧
2020-06-27 10:27:01
171
原创 CF 647E Johnny and Grandmaster
注意随意取模的那个数全程也要用那个模数,计算qpow,不然会出错#include <iostream>#include <cstring>#include <cstdio>#include <algorithm>#include <queue>#include <vector>#include <string>#include <cmath>#include <set>#inc..
2020-06-24 18:00:53
215
原创 Codeforces Round #647 (Div. 2) D. Johnny and Contribution(贪心)
题意:Jony要写n篇博客,每篇博客的内容只能覆盖一个主题,但一个主题可以被多篇博客覆盖。在博客与博客之间可以相互引用,但是相互引用的博客不能涵盖相同的主题,否则博客是无效的。给出Jony要写的博客之间的相互引用关系,他在写博客的时候会依照这个引用关系来安排写博客的顺序,因此他在写博客的时候会首先查看他要引用的博客的主题,然后选出没有被覆盖的且主题编号最小的主题写入本篇博客。例如:若要的这篇博客引用的博客覆盖了主题1,3,2,5,那么这篇博客就应该要选择主题4编写。问是否存在一个写博客的顺序满足博客之间的相
2020-06-24 17:57:03
608
原创 Codeforces Round #644 (Div. 3) H Binary Median
题意:给你m代表有2^m 个不同的01串,现在去掉n个,问剩下的2^m-n个串中 排序后中位的字符串. 中位计算:(id-1)/2做法:因为m只有60,考虑字符串当作longlong的整数来算。最初的中位数一定是01111形式就是2^(m-1)-1.然后n只有100,考虑对初始的中位数上下枚举100个数,然后判断小于当前数和大于当前数是否相等。至于怎么 去掉 n 的 影响。对当前数在n中二分查找大于当前数x的个数。那么大于x的个数就少了这么多。#pragma GCC optimize(2)#inc
2020-06-20 23:50:13
156
原创 CodeForces - 1333D Challenges in school №41(构造+模拟)
#include <iostream>#include <cstring>#include <cstdio>#include <queue>#include <vector>using namespace std;#define inf 0x7fffffffvector<int> v[3000001];char...
2020-04-13 16:56:51
132
原创 最大连续子序列和
下面引入一个编程题理解最大连续子序列和的概念有一个数组,如1, -5, 8, 3, -4, 15, -8,查找其中连续和最大的相邻串的值。在本例中,最大值为8 + 3 + -4 + 15 = 22.朴素算法的复杂度为O(n^2),另一种算法如下:首先假设我们已经找到了最大连续和子串在数组中的起始位置(i)和结束位置(j),其中i <= j,即最大和maxSum = a[i] + a...
2020-01-11 21:38:09
322
原创 HDU 4283 You Are the One(区间DP)
Problem Description The TV shows such as You Are the One has been very popular. In order to meet the need of boys who are still single, TJUT hold the show itself. The show is hold in the Small hall,...
2019-10-04 11:44:04
131
原创 codeforce 1234 B2、D
D. Distinct Characters Queriestime limit per test: 2 secondsmemory limit per test: 256 megabytesYou are given a string ss consisting of lowercase Latin letters and qq queries for this string.Recal...
2019-10-03 19:40:26
298
原创 bzoj3257 树的难题(树形DP)
Description给出一个无根树。树有N个点,边有权值。每个点都有颜色,是黑色、白色、灰色这三种颜色之一,称为一棵三色树。可爱的 Alice觉得,一个三色树为均衡的,当且仅当,树中不含有黑色结点或者含有至多一个白色节点。然而,给出的三色树可能并不满足这个性质。所以,Alice打算删去若干条边使得形成的森林中每棵树都是均衡的,花费的代价等于删去的边的权值之和。请你计算需要花费的代价最...
2019-10-01 16:08:24
486
1
转载 [HNOI]2003 消防局的建立
题目描述2020年,人类在火星上建立了一个庞大的基地群,总共有n个基地。起初为了节约材料,人类只修建了n-1条道路来连接这些基地,并且每两个基地都能够通过道路到达,所以所有的基地形成了一个巨大的树状结构。如果基地A到基地B至少要经过d条道路的话,我们称基地A到基地B的距离为d。由于火星上非常干燥,经常引发火灾,人类决定在火星上修建若干个消防局。消防局只能修建在基地里,每个消防局有能力扑灭与它距...
2019-09-30 20:24:30
152
原创 Primes and Multiplication
Let’s introduce some definitions that will be needed later.Let prime(x)prime(x) be the set of prime divisors of xx. For example, prime(140)={2,5,7}prime(140)={2,5,7}, prime(169)={13}prime(169)={13}....
2019-09-30 19:30:35
279
原创 洛谷P2585[ZJOI2006]三色二叉树(树形DP)
思路树形DP,首先是递归建树,然后是DP状态方程转移。代码#include<cstdio>#include<cstring>#include<algorithm>#include <cmath>#include<vector>#define ll long long#define inf 0x3f3f3f3f#def...
2019-09-27 21:00:07
596
原创 Codeforces 149D Coloring Brackets(区间dp)
给出一个合法的括号序列,要求给这个序列染色,求染色方案。1.可以选择无色、红色、蓝色。2.每一对括号要有且仅有一个染色的括号。3.相邻的括号不能有相同的颜色(无色没关系)#include<cstdio>#include<cstring>#include<algorithm>#define rep(i,a,b) for(int i=a;i<=b...
2019-09-17 22:30:20
172
1
转载 POJ 3071 Football(概率dp)
题意:有2^n支队,现在要进行n次比赛,并且按次序进行比赛并淘汰,胜利的队继续按次序比赛并淘汰,比如1,2,3,4进行比赛,第一轮1和2比,3和4比,假如1和3胜利了,那么第二轮1和3继续比,2,4淘汰。最后问最有可能胜利的队伍是哪一支。分析:分析题目,先创建状态,dp[i][j],表示在第i轮比赛中第j支队获胜,那么dp[0][j] = 1。然后考虑状态间的转移,很明显,如果j队要在本轮中...
2019-09-16 19:53:38
196
1
原创 HDU - 6709 Fishing Master(2019中国大学生程序设计竞赛(CCPC) - 网络选拔赛)
Fishing Master(贪心)Heard that eom is a fishing MASTER, you want to acknowledge him as your mentor. As everybody knows, if you want to be a MASTER’s apprentice, you should pass the trial. So when you f...
2019-09-11 21:16:45
216
原创 The Preliminary Contest for ICPC Asia Xuzhou 2019 J Random Access Iterator
Random Access IteratorRecently Kumiko learns to use containers in C++ standard template library.She likes to use the std::vector very much. It is very convenient for her to do operations like an ord...
2019-09-08 21:48:31
235
1
原创 Educational Codeforces Round 72 (Rated for Div. 2) C The Number Of Good Substrings
C. The Number Of Good SubstringsProblem Description:You 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 int...
2019-09-06 20:38:48
134
转载 2018-2019 ACM-ICPC, Asia Nakhon Pathom Regional Contest E How Many Groups
How Many GroupsYou are given an array of n integers. Define a binary relation ~ on the elements of this arrayso that x ~ y if and only if |x – y| is less than or equal to 2. Let ~* be the transitive...
2019-09-03 22:01:26
279
原创 The Preliminary Contest for ICPC Asia Nanjing 2019 D Robots
RobotsGiven a directed graph with no loops which starts at node 11 and ends at node nn.There is a robot who starts at 11, and will go to one of adjacent nodes or stand still with equal probability e...
2019-09-03 20:13:36
142
原创 The Preliminary Contest for ICPC Asia Nanjing 2019 H Holy Grail
Holy GrailDescriptionAs the current heir of a wizarding family with a long history,unfortunately, you find yourself forced to participate in the cruel Holy Grail War which has a reincarnation of six...
2019-09-02 16:33:36
110
转载 2019牛客多校四 K number(dp或前缀和)
转载至:https://www.cnblogs.com/rookie-acmer/p/11258415.htmlnumber题目描述300iq loves numbers who are multiple of 300.One day he got a string consisted of numbers. He wants to know how many substrings in ...
2019-08-31 23:29:18
226
原创 Cosmetic Survey(2018-2019 ACM-ICPC, Asia Seoul Regional Contest B)
ICP(International Cosmetic Perfection) Company plans to survey the preferences of new m cosmetics in order to know which cosmetic is the most preferred. For this survey, ICPC selected n people as eval...
2019-08-31 23:01:24
399
原创 2018 宁夏邀请赛 F Moving On
**2018 宁夏邀请赛 F Moving On(floyd算法变形)**DescriptionFirdaws and Fatinah are living in a country with nn cities, numbered from 11 to nn.Each city has a risk of kidnapping or robbery.Firdaws’s home loc...
2019-08-31 12:17:45
1256
原创 2018 宁夏邀请赛 H Fight Against Monsters
**2018 宁夏邀请赛 H Fight Against Monsters(贪心)**DescriptionIt is my great honour to introduce myself to you here. My name is Aloysius Benjy Cobweb Dartagnan Egbert Felix Gaspar Humbert Ignatius Jayden ...
2019-08-31 12:17:24
290
原创 2019牛客暑期多校训练营(第五场) G subsequence 1(DP+组合数学)
题目描述You are given two strings s and t composed by digits (characters ‘0’ ∼\sim∼ ‘9’). The length of s is n and the length of t is m. The first character of both s and t aren’t ‘0’.Please calculate t...
2019-08-30 21:11:14
165
原创 树形依赖背包的两种实现形式
这里选取 洛谷 P2014 选课作为背景Description一只队伍在爬山时碰到了雪崩,他们在逃跑时遇到了一座桥,他们要尽快的过桥. 桥已经很旧了, 所以它不能承受太重的东西. 任何时候队伍在桥上的人都不能超过一定的限制. 所以这只队伍过桥时只能分批过,当一组全部过去时,下一组才能接着过. 队伍里每个人过桥都需要特定的时间,当一批队员过桥时时间应该算走得最慢的那一个,每个人也有特定的重量,我...
2019-08-29 21:56:36
226
原创 2019牛客暑期多校训练营第一场 E题 ABBA
**ABBA**链接:https://ac.nowcoder.com/acm/contest/881/E?tdsourcetag=s_pcqq_aiomsg来源:牛客网题目描述Bobo has a string of length 2(n + m) which consists of characters A and B. The string also has a fascinati...
2019-08-29 16:43:16
222
原创 It’s Time for a Montage
**Problem I: It’s Time for a Montage(German Collegiate Programming Contest 2018)**The heroes of your favorite action TV show are preparing for the final confrontation with the villains. Fundamental...
2019-08-27 20:23:16
398
原创 Fighting Monsters
**Fighting Monsters(German Collegiate Programming Contest 2018)**Emma just discovered a new card game called Gwint: A wizard’s game. There are two types of cards: monster cards and spell cards. Mon...
2019-08-27 20:09:44
791
1
原创 Problem E: Expired License
**Problem E: Expired License(German Collegiate Programming Contest 2018)**Paul is an extremely gifted computer scientist who just completed his master’s degree at aprestigious German university. N...
2019-08-27 19:47:19
463
原创 BAPC 2018 F Financial Planning
**BAPC 2018 F Financial Planning(二分+贪心)**DescriptionBeing a responsible young adult, you have decided to start planning for retirement. Doing some back-of-the-envelope calculations, you figured ou...
2019-08-24 20:42:39
501
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人