自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(30)
  • 收藏
  • 关注

原创 HDU1255 覆盖的面积(扫描线+离散化+线段树)

题目链接Problem Description给定平面上若干矩形,求出被这些矩形覆盖过至少两次的区域的面积.Input输入数据的第一行是一个正整数T(1<=T<=100),代表测试数据的数量.每个测试数据的第一行是一个正整数N(1<=N<=1000),代表矩形的数量,然后是N行数据,每一行包含四个浮点数,代表平面上的一个矩形的左上角坐标和右下角坐标,矩形的上下边和X轴平行,左右边和Y轴平行.坐标的范围从0到100000.注意:本题的输入数据较多,推荐使用scanf读入数据

2020-11-21 10:54:12 27

原创 Codeforces Round #372 C.Plus and Square Root

题目链接input3Output141646Input2Output99999999999999999844500000000Input4Output2174697

2020-11-19 18:46:40 6

原创 Codeforces Round #683 B. Numbers Box

题目链接Input22 2-1 11 13 40 -1 -2 -3-1 -2 -3 -4-2 -3 -4 -5Output230思路题目要求变换使得矩阵的和最大,由于变换次数不限,所以推断可知当负数数量为偶时,一定可以将所有值都变换为正数,此时结果为所有数的绝对值之和。当负数数量为奇时,至少会有一个数仍为负数,所以此时的结果为所有数的绝对值之和减去绝对值最小的数的两倍。代码#include<bits/stdc++.h>using namespace std

2020-11-16 16:53:11 23

原创 Codeforces Round #679 C(尺取)

题目链接思路由于琴弦序列仅有六种,所以可以将每一个音符与其的差值用结构体记录,排序后在进行尺取即可寻找到符合条件的最值。代码#include<map>#include<stack>#include<queue>#include<string>#include<math.h>#include<stdio.h>#include<string.h>#include<iostream>#inc

2020-10-27 11:39:16 24

原创 Codeforces Round #678 (Div. 2) C

题目链接思路按照题目所给程序,将a[mid]<=x等价转化为mid<=pos,即可求出需要小于和大于x的数量。则答案转化为在x-1个数中任意选取small个小于x的数×在n-x个数中任意选取big个大于x的数×剩余的(n-big-small-1)个数任意组合。代码#include<map>#include<stack>#include<queue>#include<string>#include<math.h>#i

2020-10-26 14:17:47 55

原创 HDU1272 小希的迷宫(并查集判正环)

题目链接思路选用并查集判断是否形成环与是否全部连通即可,如果两个点父节点相同,则必定成环,连通则可以通过i==pre[i]的数量进行判断。代码#include<map>#include<stack>#include<queue>#include<string>#include<math.h>#include<stdio.h>#include<string.h>#include<iostream&

2020-10-24 23:14:00 9

原创 ZOJ3261 Connections in Galaxy War(逆向并查集+删边)

题目链接Sample Input210 2010 15query 0query 1destroy 0 1query 0query 1Sample Output1-1-1-1思路题意在此就不赘述了,相较寻常并查集增添了删边的操作。怎样才可以在并查集中实现删边的操作呢?我们可以选用逆向的方法。首先我们将所有应删边去除后的其余边进行连接,然后从后往前对操作进行实现。当需要查询时,就查询当前情况是否符合题目要求,对结果进行记录;当需要删边时将此边恢复,则可以回到上一次查询时

2020-10-22 15:31:42 18

原创 POJ1733 Parity game(并查集+Map离散化)

题目链接DescriptionNow and then you play the following game with your friend. Your friend writes down a sequence consisting of zeroes and ones. You choose a continuous subsequence (for example the subsequence from the third to the fifth digit inclusively) an

2020-10-17 12:21:47 7

原创 Educational Codeforces Round 96 D(贪心+双指针)

题意给定一个长度为n且只包含0和1的字符串,每次执行两个操作:删掉字符串中任一字符,再去除连续的前缀,询问使字符串为空的最多操作次数。思路对于这样的字符串,我们可以思考如何取才可以达到最优解。例举一些数据可以看出对于字符串开头部分单个非连续的字符,我们可以将其加入非连续子串。若遇到连续子串,可以按照非连续子串的长度与连续子串长度的关系选择将子串留下一个与剩余非连续子串合并或者将非连续子串清空并利用剩余部分再进行一次操作。代码#include<map>#include<sta..

2020-10-13 13:36:47 18

原创 Codeforces Round #673 (Div. 2) C

思路对于每个数,考虑相同数之间最少需要多长的k才能将其涵盖。枚举一个数与序列开头、中间数之间的差和序列结尾,过程中记录长度k范围内最小的数值。代码#include<map>#include<set>#include<stack>#include<queue>#include<string>#include<math.h>#include<stdio.h>#include<string.h>.

