![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
搜索
文章平均质量分 58
哈哈哈哈哈v3v
这个作者很懒,什么都没留下…
展开
-
HDU - 2295 Radar (二分 + DLX求可重复覆盖)
N cities of the Java Kingdom need to be covered by radars for being in a state of war. Since the kingdom has M radar stations but only K operators, we can at most operate K radars. All radars have the same circular coverage with a radius of R. Our goal is原创 2021-03-25 15:28:37 · 102 阅读 · 0 评论 -
舞蹈链(Dancing Links)求解数独
讲解(写的太好了orzPOJ - 3074(3 * 3)题意:求3 * 3 * 3大小的数独#include <iostream>#include <cstdio>#include <cstring>#include <cmath>#include <algorithm>using namespace std;typedef long long ll;const int inf = 0x3f3f3f3f;const原创 2021-03-24 19:03:11 · 340 阅读 · 0 评论 -
舞蹈链(Dancing Links)——求精确覆盖问题
精确覆盖问题的定义:给定一个由0-1组成的矩阵,是否能找到一个行的集合,使得集合中每一列都恰好包含一个1例如:如下的矩阵就包含了这样一个集合(第1、4、5行)如何利用给定的矩阵求出相应的行的集合呢?我们采用回溯法矩阵1:先假定选择第1行,如下所示:如上图中所示,红色的那行是选中的一行,这一行中有3个1,分别是第3、5、6列。由于这3列已经包含了1,故,把这三列往下标示,图中的蓝色部分。蓝色部分包含3个1,分别在2行中,把这2行用紫色标示出来根据定义,...转载 2021-03-24 18:44:58 · 213 阅读 · 0 评论 -
牛客练习赛78 C. CCA的子树(搜索)
传送门思路:求两棵互不相关的子树点权和的最大值,用同一棵子树中的两个最大子树,更新答案,dfs每次返回子树中的最大子树和。(赛时把更新的最大值写错成了子树和#include <bits/stdc++.h>using namespace std;typedef long long ll;const ll inf = 1e17;const int mod = 1e9 + 7;const int N = 2e5 + 7;int n, u, v;ll a[N], ans,原创 2021-03-14 20:34:53 · 93 阅读 · 0 评论 -
2020 ICPC Taipei H.Optimization for UltraNet(二分 + 最小生成树)
题意:好长啊求一棵生成树,首先满足最短边最大,其次使任意两点路径上的最短边之和最小。思路:要使最短边取最大值,考虑二分最短边,判断当前能否生成一棵树,如果可以,考虑使任意两点路径上的最短边之和最小,也就是说,其余的边应该尽量小,即求最小生成树。建完图之后跑一遍任意两点路径上的最短边和就可以了。参考#include<bits/stdc++.h>using namespace std;typedef long long ll;const double eps = 1e...原创 2021-01-22 00:41:54 · 362 阅读 · 0 评论 -
计蒜客 - 42397 2019ICPC南京 C - Digital Path (记忆化搜索)
Zhe the bully, is condemned by all kinds of evil, like bullying those who are weaker. His teammates have been mistreated for a long time. Finally, they decided not to put up with their buddy any more and flee to Digital Village, with the bully in hot pursu原创 2020-12-09 19:39:22 · 461 阅读 · 1 评论 -
HDU - 5952 Counting Cliques (暴搜)
A clique is a complete graph, in which there is an edge between every pair of the vertices. Given a graph with N vertices and M edges, your task is to count the number of cliques with a specific size S in the graph.InputThe first line is the number of.原创 2020-11-24 19:25:25 · 204 阅读 · 0 评论 -
2017ccpc杭州 K. Master of Sequence(HDU - 6274 向下取整拆分 + 二分)
题意:浅显易懂不需要解释思路:令,,原式子可以化简为,即当时,第 i 项的值为,否则为原式子转化为了所以预处理,用二维数组表示所有时b[i] % a[i] >= y 的数目,二分 t 即可(用了4种二分来练练手,都能ac)#include<bits/stdc++.h>using namespace std;typedef long long ll;const ll mod = 998244353;const double eps ...原创 2020-11-09 16:46:57 · 183 阅读 · 0 评论 -
二分模板
二分模板一共有两个,分别适用于不同情况。算法思路:假设目标值在闭区间[l, r]中, 每次将区间长度缩小一半,当l = r时,我们就找到了目标值。版本1当我们将区间[l, r]划分成[l, mid]和[mid + 1, r]时,其更新操作是r = mid或者l = mid + 1;,计算mid时不需要加1。C++ 代码模板:int bsearch_1(int l, int r) { while (l < r) { int mid = (l + r) >&原创 2020-10-03 21:25:11 · 111 阅读 · 0 评论 -
HDU - 6736 Forest Program (思维 + 无向图暴力搜环)
The kingdom of Z is fighting against desertification these years since there are plenty of deserts in its wide and huge territory. The deserts are too arid to have rainfall or human habitation, and the only creatures that can live inside the deserts are th原创 2020-10-02 09:45:46 · 135 阅读 · 0 评论 -
HDU - 6665 Calabash and Landlord(离散化 + dfs)
Calabash is the servant of a landlord. The landlord owns a piece of land, which can be regarded as an infinite 2D plane.One day the landlord set up two orthogonal rectangular-shaped fences on his land. He asked Calabash a simple problem: how many nonempt.原创 2020-07-09 18:40:19 · 211 阅读 · 0 评论 -
HDU - 1078 FatMouse and Cheese (dfs + dp)
FatMouse has stored some cheese in a city. The city can be considered as a square grid of dimension n: each grid location is labelled (p,q) where 0 <= p < n and 0 <= q < n. At each grid lo...原创 2020-04-05 21:02:54 · 150 阅读 · 0 评论 -
ICPC North Central NA Contest 2017 E Is-A? Has-A? Who Knowz-A?(搜索 || floyd传递闭包)
Two familiar concepts in object oriented programming are the is-a and has-a relationships. Given two classes A and B, we say that A is-a B if A is a subclass of B; we say A has-a B if one of the field...原创 2020-03-01 17:26:58 · 222 阅读 · 0 评论 -
POJ - 3984 迷宫问题(bfs+路径标记)
定义一个二维数组:int maze[5][5] = { 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 0,};它表示一个迷宫,其中的1表示墙壁,0表示可以走的路,只能横着走或竖着走,不能斜着走,要求编程序找出从左上角到右下角的最短路线。Input一个5 × ...原创 2019-11-04 20:08:41 · 260 阅读 · 0 评论 -
POJ - 3414 Pots (bfs+路径标记)
You are given two pots, having the volume of A and B liters respectively. The following operations can be performed:FILL(i) fill the pot i (1 ≤ i ≤ 2) from the tap; DROP(i) empty the po...原创 2019-11-03 21:19:23 · 164 阅读 · 0 评论 -
POJ - 3087 Shuffle'm Up(搜索)
A common pastime for poker players at a poker table is to shuffle stacks of chips. Shuffling chips is performed by starting with two stacks of poker chips, S1 and S2, each stack containing C chips. Ea...原创 2019-11-03 17:06:21 · 170 阅读 · 0 评论 -
POJ - 3126 Prime Path (搜索)
The ministers of the cabinet were quite upset by the message from the Chief of Security stating that they would all have to change the four-digit room numbers on their offices.— It is a matter of ...原创 2019-11-03 15:28:03 · 118 阅读 · 0 评论 -
POJ - 1426 Find The Multiple (暴力搜索)
Given a positive integer n, write a program to find out a nonzero multiple m of n whose decimal representation contains only the digits 0 and 1. You may assume that n is not greater than 200 and there...原创 2019-11-02 16:30:26 · 87 阅读 · 0 评论 -
POJ - 3278 Catch That Cow (搜索)
Farmer John has been informed of the location of a fugitive cow and wants to catch her immediately. He starts at a point N (0 ≤ N ≤ 100,000) on a number line and the cow is at a point K (0 ≤ K ≤ 100,0...原创 2019-11-02 11:44:04 · 83 阅读 · 0 评论 -
POJ - 2251 Dungeon Master(搜索)
You are trapped in a 3D dungeon and need to find the quickest way out! The dungeon is composed of unit cubes which may or may not be filled with rock. It takes one minute to move one unit north, south...原创 2019-11-01 20:50:14 · 151 阅读 · 0 评论 -
POJ - 1321 棋盘问题(搜索)
在一个给定形状的棋盘(形状可能是不规则的)上面摆放棋子,棋子没有区别。要求摆放时任意的两个棋子不能放在棋盘中的同一行或者同一列,请编程求解对于给定形状和大小的棋盘,摆放k个棋子的所有可行的摆放方案C。Input输入含有多组测试数据。每组数据的第一行是两个正整数,n k,用一个空格隔开,表示了将在一个n*n的矩阵内描述棋盘,以及摆放棋子的数目。 n <= 8 , k <= n...原创 2019-10-31 23:59:38 · 174 阅读 · 0 评论 -
n皇后(dfs)
Description在N*N的方格棋盘放置了N个皇后,使得它们不相互攻击(即任意2个皇后不允许处在同一排,同一列,也不允许处在与棋盘边框成45角的斜线上。你的任务是,对于给定的N,求出有多少种合法的放置方法。Input共有若干行,每行一个正整数N≤10,表示棋盘和皇后的数量。Output共有若干行,每行一个正整数,表示对应输入行的皇后的不同放置数量。Sample Inp...原创 2019-10-31 21:15:04 · 114 阅读 · 0 评论