2020-10-02 14:39:39 1670 1

原创 HDU4614 Vases and Flowers(线段树区间更新维护+二分)

题目链接Problem DescriptionAlice is so popular that she can receive many flowers everyday. She has N vases numbered from 0 to N-1. When she receive some flowers, she will try to put them in the vases, one flower in one vase. She randomly choose the vase A an

2020-09-29 14:04:21 22

原创 POJ1182 食物链(并查集好题)

题目链接Description动物王国中有三类动物A,B,C,这三类动物的食物链构成了有趣的环形。A吃B, B吃C,C吃A。现有N个动物,以1-N编号。每个动物都是A,B,C中的一种,但是我们并不知道它到底是哪一种。有人用两种说法对这N个动物所构成的食物链关系进行描述:第一种说法是"1 X Y",表示X和Y是同类。第二种说法是"2 X Y",表示X吃Y。此人对N个动物,用上述两种说法,一句接一句地说出K句话,这K句话有的是真的,有的是假的。当一句话满足下列三条之一时,这句话就是假话,否则就是真

2020-09-25 19:50:09 21

原创 洛谷P3386 [模板]二分图最大匹配(网络最大流)

题目链接题目描述给定一个二分图,其左部点的个数为 nnn,右部点的个数为 mmm,边数为 eee,求其最大匹配的边数。左部点从 111 至 nnn 编号,右部点从 111 至 mmm 编号。输入格式输入的第一行是三个整数,分别代表 nnn,mmm 和 eee。接下来 eee 行,每行两个整数 u,vu, vu,v,表示存在一条连接左部点 uuu 和右部点 vvv 的边。输出格式输出一行一个整数,代表二分图最大匹配的边数。输入 #11 1 11 1输出 #11输入 #24 2

2020-09-25 17:01:00 31

原创 洛谷P1343 地震逃生(网络最大流板子)

题目链接题目描述汶川地震发生时,四川**中学正在上课,一看地震发生,老师们立刻带领x名学生逃跑,整个学校可以抽象地看成一个有向图,图中有n个点,m条边。1号点为教室,n号点为安全地带,每条边都只能容纳一定量的学生,超过楼就要倒塌,由于人数太多,校长决定让同学们分成几批逃生,只有第一批学生全部逃生完毕后,第二批学生才能从1号点出发逃生,现在请你帮校长算算,每批最多能运出多少个学生,x名学生分几批才能运完。输入格式第一行3个整数n,m,x(x<2^31,n<=200,m<=2000);

2020-09-24 16:58:02 26

原创 LightOJ1197 Help Hanzo(欧拉筛+区间素数)

题目链接Problem DescriptionAmakusa, the evil spiritual leader has captured the beautiful princess Nakururu. The reason behind this is he had a little problem with Hanzo Hattori, the best ninja and the love of Nakururu. After hearing the news Hanzo got extrem

2020-09-23 19:05:09 15

原创 LightOJ1214 Large Division(高精度除法求余)

题目链接Problem DescriptionGiven two integers, a and b, you should check whether a is divisible by b or not. We know that an integer a is divisible by an integer b if and only if there exists an integer c such that a = b * c.InputInput starts with an integ

2020-09-23 16:51:02 15

原创 LightOJ1236 Pairs Forming LCM(唯一分解定理)

题目链接题意用更加高效的方法计算图中所示程序的结果,要求i<=j并且LCM(i,j)=n,求满足条件的对数。思路根据lcm(a,b)=p1^max(a1,b1)×p2 ^ max(a2,b2)×…×pn ^ max(an,bn)可知当ai=ei时,bi可取[0,ei]范围内的任意数,bi=ei时同理,则共有2*(ei+1)种结果。但当三者都相同时,会出现重复的情况,所以需要减去。在所有剩余情况中,除了(n,n)外其余都出现了两次,所以先加一再除二即可得出结果。代码#include<

2020-09-22 10:49:00 19

原创 LightOJ1245 Harmonic Number (II)(整数分块)

题目链接Description题意求取图中的结果,但n会非常大。思路其实这是除法分块的板子题,由于除法运算时会出现许多结果相同的数,所以将这些数进行分块计算就可以提高运算的效率。代码#include<map>#include<set>#include<stack>#include<queue>#include<string>#include<math.h>#include<stdio.h>#in

2020-09-21 17:32:50 15

原创 AtCoder Beginner Contest 179 D题解

题目链接Problem StatementThere are N cells arranged in a row, numbered 1,2,…,N from left to right.Tak lives in these cells and is currently on Cell 1. He is trying to reach Cell N by using the procedure described below.You are given an integer K that is le

2020-09-21 15:32:50 38 1

原创 POJ3169 Layout(差分约束应用+SPFA)

题目链接DescriptionLike everyone else, cows like to stand close to their friends when queuing for feed. FJ has N (2 <= N <= 1,000) cows numbered 1…N standing along a straight line waiting for feed. The cows are standing in the same order as they are nu

2020-09-19 16:11:50 24

原创 Codeforces Round #662 (Div. 2) B——思维题

题意首先提供n块木板的长度,过程中会有两种操作方式:1.添加一块长度为x的木板2.删除一块长度为x的木板在每次操作后询问现有的木板是否可以组成一个正方形和一个矩形(此矩形同样可为正方形)思路我们可以使用数组记录下每个长度的木板的数量和此数量木板对应的个数,然后每次改变后通过个数判断是否可以满足条件。代码#include<map>#include<stack>#include<queue>#include<string>#include.

2020-09-19 10:50:11 13

原创 HDU2819 Swap(匈牙利算法——行列匹配)

题目链接Problem DescriptionGiven an NN matrix with each entry equal to 0 or 1. You can swap any two rows or any two columns. Can you find a way to make all the diagonal entries equal to 1?————————————————InputThere are several test cases in the input. The

2020-09-17 11:06:33 13

原创 HDU2444 The Accomodation of Students(二分图判断+匈牙利匹配)

题目链接Problem DescriptionThere are a group of students. Some of them may know each other, while others don’t. For example, A and B know each other, B and C know each other. But this may not imply that A and C know each other.Now you are given all pairs of

2020-09-16 19:47:59 15

原创 AtCoder Beginner Contest 178 F题解

题目链接Problem StatementGiven are two sequences A and B, both of length N. A and B are each sorted in the ascending order. Check if it is possible to reorder the terms of B so that for each i (1≤i≤N) Ai≠Bi holds, and if it is possible, output any of the reo

2020-09-15 14:24:55 14

原创 POJ1321 棋盘问题(DFS入门题)

Description在一个给定形状的棋盘(形状可能是不规则的)上面摆放棋子,棋子没有区别。要求摆放时任意的两个棋子不能放在棋盘中的同一行或者同一列,请编程求解对于给定形状和大小的棋盘,摆放k个棋子的所有可行的摆放方案C。————————————————Input输入含有多组测试数据。每组数据的第一行是两个正整数,n k,用一个空格隔开,表示了将在一个n*n的矩阵内描述棋盘,以及摆放棋子的数目。 n <= 8 , k <= n当为-1 -1时表示输入结束。随后的n行描述了棋盘的形状

2020-09-12 15:39:41 50

原创 POJ2502 Subway(建图+Dijkstra)

题目链接DescriptionYou have just moved from a quiet Waterloo neighbourhood to a big, noisy city. Instead of getting to ride your bike to school every day, you now get to walk and take the subway. Because you don’t want to be late for class, you want to know

2020-09-11 10:14:06 25

原创 POJ3268 Silver Cow Party(多次Dijkstra)

题目链接DescriptionOne cow from each of N farms (1 ≤ N ≤ 1000) conveniently numbered 1…N is going to attend the big cow party to be held at farm #X (1 ≤ X ≤ N). A total of M (1 ≤ M ≤ 100,000) unidirectional (one-way roads connects pairs of farms; road i requ

2020-07-30 04:49:56 47

原创 POJ2728 Desert King(01分数规划+Prime)

题目链接题意求最优比例生成树,即令∑cost[i]/∑dis[i]=ans尽可能小,对式子略作改变化为∑cost[i]-ans×dis[i]=0。由于ans未知,所以通过0/1分数规划+Prime对∑cost[i]-s×∑dis[i]=w进行求解。#include<bits/stdc++.h>using namespace std;const int mod=100000073;const int maxn=1e3+5;typedef long long ll;const int

2020-07-29 08:19:10 38

原创 HDU1845 Jimmy’s Assignment(匈牙利算法)

题目链接Jimmy’s AssignmentJimmy is studying Advanced Graph Algorithms at his university. His most recent assignment is to find a maximum matching in a special kind of graph. This graph is undirected, has N vertices and each vertex has degree 3. Furthermore,

2020-07-28 17:32:20 48

原创 HDU3339 In Action(Dijkstra+01背包)

题目链接In ActionSince 1945, when the first nuclear bomb was exploded by the Manhattan Project team in the US, the number of nuclear weapons have soared across the globe.Nowadays,the crazy boy in FZU named AekdyCoin possesses some nuclear weapons and wanna

2020-07-26 08:01:53 42

空空如也

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人 TA的粉丝

提示
确定要删除当前文章?
取消 删除